
Get Origin Git Ref via the API
Resolve one Git reference by name with GET https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/git/ref/{ref}. Official reference: Origin API (OpenAPI OriginService_GetGitRef). Note the singular path segment git/ref.
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.
ref is typically heads/<branch> or tags/<tag> (with or without a leading refs/), or the symbolic HEAD. Matching is exact on the full ref name. 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 |
ref |
yes | Reference name; HEAD returns ref: "HEAD" with the tip commit |
curl --request GET \
--url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/git/ref/heads/main' \
--header 'Authorization: Bearer YOUR_ORIGIN_TOKEN'
Response
200 returns a GitRef: ref is the full name (e.g. refs/heads/main), and object is the unpeeled target with sha and type (commit, tree, blob, or tag). For annotated tags, object.type is tag and object.sha is the tag object SHA.
{
"ref": "refs/heads/main",
"object": {
"sha": "9a41f0c3d2b8e7f6a5c4d3e2f1b0a9c8d7e6f5a4",
"type": "commit"
}
}
For a prefix match across many refs, use List Matching Git Refs. Base URL: https://api.cursor.com/v1/origin.