> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# UpdateBranch

# Package: branches

# Namespace: BranchesService

# Method link: https://dev.wix.com/docs/api-reference/business-management/branches/update-branch.md

## Permission Scopes:
Manage Site Branches: SCOPE.DC-DOCUMENT-MANAGEMENT.MANAGE-BRANCHES

## Introduction

Updates a branch.

Each time the branch is updated, `revision` increments by 1. If the current `revision` is passed, it's validated to ensure you're working with the latest branch and prevents unintended overwrites. If `revision` isn't passed, the update is applied without a revision check.

Note that `ORIGINAL_BRANCH` types can't be updated.

---

## REST API

### Schema

```
 Method: updateBranch
 Description: Updates a branch.  Each time the branch is updated, `revision` increments by 1. If the current `revision` is passed, it's validated to ensure you're working with the latest branch and prevents unintended overwrites. If `revision` isn't passed, the update is applied without a revision check.  Note that `ORIGINAL_BRANCH` types can't be updated.
 URL: https://www.wixapis.com/branches/v1/branches/{branch.id}
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  branch, branch.id
 Method parameters: 
   param name: branch | type: Branch | description: A branch is a version of draft site content that can be edited independently. Also known as a test site.  Branches let site owners and developers create isolated versions of a site for testing changes without affecting the live site. Each branch maintains its own content, design, and settings while sharing the same site infrastructure.  Learn more about [branches](https://support.wix.com/en/article/about-test-sites). | required: true 
    - ONE-OF: - required: true
     - name: sourceBranchProperties | type: SourceBranch | description: Source branch properties. Use when `sourceType` = `SOURCE_BRANCH`.  
        - name: branchId | type: string | description: Source branch GUID.  | validation: format GUID
        - name: branchRevision | type: string | description: Revision number of the source branch when this branch was created. To prevent conflicting changes, the current revision must be passed when updating the branch.  | validation: format int64
     - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`.  
        - name: templateId | type: string | description: GUID of the source template.  | validation: format GUID
        - name: id | type: string | description: Branch GUID. | required: true | read-only: true | validation: format GUID
        - name: type | type: Type | description: Branch type.  
             - enum:
             -     USER: A branch created by a site owner that can be accessed for editing and publishing in the editor.
             -     TECHNICAL: A branch created for technical purposes, unrelated to site owners. For internal use, can't be accessed in the editor.
             -     ORIGINAL_BRANCH: The original branch of the site, created when the site is created. Can be accessed for editing and publishing in the editor.
        - name: name | type: string | description: Branch name.  | validation: maxLength 50
        - name: sourceType | type: SourceType | description: Source type for this branch's content. Must be aligned with the corresponding source properties below.  
             - enum:
             -     SOURCE_BRANCH: This branch's source was another branch. Must be used with `sourceBranchProperties`.
        - name: editorType | type: EditorType | description: Wix editor type. Provide this field only when the new branch uses a different editor than the branch it was created from, and the branch is not created from a template. Only `STUDIO_TWO` may be provided explicitly; otherwise the editor type is calculated automatically.  | validation: immutable
           - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types.  
                 - enum:
                 -     STUDIO: Wix Studio Editor.
                 -     CLASSIC: Wix's Classic Editor.
                 -     HARMONY: Wix Type Harmony Editor.
                 -     STUDIO_TWO: Wix StudioTwo Editor.
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the branch. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
           - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
        - name: tags | type: PublicTags | description: Public tags assigned to the branch.  
           - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
              - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
 Return type: UpdateBranchResponse
  - name: branch | type: Branch | description: Updated branch.  
     - ONE-OF: 
        - name: sourceBranchProperties | type: SourceBranch | description: Source branch properties. Use when `sourceType` = `SOURCE_BRANCH`.  
           - name: branchId | type: string | description: Source branch GUID.  | validation: format GUID
           - name: branchRevision | type: string | description: Revision number of the source branch when this branch was created. To prevent conflicting changes, the current revision must be passed when updating the branch.  | validation: format int64
        - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`.  
           - name: templateId | type: string | description: GUID of the source template.  | validation: format GUID
     - name: id | type: string | description: Branch GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, pass the current revision when updating the branch. If omitted, the update is applied without a revision check.  | read-only: true | validation: format int64
     - name: type | type: Type | description: Branch type.  
         - enum:
         -     USER: A branch created by a site owner that can be accessed for editing and publishing in the editor.
         -     TECHNICAL: A branch created for technical purposes, unrelated to site owners. For internal use, can't be accessed in the editor.
         -     ORIGINAL_BRANCH: The original branch of the site, created when the site is created. Can be accessed for editing and publishing in the editor.
     - name: name | type: string | description: Branch name.  | validation: maxLength 50
     - name: sourceType | type: SourceType | description: Source type for this branch's content. Must be aligned with the corresponding source properties below.  
         - enum:
         -     SOURCE_BRANCH: This branch's source was another branch. Must be used with `sourceBranchProperties`.
     - name: lastPublishDate | type: string | description: Date and time the branch was last published.  | read-only: true | validation: format int64
     - name: editorType | type: EditorType | description: Wix editor type. Provide this field only when the new branch uses a different editor than the branch it was created from, and the branch is not created from a template. Only `STUDIO_TWO` may be provided explicitly; otherwise the editor type is calculated automatically.  | validation: immutable
        - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types.  
             - enum:
             -     STUDIO: Wix Studio Editor.
             -     CLASSIC: Wix's Classic Editor.
             -     HARMONY: Wix Type Harmony Editor.
             -     STUDIO_TWO: Wix StudioTwo Editor.
     - name: default | type: boolean | description: Whether this branch is the default branch. The default branch is used for API operations when no branch GUID is specified.  | read-only: true 
     - name: createdDate | type: string | description: Date and time the branch was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the branch was last updated.  | read-only: true | validation: format date-time
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the branch. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
     - name: tags | type: PublicTags | description: Public tags assigned to the branch.  
        - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
           - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: FORBIDDEN_UPDATE_ORIGINAL_BRANCH_TYPE | Description: Can't update branches with `ORIGINAL_BRANCH` type.


```

