API / get-origin-contents-via-api

API

Get Origin Contents via the API

Read a file or directory at a ref with GET https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/contents. Official reference: Origin API (OpenAPI OriginService_GetContents).

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.

Pass the path as the path query parameter (nested paths allowed). Omit path or leave it empty for the repository root directory. Pass ref as a commit SHA, branch, tag, or symbolic HEAD; omit it to use the repository default branch. File payloads larger than 1 MiB (decoded) return FailedPrecondition (HTTP 400); fetch larger files by cloning over Git HTTPS.

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

Query parameters

Param Required Meaning
path no Path relative to the repository root; empty requests the root directory
ref no Commit, branch, tag, or HEAD; empty uses the default branch
curl --request GET \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/contents?path=README.md&ref=HEAD' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN'

Response

200 returns a Content object. type is file or dir. For a file, encoding is typically base64 and content carries the base64 body. For a directory, entries lists immediate children (same shape, without nested directory expansion beyond one level). Every payload includes name, path, sha (blob or tree hex), and size as a JSON string for decoded byte length.

{
  "type": "file",
  "encoding": "base64",
  "size": "128",
  "name": "README.md",
  "path": "README.md",
  "sha": "9a41f0c3d2b8e7f6a5c4d3e2f1b0a9c8d7e6f5a4",
  "content": "IyBSb2NrZXQK"
}

Use Batch Get Contents when you need several exact paths in one call. Base URL: https://api.cursor.com/v1/origin.