> 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`). > - 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. The current `revision` must be passed when updating the branch. This ensures you're working with the latest branch and prevents unintended overwrites. 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. The current `revision` must be passed when updating the branch. This ensures you're working with the latest branch and prevents unintended overwrites. 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, branch.revision 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. - 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. - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`. - name: templateId | type: string | description: Source template GUID. - name: id | type: string | description: Branch GUID. | required: true - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, the current revision must be passed when updating the branch. | required: true - 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. - 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: 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). - 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 | description: List of tag GUIDs. 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. - 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. - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`. - name: templateId | type: string | description: Source template GUID. - name: id | type: string | description: Branch GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, the current revision must be passed when updating the branch. - 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. - 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. - name: editorType | type: EditorType | description: Wix editor type. - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types. - enum: - STUDIO: Wix Studio Editor. - CLASSIC: Wix's Classic 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. - name: createdDate | type: string | description: Date and time the branch was created. - name: updatedDate | type: string | description: Date and time the branch was last updated. - 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). - 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 | description: List of tag GUIDs. 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: ' \ -H 'Content-Type: application/json' \ -d '{"branch":{ "id":"11111111-1111-1111-1111-111111111111", "revision":"1", "name": "newName" } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.branches.BranchesService.updateBranch(_id, branch) Description: Updates a branch. Each time the branch is updated, `revision` increments by 1. The current `revision` must be passed when updating the branch. This ensures you're working with the latest branch and prevents unintended overwrites. 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, branch.revision Method parameters: param name: _id | type: string | description: Branch GUID. | required: true 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. - 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. - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`. - name: templateId | type: string | description: Source template GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, the current revision must be passed when updating the branch. | required: true - 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. - 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: 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). - 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 | description: List of tag GUIDs. Return type: PROMISE - ONE-OF: - name: sourceBranchProperties | type: SourceBranch | description: Source branch properties. Use when `sourceType` = `SOURCE_BRANCH`. - name: branchId | type: string | description: Source branch 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. - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`. - name: templateId | type: string | description: Source template GUID. - name: _id | type: string | description: Branch GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, the current revision must be passed when updating the branch. - 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. - 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. - name: editorType | type: EditorType | description: Wix editor type. - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types. - enum: - STUDIO: Wix Studio Editor. - CLASSIC: Wix's Classic 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. - name: _createdDate | type: Date | description: Date and time the branch was created. - name: _updatedDate | type: Date | description: Date and time the branch was last updated. - 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). - 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 | description: List of tag GUIDs. 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-hosted) Self-hosted 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); }; ``` ---