⚠️ Work in progress — createCMS is pre-1.0 and not production-ready (not tested in production). Expect breaking changes.
createCMS
Reference

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
GET/{collection}/listBranches
const { data, error } = await client.pages.listBranches({
  query: {
    rootId: 'root_123', // required
    limit: 50,
  },
});
Parameters
rootIdstringrequired

Root whose branches to list.

limitnumber= 20

Page size, 1 to 100.

offsetnumber= 0

Rows to skip.

searchstring

Case-insensitive substring match on branch name.

isDeletableboolean

Keep only deletable branches (true) or only protected ones (false).

hasPublicationsboolean

Keep only branches with (true) or without (false) any publication.

hasOpenMergeRequestsboolean

Keep only branches with (true) or without (false) an open merge request.

Returns
branchesBranchListItem[]

The branches on this page. Each has id, rootId, name, headCommitId, createdBy, createdAt, updatedAt, plus `hasPublications` and `isDeletable`.

totalnumber

Total branches matching the filters across all pages, ignoring limit/offset.

hasMoreboolean

Whether 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
GET/{collection}/getBranch
const { data, error } = await client.pages.getBranch({
  query: { rootId: 'root_123', name: 'draft' }, // or { branchId: 'br_main' }
});
Parameters
branchIdstring

Look up by primary key. Use this, or the `{ rootId, name }` pair.

rootIdstring

Look up by root plus branch name. Requires `name`.

namestring

Branch name, unique per root. Requires `rootId`.

Returns
idstring

The branch id.

rootIdstring

The root the branch belongs to.

namestring

The branch name, unique within the root.

headCommitIdstring

The commit currently at the branch head.

createdBystring | null

Actor id that created the branch, or null.

createdAtDate

When the branch was created.

updatedAtDate

When the branch was last updated.

isDeletableboolean

Whether 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
POST/{collection}/createBranch
const { data, error } = await client.pages.createBranch({
  body: {
    rootId: 'root_123', // required
    name: 'feature-hero', // required
    sourceBranchId: 'br_main', // required
  },
});
Parameters
rootIdstringrequired

Root the branch belongs to.

namestringrequired

New branch name, unique within the root.

sourceBranchIdstringrequired

Branch whose head commit seeds the new branch.

createdBystring

Fallback actor id, used only when no session user is present.

Returns
branchBranch

The newly created branch row: `{ id, rootId, name, headCommitId, createdBy, createdAt, updatedAt }`.

isDeletableboolean

Always `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
POST/{collection}/renameBranch
const { data, error } = await client.pages.renameBranch({
  body: {
    branchId: 'br_feature', // required
    newName: 'feature-hero', // required
  },
});
Parameters
branchIdstringrequired

Branch to rename.

newNamestringrequired

New name, unique within the root.

Returns
branchBranch

The updated branch row with its new name and refreshed `updatedAt`.

isDeletableboolean

Whether 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
POST/{collection}/revertBranch
const { data, error } = await client.pages.revertBranch({
  body: {
    branchId: 'br_feature', // required
    targetCommitId: 'commit_abc', // required
  },
});
Parameters
branchIdstringrequired

Branch to revert.

targetCommitIdstringrequired

Commit whose snapshot to restore.

messagestring

Commit message. Defaults to an auto-generated one.

createdBystring

Fallback actor id, used only when no session user is present.

Returns
commitCommit

The 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
GET/{collection}/checkDivergence
const { data, error } = await client.pages.checkDivergence({
  query: {
    sourceBranchId: 'br_feature', // required
    targetBranchId: 'br_main', // required
  },
});
Parameters
sourceBranchIdstringrequired

Source branch to compare.

targetBranchIdstringrequired

Target branch to compare.

Returns
hasCommonAncestorboolean

Whether the two branches share a common ancestor commit.

commonAncestorCommitIdstring | null

The shared ancestor commit id, or null when there is none.

sourceAheadnumber

How many commits the source branch is ahead of the common ancestor.

targetAheadnumber

How many commits the target branch is ahead of the common ancestor.

canFastForwardboolean

Whether 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
POST/{collection}/deleteBranch
const { data, error } = await client.pages.deleteBranch({
  body: { branchId: 'br_feature' }, // required
});
Parameters
branchIdstringrequired

Branch to delete.

Returns
branchIdstring

The id of the deleted branch.

On this page