Codetree
GET/repositories/{repo_id}/tree
List tree entries in a repository at a given path and ref
list_tree
tree:read
A token needs thetree:readscope: Browse repository trees and blobsGranted bymcp_agent,mcp_agent_write,read_api,read_repository,write_api,write_repository.Every operation this scope unlocksCacheable · ref addressed
x-gitmoap-cache: {"kind":"ref_addressed"}
Single-resource
x-gitmoap-isolation: {"kind":"single_or_self_scoped"}
Conditional · 304
Declares304 Not Modified.Redirects · 302
Declares302 Found.
The files and folders in one directory at a branch, tag or commit — folders first, then files,
each group by name — a page at a time with the total count. A ref that names a branch or tag
may be answered with a redirect to the same request pinned to the commit it resolves to, so
every page reads one snapshot. Anyone who can read the repository's code may call it.
Parameters
Path
- repo_idRepositoryId (string · uuid)Repository ID
Query
- refstringoptionalGit ref (branch, tag, or commit SHA). Default: HEAD
- pathstringoptionalDirectory path within the repo. Default: root
- redirectbooleanoptional
falseanswers with the pinned URL and commit SHA in the body instead of a 302, for clients that cannot follow a redirect. Default: true - limitintegeroptionalEntries per page (max 100). Default: 100
- pageintegeroptionalPage number (0-based). Default: 0
Responses
200Tree entries listed. When the request would redirect, `?redirect=false` instead returns the pinned URL and commit SHAapplication/json
- has_moreboolean
itemsarray of TreeEntry
- The TreeEntry schema
- modestring
- namestring
- oidObjectId (string)The entry's git object id at this commit. For a file, it is the
blob_shaa blob read returns — so a client holding an edited copy can tell from a listing alone that the file changed underneath it. - pathstring
- typeTreeEntryTypeblobtree
- sizeinteger · int64 or nulloptional0–∞
- pageinteger0–∞
- total_countinteger0–∞
200 exampleSynthesized example
{
"has_more": false,
"items": [
{
"mode": "mode-443c",
"name": "payments-api",
"oid": "oid-82b9",
"path": "path-dbf1",
"type": "blob"
}
],
"page": 72,
"total_count": 2
}
302`ref` names a branch, tag or HEAD: redirect to the same request with `ref` pinned to the commit SHA it resolves to
No body.
304The ref has not moved since the caller's `If-None-Match`
No body.
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-2276",
"message": "Inline scalar newtypes but keep their brand"
}
}
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-9da1",
"message": "Pin a page's payload to the build that rendered it"
}
}
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-086c",
"message": "Draw the region map from operation density"
}
}
404Repository or tree 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-d632",
"message": "Pin a page's payload to the build that rendered it"
}
}
409The repository is empty: nothing has been pushed to it, so there is no tree to listapplication/json
Error codes
- CONFLICTThe request conflicts with the resource's current state;
reasonsays how - REPOSITORY_EMPTYThe repository has no branches or tags yet; there is nothing to read until something is pushed to 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.
409 exampleSynthesized example
{
"error": {
"code": "code-7f76",
"message": "Stream pipeline status into the run header"
}
}
CLI
gitmoap tree list-tree
- --repo-ididRepository ID (id or owner/repo path)
- --limitnumberoptionalEntries per page (max 100). Default: 100
- --pagenumberoptionalPage number (0-based). Default: 0
- --pathstringoptionalDirectory path within the repo. Default: root
- --redirectflagoptional`false` answers with the pinned URL and commit SHA in the body instead of a 302, for clients that cannot follow a redirect. Default: true
- --refstringoptionalGit ref (branch, tag, or commit SHA). Default: HEAD