Branches API
Create and manage branches (drafts) of an entry.
Branches are the drafts of an entry (root): each one is an independent line of commits you can edit, publish, and merge back. Methods live at cms.api.<collection>.<method> (use your collection name, e.g. cms.api.pages.listBranches) and mirror on the client with identical types. Every commit-producing mutation returns a commit envelope: { id, message, createdAt, createdBy }.
Methods
List Branches
List the branches of an entry, with pagination and filters for publication and merge-request state. Each item carries isDeletable and hasPublications, so you can tell at a glance which drafts are safe to remove.
branch:read/{collection}/listBranchesconst data = await cms.api.pages.listBranches({
query: {
rootId: 'root_123', // required
limit: 50,
},
});const { data, error } = await client.pages.listBranches({
query: {
rootId: 'root_123', // required
limit: 50,
},
});rootIdstringrequiredRoot whose branches to list.
limitnumber= 20Page size, 1 to 100.
offsetnumber= 0Rows to skip.
searchstringCase-insensitive substring match on branch name.
isDeletablebooleanKeep only deletable branches (true) or only protected ones (false).
hasPublicationsbooleanKeep only branches with (true) or without (false) any publication.
hasOpenMergeRequestsbooleanKeep only branches with (true) or without (false) an open merge request.
branchesBranchListItem[]The branches on this page. Each has id, rootId, name, headCommitId, createdBy, createdAt, updatedAt, plus `hasPublications` and `isDeletable`.
totalnumberTotal branches matching the filters across all pages, ignoring limit/offset.
hasMorebooleanWhether more branches exist after this page.
Get a Branch
Fetch a single branch with its metadata and isDeletable flag. Look it up either by branchId, or by its { rootId, name } pair (branch names are unique per root), so you can resolve a branch you only know by name without paging through listBranches.
branch:read/{collection}/getBranchconst data = await cms.api.pages.getBranch({
query: { rootId: 'root_123', name: 'draft' }, // or { branchId: 'br_main' }
});const { data, error } = await client.pages.getBranch({
query: { rootId: 'root_123', name: 'draft' }, // or { branchId: 'br_main' }
});branchIdstringLook up by primary key. Use this, or the `{ rootId, name }` pair.
rootIdstringLook up by root plus branch name. Requires `name`.
namestringBranch name, unique per root. Requires `rootId`.
idstringThe branch id.
rootIdstringThe root the branch belongs to.
namestringThe branch name, unique within the root.
headCommitIdstringThe commit currently at the branch head.
createdBystring | nullActor id that created the branch, or null.
createdAtDateWhen the branch was created.
updatedAtDateWhen the branch was last updated.
isDeletablebooleanWhether the branch can be deleted (not the default branch, no publications or open merge requests).
Create a Branch
Spin up a new branch by copying the head commit of a source branch. You get back the fresh branch, whose isDeletable is always true since it has no publications or open merge requests yet.
branch:create/{collection}/createBranchconst data = await cms.api.pages.createBranch({
body: {
rootId: 'root_123', // required
name: 'feature-hero', // required
sourceBranchId: 'br_main', // required
},
});const { data, error } = await client.pages.createBranch({
body: {
rootId: 'root_123', // required
name: 'feature-hero', // required
sourceBranchId: 'br_main', // required
},
});rootIdstringrequiredRoot the branch belongs to.
namestringrequiredNew branch name, unique within the root.
sourceBranchIdstringrequiredBranch whose head commit seeds the new branch.
createdBystringFallback actor id, used only when no session user is present.
branchBranchThe newly created branch row: `{ id, rootId, name, headCommitId, createdBy, createdAt, updatedAt }`.
isDeletablebooleanAlways `true` for a fresh branch (never the default branch, no publications or open merge requests yet).
Rename a Branch
Rename a branch and get the updated row back. Fails with CANNOT_RENAME_MAIN_BRANCH for the default branch, or BRANCH_NAME_ALREADY_EXISTS if the name is taken in the root.
branch:update/{collection}/renameBranchconst data = await cms.api.pages.renameBranch({
body: {
branchId: 'br_feature', // required
newName: 'feature-hero', // required
},
});const { data, error } = await client.pages.renameBranch({
body: {
branchId: 'br_feature', // required
newName: 'feature-hero', // required
},
});branchIdstringrequiredBranch to rename.
newNamestringrequiredNew name, unique within the root.
branchBranchThe updated branch row with its new name and refreshed `updatedAt`.
isDeletablebooleanWhether the renamed branch can be deleted (not the default branch, no publications or open merge requests).
Revert a Branch
Roll a branch back to the snapshot at an earlier commit. This writes a new commit with that state onto the branch head (it never rewrites history), and is blocked while the branch is published.
branch:update/{collection}/revertBranchconst data = await cms.api.pages.revertBranch({
body: {
branchId: 'br_feature', // required
targetCommitId: 'commit_abc', // required
},
});const { data, error } = await client.pages.revertBranch({
body: {
branchId: 'br_feature', // required
targetCommitId: 'commit_abc', // required
},
});branchIdstringrequiredBranch to revert.
targetCommitIdstringrequiredCommit whose snapshot to restore.
messagestringCommit message. Defaults to an auto-generated one.
createdBystringFallback actor id, used only when no session user is present.
commitCommitThe revert commit written onto the branch head: `{ id, message, createdAt, createdBy }`.
Check Divergence
Compare two branches of the same root to see how far they have diverged: their common ancestor, how many commits each is ahead, and whether the source can fast-forward onto the target. Fails with BRANCHES_NOT_SAME_ROOT if the branches belong to different roots.
branch:read/{collection}/checkDivergenceconst data = await cms.api.pages.checkDivergence({
query: {
sourceBranchId: 'br_feature', // required
targetBranchId: 'br_main', // required
},
});const { data, error } = await client.pages.checkDivergence({
query: {
sourceBranchId: 'br_feature', // required
targetBranchId: 'br_main', // required
},
});sourceBranchIdstringrequiredSource branch to compare.
targetBranchIdstringrequiredTarget branch to compare.
hasCommonAncestorbooleanWhether the two branches share a common ancestor commit.
commonAncestorCommitIdstring | nullThe shared ancestor commit id, or null when there is none.
sourceAheadnumberHow many commits the source branch is ahead of the common ancestor.
targetAheadnumberHow many commits the target branch is ahead of the common ancestor.
canFastForwardbooleanWhether the source can fast-forward onto the target (the target has not moved past the ancestor).
Delete a Branch
Delete a branch. Fails with CANNOT_DELETE_MAIN_BRANCH for the default branch, BRANCH_HAS_PUBLICATIONS if it has any publication, or BRANCH_HAS_OPEN_MERGE_REQUESTS if it is part of an open merge request.
branch:delete/{collection}/deleteBranchconst data = await cms.api.pages.deleteBranch({
body: { branchId: 'br_feature' }, // required
});const { data, error } = await client.pages.deleteBranch({
body: { branchId: 'br_feature' }, // required
});branchIdstringrequiredBranch to delete.
branchIdstringThe id of the deleted branch.