---
title: "Open or close a branch to viewers"
method: PATCH
path: "/v1/branches/{branchId}"
tags: ["Branches"]
---

# Open or close a branch to viewers

`PATCH /v1/branches/{branchId}`

## Request

- Base URL: `https://blobsrus.omniapp.co/api`
- URL: `https://blobsrus.omniapp.co/api/v1/branches/{branchId}`
- Auth: HTTP bearer

<Note>
  Opening a branch with this endpoint requires permission to edit every model in the branch.
  
  Closing a branch only requires permission to edit the branch on one of its member models.
</Note>

Open a branch to Viewers and Restricted Queriers - including embed users - so they see the branch's content instead of production, or close it again. See [Opening a branch to viewers](/content/develop/branch-mode#opening-a-branch-to-viewers) for more information.

## Path parameters

- `branch_id` string, uuid, required

## Query parameters

- `userId` string, uuid

## Request body

- object
  - `openToViewers` boolean, required: `true` to open the branch to Viewers and Restricted Queriers, `false` to close it.

## Response `200`

The branch was opened or closed successfully.

- object
  - `branch` object
    - `id` string, uuid: The organization-wide branch ID.
    - `name` string: The branch's name.
    - `openToViewers` boolean: The branch's new state.
  - `success` boolean: Whether the operation succeeded.

## Other responses

- `400`: Bad Request Possible error messages: - `openToViewers` is missing or isn't a JSON boolean - An Organization API key was used without a `userId`
- `403`: Forbidden Possible error messages: - `Opening a branch to viewers needs permission to edit every model in it` - Closing a branch to viewers needs permission to edit the branch on at least one of its models - A Personal Access Token was used with a `userId` naming a different member
- `404`: Not Found Possible error messages: - `Branch with id <branchId> does not exist` - the ID names a retired branch, a model-level layer ID rather than an org-wide branch ID, or a branch in another organization - `User with id <userId> does not exist` - an Organization API key named a `userId` who hasn't accepted their invitation
- `405`: Method Not Allowed
- `429`: Too Many Requests - Rate limit exceeded (60 requests/minute)
- `500`: Internal Server Error

## Changes

- **2026-11-03** `43290040f88f`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/omni/apis/omni-api/changes/v1/branches/:branchId/patch.md)

---

[API](https://skmtc.dev/omni/apis/omni-api.md) - [All operations](https://skmtc.dev/omni/apis/omni-api/llms.txt) - [OpenAPI document](https://skmtc.dev/omni/apis/omni-api/revisions/43290040f88f?raw)
