API / get-origin-tree-via-api

API

Get Origin Tree via the API

Read a Git tree object with GET https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/git/trees/{sha}. Official reference: Origin API (OpenAPI OriginService_GetTree).

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.

Path sha accepts a tree SHA, commit SHA, branch, tag, or symbolic ref such as HEAD. Set query recursive=true (or 1) to walk the whole tree; omitting the parameter or passing any other value (including false and 0) lists immediate children only. Recursive listings truncate at 100,000 entries or 7 MiB and set truncated=true. Empty repositories return 409 Conflict.

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 Tree SHA, commit SHA, branch, tag, or HEAD

Query parameters

Param Required Meaning
recursive no true or 1 for a full walk; otherwise immediate children only
curl --request GET \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/git/trees/HEAD?recursive=true' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN'

Response

200 returns a GitTree: sha is the tree object hex SHA; tree is an array of entries; truncated is true when a recursive listing hit the entry-count or size cap (fetch subtrees non-recursively to continue).

Each entry has path (relative to the requested tree root), mode (octal string: 100644, 100755, 040000, 120000, 160000), type (blob, tree, or commit for a gitlink/submodule), sha, and size (blob byte length as a JSON number; unset for trees and gitlinks).

{
  "sha": "a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8",
  "tree": [
    {
      "path": "src/telemetry.ts",
      "mode": "100644",
      "type": "blob",
      "sha": "c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0",
      "size": 312
    }
  ],
  "truncated": false
}

Fetch a blob by SHA with Get Blob when you need file bytes. Base URL: https://api.cursor.com/v1/origin.