API / create-origin-pull-request-via-api

API

Create an Origin Pull Request via the API

Open a pull request from head into base with POST https://api.cursor.com/v1/origin/repos/{ownerSlug}/{repoName}/pulls. Official reference: Origin API → Create Pull Request (OpenAPI OriginService_CreatePullRequest). Changelog notes: September 12, 2026 (base must name an existing branch), August 28, 2026 (unrelated histories rejected), August 25, 2026 (title and body length caps).

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. Requesting :write also grants repository:pull_requests:read. Availability: Early Beta per the API overview.

Optional parentPullNumber stacks this change on another open or draft pull request in the same repository. Pull request number in the response is a JSON string (protobuf 64-bit encoding).

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

Request body

Field Required Meaning
title yes Pull request title; max 256 Unicode code points
head yes Source branch name; must resolve in the repo at call time
base yes Target branch name (main or refs/heads/main); must name an existing branch (not a commit SHA or tag)
body no Description; may be empty; max 65,536 Unicode code points
draft no true creates a draft; false or omitted creates open (ready for review)
parentPullNumber no Parent pull number when stacking on another open/draft change in the same repo

A base that is a commit SHA, a tag, or a missing branch returns InvalidArgument (HTTP 400). A head with no history in common with base also returns InvalidArgument (HTTP 400) and creates nothing.

curl --request POST \
  --url 'https://api.cursor.com/v1/origin/repos/OWNER_SLUG/REPO_NAME/pulls' \
  --header 'Authorization: Bearer YOUR_ORIGIN_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "title": "Add launch telemetry",
  "body": "Adds structured launch telemetry to the ignition path.",
  "head": "add-telemetry",
  "base": "main",
  "draft": false
}'

Response

200 returns the created PullRequest: id, number (string), state, draft, merged, title, body, head / base refs, author, timestamps, line stats, labels, and latest version.

{
  "id": "pr_01k2ja2000e0080000000000d4",
  "number": "17",
  "state": "open",
  "draft": false,
  "merged": false,
  "title": "Add launch telemetry",
  "body": "Adds structured launch telemetry to the ignition path.",
  "head": {
    "ref": "add-telemetry",
    "sha": "9a41f0c3d2b8e7f6a5c4d3e2f1b0a9c8d7e6f5a4"
  },
  "base": {
    "ref": "main",
    "sha": "3b1f9c2d8a7e6f5049c8b7a6d5e4f3a2b1c0d9e8"
  },
  "author": {
    "user": {
      "id": "user_01k2ja2000e0080000000000c3",
      "email": "jane@acme.dev"
    }
  },
  "createdAt": "2026-08-01T09:30:00Z",
  "updatedAt": "2026-08-02T14:45:00Z",
  "additions": 128,
  "deletions": 46,
  "changedFiles": 5,
  "labels": [
    {
      "id": "lbl_01k2ja2000e0080000000000m1",
      "name": "bug",
      "color": "d73a4a",
      "description": "Something isn't working"
    }
  ],
  "version": {
    "number": "3",
    "headSha": "9a41f0c3d2b8e7f6a5c4d3e2f1b0a9c8d7e6f5a4",
    "baseSha": "3b1f9c2d8a7e6f5049c8b7a6d5e4f3a2b1c0d9e8",
    "createdAt": "2026-08-01T09:30:00Z"
  }
}

Parse number as a string. Assign labels afterward with the pull-request label endpoints (repository:pull_requests:write). Base URL: https://api.cursor.com/v1/origin.