Codebranches
POST/repositories/{repo_id}/branches
Create a branch in a repository
create_branch
branch:create
A token needs thebranch:createscope: Create branchesGranted bymcp_agent_write,write_api,write_repository.Every operation this scope unlocksAudited · mutation
x-gitmoap-audit: {"kind":"audited","arg":"mutation"}
Quota (deferred) · branches per repo
x-gitmoap-quota: {"kind":"deferred","arg":"branches_per_repo"}
Creates a branch at a commit, a branch or a tag. It passes the same branch rules and push rules
a git push does, so a name a rule protects is refused here just as it would be from git.
Parameters
Path
- repo_idRepositoryId (string · uuid)Repository ID
Request body
application/json- branch_nameBranchName (string)
- from_branchBranchName (string)
Request body exampleSynthesized example
{
"branch_name": "refactor/brand-inline",
"from_branch": "fix/payload-build-pin"
}
Responses
201Branch createdapplication/json
- aheadinteger · int320–∞
- behindinteger · int320–∞
- branch_nameBranchName (string)
commitCommit
- The Commit schema
- author_emailEmail (string)
- author_namestring
- authored_atstring
- commit_shaCommitHash (string)
- committed_atstring
- committer_emailEmail (string)
- committer_namestring
- repository_idRepositoryId (string · uuid)
- short_shaShortCommitHash (string)
- titlestring
- author_avatar_urlstring or nulloptional
- committer_avatar_urlstring or nulloptional
- messagestring or nulloptional
- parent_shasarray of CommitHash (string)optional
- tagsarray of TagName (string)optional
open_merge_requestsarray of BranchMergeRequestRefThe open merge requests proposing this branch — one per target branch at most. A commit to the branch updates each of them.
- The BranchMergeRequestRef schema
- iidMergeRequestId (integer · int64)The merge request's number in its repository.
- target_branchBranchName (string)Where it proposes to merge the branch.
- protectedbooleanA branch rule protects this branch.
- repository_idRepositoryId (string · uuid)
- viewer_can_pushbooleanWhether the caller may push to this branch — the same verdict a
git pushor a commit written in the browser gets.falsefor someone not signed in. - push_refusalstring or nulloptionalWhy the caller may not push here, in a sentence to show them. Absent when they may.
201 exampleSynthesized example
{
"ahead": 3,
"behind": 1,
"branch_name": "feature/region-legend",
"commit": {
"author_email": "mara@acme.example",
"author_name": "Mara Okafor",
"authored_at": "2026-10-12T19:28:58Z",
"commit_sha": "593d5bf33a778a9d80d8cf55ef3bccf6856e83b2",
"committed_at": "2026-10-16T17:33:05Z",
"committer_email": "mara@acme.example",
"committer_name": "payments-api",
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"short_sha": "bcb12f7ceb01ec953033bbb25e63df6a68a1483b",
"title": "Label every synthesized example",
"author_avatar_url": "https://gitmoap.example/acme/525b9375",
"committer_avatar_url": "https://gitmoap.example/acme/911cae59",
"message": "Draw the region map from operation density",
"parent_shas": [
"f5e595ea825c9374ebb18f2797beec1cb33494d5",
"42efca1230f22580a3658d469e5656661552404a"
],
"tags": [
"tags-8df0"
]
},
"open_merge_requests": [
{
"iid": 42,
"target_branch": "main"
}
],
"protected": false,
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"viewer_can_push": false,
"push_refusal": "push-refusal-5015"
}
400Invalid requestapplication/json
Error codes
- BAD_REQUESTThe request is malformed: a parameter or a body field is not a well-formed value of its type
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
400 exampleSynthesized example
{
"error": {
"code": "code-1308",
"message": "Draw the region map from operation density"
}
}
401Unauthenticated — no credential, or an invalid oneapplication/json
Error codes
- UNAUTHORIZEDNo credential was sent, or the one sent is invalid, expired or revoked
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
401 exampleSynthesized example
{
"error": {
"code": "code-7d09",
"message": "Stream pipeline status into the run header"
}
}
403The caller may not push here, or a branch rule protects this nameapplication/json
Error codes
- BRANCH_PROTECTEDA branch rule keeps you from changing this branch this way
- FORBIDDENYou are signed in but may not do this here;
reasonnames the permission or the rule that refused it - INSUFFICIENT_SCOPEThe access token lacks the scope this operation needs;
required_scopenames it - PERMISSION_REQUIREDYou need a permission you do not hold here; the message names it
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
403 exampleSynthesized example
{
"error": {
"code": "code-ede6",
"message": "Inline scalar newtypes but keep their brand"
}
}
404Repository or source branch not foundapplication/json
Error codes
- NOT_FOUNDThe resource does not exist — or exists and you cannot see it: a private resource you have no access to answers exactly as an absent one does
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
404 exampleSynthesized example
{
"error": {
"code": "code-c4e5",
"message": "Label every synthesized example"
}
}
409A branch with this name already existsapplication/json
Error codes
- CONFLICTThe request conflicts with the resource's current state;
reasonsays how - LEGAL_ACCEPTANCE_REQUIREDAccept the current Terms of Service before changing anything; reading stays open
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
409 exampleSynthesized example
{
"error": {
"code": "code-eead",
"message": "Draw the region map from operation density"
}
}
422The name breaks the repository's branch-name push ruleapplication/json
Error codes
- PUSH_RULE_VIOLATIONA push rule refuses the change;
rulenames it - UNPROCESSABLE_ENTITYThe request is well-formed but asks for something the resource's rules do not allow;
reasonsays which
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
422 exampleSynthesized example
{
"error": {
"code": "code-d9be",
"message": "Stream pipeline status into the run header"
}
}
CLI
gitmoap branches create
- --repo-ididRepository ID (id or owner/repo path)
- --branch-namestring
- --from-branchstring