
Batch Get Origin Contents via the API
Fetch several exact paths at one ref with POST https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/contents:batchGet. Official reference: Origin API → Batch Get Contents (OpenAPI OriginService_BatchGetContents).
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 list travels in the JSON body, so the method is POST. Paths are matched exactly — no globs or patterns — and at most 20 may be requested; duplicates are removed. An empty string in paths requests the repository root directory. A single file larger than the Get Contents 1 MiB cap fails the entire batch with FailedPrecondition (HTTP 400).
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 |
Request body
| Field | Required | Meaning |
|---|---|---|
paths |
yes | Exact repository-relative paths (≤20; duplicates removed) |
ref |
no | Commit, branch, tag, or HEAD; empty uses the default branch |
curl --request POST \
--url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/contents:batchGet' \
--header 'Authorization: Bearer YOUR_ORIGIN_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"paths": [
"README.md",
"src/main.ts",
"docs"
],
"ref": "HEAD"
}'
Response
200 returns results (one entry per unique requested path, first-seen order) and resolvedCommitSha. Each result echoes path, sets found, and when found includes content in the same Content shape as Get Contents (files as base64, directories as immediate entries, symlinks as files). When found is false, content is unset.
{
"results": [
{
"path": "README.md",
"found": true,
"content": {
"type": "file",
"encoding": "base64",
"size": "128",
"name": "README.md",
"path": "README.md",
"sha": "9a41f0c3d2b8e7f6a5c4d3e2f1b0a9c8d7e6f5a4",
"content": "IyBSb2NrZXQK"
}
},
{
"path": "missing.txt",
"found": false
}
],
"resolvedCommitSha": "3b1f9c2d8a7e6f5049c8b7a6d5e4f3a2b1c0d9e8"
}
Base URL: https://api.cursor.com/v1/origin.