API

Pull requests

Open, comment on, merge and close pull requests.

See Pull requests.

Every route below, with its parameters, request and response, errors and samples, is in the API reference.

RouteWhat it does
GET /v1/orgs/:orgId/repos/:name/pulls/:number/reviewInline review comments with their file and line, approvals, and how many approvals the pull request still needs.
POST /v1/orgs/:orgId/repos/:name/pulls/:number/review/commentsAdds a review comment: a new thread on a line of the diff (path, line, side), or a reply (inReplyTo).
POST /v1/orgs/:orgId/repos/:name/pulls/:number/approvalApproves the pull request's current revision, or withdraws your approval. Authors can't approve their own.
POST /v1/orgs/:orgId/repos/:name/pulls/:number/reopenCodeCommit can't reopen a closed pull request; a new one replaces it under the same number.
GET /v1/orgs/:orgId/repos/:name/pullsLists pull requests in one state, newest first. Listing open pull requests also settles any that were merged or closed outside the portal.
POST /v1/orgs/:orgId/repos/:name/pullsOpens a pull request that merges source into target.
GET /v1/orgs/:orgId/repos/:name/pulls/:numberA pull request with its commit range, the merge strategies available now, its comments, and codeowners: the owners each changed path needs an approval from (null without a CODEOWNERS file).
PATCH /v1/orgs/:orgId/repos/:name/pulls/:numberChanges a pull request's title, description, labels or assignees.
GET /v1/orgs/:orgId/repos/:name/pulls/:number/commitsCommits the pull request adds to its target.
GET /v1/orgs/:orgId/repos/:name/pulls/:number/filesChanged files with unified diffs.
POST /v1/orgs/:orgId/repos/:name/pulls/:number/mergeMerges the pull request. Pass sourceCommitId (the head you reviewed) to fail if the branch has moved since. Into a ruled branch it needs the rule's approvals and code owner reviews (409 otherwise) and a clean secret scan (422); bypass: true merges without the reviews for people on the bypass list, audited.
POST /v1/orgs/:orgId/repos/:name/pulls/:number/closeCloses the pull request without merging.
POST /v1/orgs/:orgId/repos/:name/pulls/:number/commentsAdds a comment to a pull request.