API / delete-origin-git-ref-via-api

API

Delete Origin Git Ref via the API

Delete a branch reference with DELETE https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/git/refs/{ref}. Official reference: Origin API and changelog (OpenAPI OriginService_DeleteGitRef; added 2026-09-19). The response body is empty.

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:write. Availability: Early Beta per the API overview.

Only branch references can be deleted: path ref is refs/heads/<branch> or heads/<branch>. A missing branch returns 404. The repository default branch, a branch protected by a deletion rule, and a repository whose contents are mirrored from another host each return FailedPrecondition (HTTP 400). Pull requests whose head is the deleted branch are closed, as after a pushed deletion. If the tip moves while the delete is in flight, the call returns FailedPrecondition (HTTP 400) or Aborted (HTTP 409 Conflict); retry to delete the new tip.

Cost: 5 points against the principal budget (ordinary write; changelog).

Path parameters

Param Required Meaning
ownerSlug yes Owning entity's unique slug
repoName yes Repo name, unique to the owner
ref yes Branch as refs/heads/<branch> or heads/<branch>
curl --request DELETE \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/git/refs/heads/feature/login' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN'

Response

Successful requests return 204 No Content with an empty body.

204 No Content

Confirm the branch is gone with Get Git Ref or List Matching Git Refs. Base URL: https://api.cursor.com/v1/origin.