API / update-origin-repo-via-api

API

Update an Origin Repo via the API

Change repository settings with PATCH https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}. Official reference: Origin API → Update Repo.

Origin is in Early Beta and subject to change. Authenticate with an installation access token or a Cursor user access token that carries repository:settings:write. Availability: Early Beta per the API overview.

Omitted fields stay unchanged. At least one settable field is required; a request that sets no field returns InvalidArgument (HTTP 400). Settings apply as independent groups in a fixed order: default branch, automatic head-branch deletion, visibility, then merge methods. The update is not atomic across groups. When a later group is rejected, earlier groups already applied stay applied — retry with the rejected group corrected. A concurrent change to the default branch returns 409 Conflict.

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

Path parameters

Param Required Meaning
ownerSlug yes Owning entity slug (or _ with repo ID form)
repoName yes Repo name unique to the owner (or repository ID when ownerSlug is _)

Request body

Field Required Meaning
defaultBranch no New default branch; must name an existing branch. Supported only on repositories that neither pull from nor push to an upstream source; otherwise FailedPrecondition (HTTP 400).
allowMergeCommit no Whether PRs can land as merge commits. Must be sent together with allowSquashMerge; at least one of the two must be true. Sending one without the other returns InvalidArgument (HTTP 400).
allowSquashMerge no Whether PRs can land as squash merges. Pair with allowMergeCommit as above.
deleteBranchOnMerge no Whether the head branch deletes automatically on merge. Supported only when pull requests live on this API; a repo that pulls from an upstream source returns FailedPrecondition (HTTP 400).
visibility no internal or private. Omit to leave visibility unchanged.
curl --request PATCH \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "defaultBranch": "main",
  "allowMergeCommit": false,
  "allowSquashMerge": true,
  "deleteBranchOnMerge": true,
  "visibility": "private"
}'

Response

The body returns the repository as of the last settings group applied: id, name, fullName, owner, defaultBranch, timestamps, cloneUrl, optional mirror, visibility, allowMergeCommit, allowSquashMerge, and deleteBranchOnMerge.

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 use installation tokens with repository:settings:write. Do not put a Cursor API key directly in the Origin Authorization header.

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