Codetree
GET/repositories/{repo_id}/blob
Get a blob (file content) from a repository at a given path and ref
get_blob
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 unlocksMetered egress · in band body
x-gitmoap-egress: {"kind":"metered","arg":"in_band_body"}
Cacheable · ref addressed
x-gitmoap-cache: {"kind":"ref_addressed"}
Conditional · 304
Declares304 Not Modified.Redirects · 302
Declares302 Found.
One file's content at a branch, tag or commit, with its size, mode, object id and the commit the ref resolved to. Text comes as UTF-8, marked lossy where it is not valid UTF-8, and binary content as base64; a file over 1 MiB is refused. 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
- pathstringFile path within the repo (required)
- 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
Responses
200Blob content. When the request would redirect, `?redirect=false` instead returns the pinned URL and commit SHAapplication/json
- blob_shaObjectId (string)The file's git object id — what a commit that edits this file sends back as
expected_blob_sha. - commit_shaCommitHash (string)The commit the requested ref resolved to.
- contentstring
- encodingBlobEncodingutf8base64
- lossyboolean
truewhen the file is text but not valid UTF-8, andcontentshows replacement characters where its bytes could not be decoded. Writing such content back would change the file. - modeFileMode100644100755120000160000The file's mode at that commit. A symbolic link's content is its target, not a file's text.
- pathstring
- sizeinteger · int640–∞
- truncatedboolean
200 exampleSynthesized example
{
"blob_sha": "8c57183b76023d068396b04d5e3947d562d6e093",
"commit_sha": "b0235ebc8223e5ad4ab0d15173074363f88ada3d",
"content": "content-9ede",
"encoding": "utf8",
"lossy": false,
"mode": "100644",
"path": "path-7736",
"size": 1,
"truncated": false
}
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 request or file too largeapplication/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-faae",
"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-f816",
"message": "Inline scalar newtypes but keep their brand"
}
}
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-a602",
"message": "Label every synthesized example"
}
}
404Repository or file 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-822d",
"message": "Stream pipeline status into the run header"
}
}
409The repository is empty: nothing has been pushed to it, so there is no file to readapplication/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-b198",
"message": "Pin a page's payload to the build that rendered it"
}
}
CLI
gitmoap tree get-blob
- --repo-ididRepository ID (id or owner/repo path)
- --pathstringFile path within the repo (required)
- --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