API / add-origin-pull-request-labels-via-api

API

Add Origin Pull Request Labels via the API

Add existing repository labels to a pull request with POST https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/pulls/{pullNumber}/labels. Official reference: Origin API → Add Pull Request Labels (OpenAPI OriginService_AddPullRequestLabels).

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

Labels already on the pull stay assigned. Named labels must already exist in the repository; an unknown name or an unknown pull returns 404. The request must name between 1 and 100 labels; duplicate names are ignored. A pull request can hold at most 100 labels total, so a request that would exceed that limit returns FailedPrecondition (HTTP 400). Pull request number is a JSON string. A 404 never distinguishes a missing pull from one your installation cannot reach.

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

Path parameters

Param Required Meaning
ownerSlug yes Owning entity's unique slug
repoName yes Repo name, unique to the owner
pullNumber yes Pull request number within the repository (string on the wire)

Request body

Field Required Meaning
labels yes Label names to add. Maximum 100. Duplicates ignored
curl --request POST \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/pulls/17/labels' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "labels": [
    "bug"
  ]
}'

Response

200 returns labels for the names in the request (not the pull's full set). Each entry carries id, name, color, and description. Read the full assigned set with List Pull Request Labels.

{
  "labels": [
    {
      "id": "lbl_01k2ja2000e0080000000000m1",
      "name": "bug",
      "color": "d73a4a",
      "description": "Something isn't working"
    }
  ]
}

To replace the entire set in one call, use Set Pull Request Labels. Base URL: https://api.cursor.com/v1/origin.