repos.branches.create
Create a new branch from an existing branch or ref. This is useful for agent workflows, ephemeral previews, or server-side automation where you do not want to clone the repo first. The base ref must exist. A new empty repository has no branch until its first commit, so the request returns 404.
Scope: git:write on the repository.
Guard a branch write
Setexpected_target_sha to control whether the branch can change:
409 with code conflict and leaves the branch unchanged. The guard
applies with or without force. It also applies to ephemeral branches. force permits a
non-fast-forward move, subject to the token’s ref policies; it does not bypass the guard.
For example, create a branch only when its name is available:
base_ref to the destination commit and expected_target_sha to its current
tip. A non-zero guard requires target_branch. Without target_branch, the server allocates a new
name with a create-only guard.Authorizations
JWT bearer token signed with your organization's registered signing key. There is no OAuth authorization server; you mint tokens yourself and the token's scopes claim carries the granted permission scopes. Public scopes: git:read (read repository contents), git:write (write branches, commits, tags, and notes), repo:write (create and manage repositories), org:read (list an organization's repositories). Each operation's security requirement names the scopes it requires. See https://code.storage/docs/getting-started/authentication for how to mint tokens.
Body
Create or move a branch from another branch or ref. The source and destination can live in the default namespace or the ephemeral namespace. Set expected_target_sha to 40 zeros to require a new branch, or to the current tip to guard a move. A failed guard returns 409 conflict without changing the branch, even with force.
Create-branch request body describing the new branch and its base ref.
Response
Branch creation result.
Result of creating a branch, including the resulting ref state.