API / list-origin-commit-files-via-api

API

List Origin Commit Files via the API

Page the files changed by a commit with GET https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/commits/{sha}/files. Official reference: Origin API → Commits / List Commit Files (OpenAPI OriginService_ListCommitFiles).

Origin is in Early Beta and subject to change. Authenticate with an installation access token (oit_…) or a user access token that carries repository:contents:read. Availability: Early Beta per the API overview.

The path sha accepts a SHA, branch, tag, or symbolic ref such as HEAD. Default page size is 30; values above 100 clamp to 100. A supplied pageToken fixes the resolved commit, page size, and file cursor, so sha and pageSize on a follow-up request must match the token.

Cost: 1 point against the principal budget (ordinary read).

Path parameters

Param Required Meaning
ownerSlug yes Owning entity's unique slug
repoName yes Repo name, unique to the owner
sha yes SHA, branch, tag, or HEAD of the commit whose files to list

Query parameters

Param Required Meaning
pageSize no Max changed files to return (default 30, max 100)
pageToken no Opaque cursor from a previous nextPageToken
curl --request GET \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/commits/9a41f0c3d2b8e7f6a5c4d3e2f1b0a9c8d7e6f5a4/files?pageSize=30' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN'

Response

The body carries files and an optional nextPageToken (empty when no more files). Each file includes filename, status (added, removed, modified, renamed, or copied), additions, deletions, changes (additions + deletions), optional patch (empty for binary files), and optional previousFilename when status is renamed or copied.

Example shape from the OpenAPI:

{
  "files": [
    {
      "filename": "src/telemetry.ts",
      "status": "modified",
      "additions": 6,
      "deletions": 3,
      "changes": 9,
      "patch": "@@ -12,6 +12,9 @@\n import { ignite } from \"./ignition\";\n+import { emitLaunchTelemetry } from \"./telemetry\";\n"
    }
  ]
}

Resolve the commit with Get Commit for aggregate stats, then page file-level patches here. Treat page tokens as opaque; restart pagination if the commit or page size changes.

Base URL: https://api.cursor.com/v1/origin.