Codediffs
GET/repositories/{repo_id}/diff-file
Fetch a single file's diff on demand, force-expanded
get_diff_file
diff:read
A token needs thediff:readscope: View commit, merge-request, and branch-comparison diffsGranted bymcp_agent,mcp_agent_write,read_api,read_repository,write_api,write_repository.Every operation this scope unlocksCacheable · immutable SHA
x-gitmoap-cache: {"kind":"immutable_sha"}
One file's patch between two full commit SHAs, never collapsed — what to fetch for a file a
diff page collapsed. Choose the context lines; pass old_path for a renamed file. A patch over
100 KB is still withheld and marked truncated: read the file in windows instead.
Parameters
Path
- repo_idRepositoryId (string · uuid)Repository ID
Query
- basestringBase commit SHA (use the batch diff's diff.base_sha). Required.
- headstringHead commit SHA (use the batch diff's diff.head_sha). Required.
- pathstringFile path within the repository. Required.
- old_pathstringoptionalThe file's previous path, when the diff reports it renamed (its old_path). Without it a renamed file reads as the whole file added.
- contextintegeroptionalUnified context lines (0-100). Default: 3
Responses
200Single file diffapplication/json
- base_shaCommitHash (string)
fileDiffFileThe single file, with its patch inlined (
collapsedis alwaysfalse). A genuinely oversized patch still setspatch_truncated; the client then falls back toGET .../file-lines.- The DiffFile schema
- additionsinteger0–∞
- collapsedbooleanThe patch was intentionally withheld (generated or oversized) to save bytes but is fetchable in full on demand via
GET .../diff-file. Only ever set when patches were requested (include_patch=true). - deletionsinteger0–∞
- generatedbooleanDetected generated/lock/minified file. Always computed from the path, independent of
collapsed, so a client can badge or auto-fold it. - is_binaryboolean
- patch_truncatedbooleanThe patch exceeds the hard per-file size cap and is omitted. Unlike
collapsed, this file is not expandable in place — a client reads it piece-by-piece viaGET .../file-linesinstead. - pathstring
- statusDiffFileStatusaddedmodifieddeletedrenamedcopied
- collapse_reasonCollapseReasongeneratedlargeor nulloptionalWhy a file's patch body was withheld from a
DiffFile(seecollapsed). Distinct frompatch_truncated, which marks a patch too large to ever send; acollapsedfile's patch is fetchable on demand viaGET .../diff-file. - old_pathstring or nulloptional
- patchstring or nulloptional
- head_shaCommitHash (string)
200 exampleSynthesized example
{
"base_sha": "057079497f78de3168958db0605f47d270a471b9",
"file": {
"additions": 44,
"collapsed": false,
"deletions": 80,
"generated": false,
"is_binary": false,
"patch_truncated": false,
"path": "path-f344",
"status": "added",
"collapse_reason": "generated",
"old_path": "old-path-9202",
"patch": "patch-d653"
},
"head_sha": "cf43bb29d0377ab48094f3456cd1c10622601220"
}
400Missing or invalid base/head/pathapplication/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-dbb6",
"message": "Stream pipeline status into the run header"
}
}
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-6399",
"message": "Stream pipeline status into the run header"
}
}
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-cec4",
"message": "Label every synthesized example"
}
}
404Repository not found, or file unchanged between the refsapplication/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-a2d8",
"message": "Pin a page's payload to the build that rendered it"
}
}
CLI
gitmoap diffs get-diff-file
- --repo-ididRepository ID (id or owner/repo path)
- --basestringBase commit SHA (use the batch diff's diff.base_sha). Required.
- --contextnumberoptionalUnified context lines (0-100). Default: 3
- --headstringHead commit SHA (use the batch diff's diff.head_sha). Required.
- --old-pathstringoptionalThe file's previous path, when the diff reports it renamed (its old_path). Without it a renamed file reads as the whole file added.
- --pathstringFile path within the repository. Required.