API / list-origin-repo-branches-via-api

API

List Origin Repo Branches via the API

List a repository's branches and tip commits with GET https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/branches. Official reference: Origin API → List Branches.

Origin is in Early Beta and subject to change. Authenticate with an installation access token or a Cursor user access token. Required scope: repository:contents:read. Availability: Early Beta per the API overview.

Branches return in ascending name order. You can also address by stable repository ID: send _ as the owner slug and the repository ID as the name (GET /v1/origin/repos/_/REPO_ID/branches).

Cost: 1 point against the principal budget (most reads).

Path parameters

Param Required Meaning
ownerSlug yes Owning entity slug, or _ when using the repository ID form
repoName yes Repo name unique to the owner, or the repository ID when ownerSlug is _

Query parameters

Param Required Meaning
pageSize no Max branches to return. Defaults to 30 when unset or 0. Values above 100 are clamped to 100.
pageToken no Opaque cursor from a previous response's nextPageToken. Empty for the first page. When a token is supplied, pageSize on the follow-up request is ignored.
curl --request GET \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/branches' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN'

With pagination:

curl --request GET \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/branches?pageSize=50' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN'

Response

Field Meaning
branches Paginated branch records
branches[].name Branch name
branches[].commit.sha Full hex SHA of the commit at the tip of the branch
nextPageToken Opaque cursor for the next page; empty when there are no more pages
{
  "branches": [
    {
      "name": "main",
      "commit": {
        "sha": "9a41f0c3d2b8e7f6a5c4d3e2f1b0a9c8d7e6f5a4"
      }
    }
  ]
}

Treat page tokens as opaque. Restart pagination when filters change.

For interactive or scripted user calls, prefer origin api after origin auth login (or CURSOR_API_KEY) so the CLI exchanges a personal user API key for a short-lived user access token. App integrations should mint installation tokens just in time. Do not put a Cursor API key directly in the Origin Authorization header.

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