### Examples

### Update Branch From Source Branch
Update branch name. NOTE: revision must be specified - use the latest branch's revision

```curl
curl -X PATCH \
    'https://www.wixapis.com/branches/v1/branches/11111111-1111-1111-1111-111111111111' \
    -H 'Authorization: <AUTH>' \
    -H 'Content-Type: application/json' \
    -d '{"branch":{
            "id":"11111111-1111-1111-1111-111111111111",
            "revision":"1",
            "name": "newName"
            }
        }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.editorBranches.branches.updateBranch(_id, branch)
 Description: Updates a branch.  Each time the branch is updated, `revision` increments by 1. If the current `revision` is passed, it's validated to ensure you're working with the latest branch and prevents unintended overwrites. If `revision` isn't passed, the update is applied without a revision check.  Note that `ORIGINAL_BRANCH` types can't be updated.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  branch, _id
 Method parameters: 
   param name: _id | type: string | description: Branch GUID. | required: true | validation: format GUID
   param name: branch | type: UpdateBranch | description: A branch is a version of draft site content that can be edited independently. Also known as a test site.  Branches let site owners and developers create isolated versions of a site for testing changes without affecting the live site. Each branch maintains its own content, design, and settings while sharing the same site infrastructure.  Learn more about [branches](https://support.wix.com/en/article/about-test-sites). | required: true 
    - ONE-OF: - required: true
     - name: sourceBranchProperties | type: SourceBranch | description: Source branch properties. Use when `sourceType` = `SOURCE_BRANCH`.  
        - name: branchId | type: string | description: Source branch GUID.  | validation: format GUID
        - name: branchRevision | type: string | description: Revision number of the source branch when this branch was created. To prevent conflicting changes, the current revision must be passed when updating the branch.  | validation: format int64
     - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`.  
        - name: templateId | type: string | description: GUID of the source template.  | validation: format GUID
        - name: type | type: Type | description: Branch type.  
             - enum:
             -     USER: A branch created by a site owner that can be accessed for editing and publishing in the editor.
             -     TECHNICAL: A branch created for technical purposes, unrelated to site owners. For internal use, can't be accessed in the editor.
             -     ORIGINAL_BRANCH: The original branch of the site, created when the site is created. Can be accessed for editing and publishing in the editor.
        - name: name | type: string | description: Branch name.  | validation: maxLength 50
        - name: sourceType | type: SourceType | description: Source type for this branch's content. Must be aligned with the corresponding source properties below.  
             - enum:
             -     SOURCE_BRANCH: This branch's source was another branch. Must be used with `sourceBranchProperties`.
        - name: editorType | type: EditorType | description: Wix editor type. Provide this field only when the new branch uses a different editor than the branch it was created from, and the branch is not created from a template. Only `STUDIO_TWO` may be provided explicitly; otherwise the editor type is calculated automatically.  | validation: immutable
           - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types.  
                 - enum:
                 -     STUDIO: Wix Studio Editor.
                 -     CLASSIC: Wix's Classic Editor.
                 -     HARMONY: Wix Type Harmony Editor.
                 -     STUDIO_TWO: Wix StudioTwo Editor.
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the branch. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
           - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
        - name: tags | type: PublicTags | description: Public tags assigned to the branch.  
           - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
              - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
 Return type: PROMISE<Branch>
  - ONE-OF: 
     - name: sourceBranchProperties | type: SourceBranch | description: Source branch properties. Use when `sourceType` = `SOURCE_BRANCH`.  
        - name: branchId | type: string | description: Source branch GUID.  | validation: format GUID
        - name: branchRevision | type: string | description: Revision number of the source branch when this branch was created. To prevent conflicting changes, the current revision must be passed when updating the branch.  | validation: format int64
     - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`.  
        - name: templateId | type: string | description: GUID of the source template.  | validation: format GUID
  - name: _id | type: string | description: Branch GUID.  | read-only: true | validation: format GUID
  - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, pass the current revision when updating the branch. If omitted, the update is applied without a revision check.  | read-only: true | validation: format int64
  - name: type | type: Type | description: Branch type.  
     - enum:
     -     USER: A branch created by a site owner that can be accessed for editing and publishing in the editor.
     -     TECHNICAL: A branch created for technical purposes, unrelated to site owners. For internal use, can't be accessed in the editor.
     -     ORIGINAL_BRANCH: The original branch of the site, created when the site is created. Can be accessed for editing and publishing in the editor.
  - name: name | type: string | description: Branch name.  | validation: maxLength 50
  - name: sourceType | type: SourceType | description: Source type for this branch's content. Must be aligned with the corresponding source properties below.  
     - enum:
     -     SOURCE_BRANCH: This branch's source was another branch. Must be used with `sourceBranchProperties`.
  - name: lastPublishDate | type: string | description: Date and time the branch was last published.  | read-only: true | validation: format int64
  - name: editorType | type: EditorType | description: Wix editor type. Provide this field only when the new branch uses a different editor than the branch it was created from, and the branch is not created from a template. Only `STUDIO_TWO` may be provided explicitly; otherwise the editor type is calculated automatically.  | validation: immutable
     - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types.  
         - enum:
         -     STUDIO: Wix Studio Editor.
         -     CLASSIC: Wix's Classic Editor.
         -     HARMONY: Wix Type Harmony Editor.
         -     STUDIO_TWO: Wix StudioTwo Editor.
  - name: default | type: boolean | description: Whether this branch is the default branch. The default branch is used for API operations when no branch GUID is specified.  | read-only: true 
  - name: _createdDate | type: Date | description: Date and time the branch was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the branch was last updated.  | read-only: true 
  - name: extendedFields | type: ExtendedFields | description: Custom field data for the branch. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
     - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
  - name: tags | type: PublicTags | description: Public tags assigned to the branch.  
     - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
        - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: FORBIDDEN_UPDATE_ORIGINAL_BRANCH_TYPE | Description: Can't update branches with `ORIGINAL_BRANCH` type.


```

### Examples

### updateBranch
```javascript
import { branches } from '@wix/editor-branches';

async function updateBranch(_id,branch) {
  const response = await branches.updateBranch(_id,branch);
};
```

### updateBranch (with elevated permissions)
```javascript
import { branches } from '@wix/editor-branches';
import { auth } from '@wix/essentials';

async function myUpdateBranchMethod(_id,branch) {
  const elevatedUpdateBranch = auth.elevate(branches.updateBranch);
  const response = await elevatedUpdateBranch(_id,branch);
}
```

### updateBranch (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { branches } from '@wix/editor-branches';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { branches },
  // Include the auth strategy and host as relevant
});


async function updateBranch(_id,branch) {
  const response = await myWixClient.branches.updateBranch(_id,branch);
};
```

---