Codebranches
GET/repositories/{repo_id}/branches
List branches in a repository
list_branches
branch:read
A token needs thebranch:readscope: View branchesGranted bymcp_agent,mcp_agent_write,read_api,read_repository,write_api,write_repository.Every operation this scope unlocksSingle-resource
x-gitmoap-isolation: {"kind":"single_or_self_scoped"}
Paginated
Pass thenext_tokena page returns to get the next one.
The repository's branches in name order, each described as reading the branch describes it:
tip commit, distance from the default branch, protection, whether you may push, and the open
merge requests that propose it. Pages hold up to 100 branches, 20 by default; pass next_token
back unchanged, and a token this listing did not hand out is refused.
Parameters
Path
- repo_idRepositoryId (string · uuid)Repository ID
Query
- limitinteger · int32optionalPage size (1-100)
- next_tokenstringoptionalPagination cursor
Responses
200Branches listedapplication/json
itemsarray of RepositoryBranch
- The RepositoryBranch schema
- 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.
- next_tokenstring or nulloptional
200 exampleSynthesized example
{
"items": [
{
"ahead": 0,
"behind": 2,
"branch_name": "feature/region-legend",
"commit": {
"author_email": "lin@acme.example",
"author_name": "Lin Park",
"authored_at": "2026-10-12T20:30:04Z",
"commit_sha": "36d52b7cf302d585449e0186f04f64dfcd7a2cfe",
"committed_at": "2026-10-14T01:37:44Z",
"committer_email": "mara@acme.example",
"committer_name": "payments-api",
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"short_sha": "eaf1c1d1b8d54be51efd3661c106d32965b6592f",
"title": "Pin a page's payload to the build that rendered it"
},
"open_merge_requests": [],
"protected": false,
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"viewer_can_push": false
}
],
"next_token": "next-token-95b9"
}
400An unreadable pagination token, or a malformed repository IDapplication/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-7f7d",
"message": "Label every synthesized example"
}
}
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-d632",
"message": "Draw the region map from operation density"
}
}
403Forbidden — the caller's access level or token scope is insufficientapplication/json
Error codes
- 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-77e9",
"message": "Pin a page's payload to the build that rendered it"
}
}
404Not found — or found and private, which is masked as absentapplication/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-cc99",
"message": "Stream pipeline status into the run header"
}
}
CLI
gitmoap branches list
- --repo-ididRepository ID (id or owner/repo path)
- --limitnumberoptionalPage size (1-100)
- --next-tokenstringoptionalPagination cursor