REST API endpoints for pull requests

Use the REST API to interact with pull requests.

About pull requests

You can list, view, edit, create, and merge pull requests using the REST API. For information about how to interact with comments on a pull request, see REST API endpoints for issue comments.

Pull requests are a type of issue. Any actions that are available in both pull requests and issues, like managing assignees, labels, and milestones, are handled by the REST API to manage issues. To perform these actions on pull requests, you must use the issues API endpoints (for example, /repos/{owner}/{repo}/issues/{issue_number}), not the pull requests endpoints. For more information, see REST API endpoints for issues.

Pull requests have these possible link relations:

Note

Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.

List pull requests

GET /repos/{owner}/{repo}/pulls

Lists pull requests in a specified repository.
Draft pull requests are available in public repositories with GitHub
Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing
plans, and in public and private repositories with GitHub Team and GitHub Enterprise
Cloud. For more information, see GitHub's products
in the GitHub Help documentation.
This endpoint supports the following custom media types. For more information, see "Media types."

application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls

Response schema (Status: 200):

Array of Pull Request Simple:

Create a pull request

POST /repos/{owner}/{repo}/pulls

Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "Rate limits for the API" and "Best practices for using the REST API."
This endpoint supports the following custom media types. For more information, see "Media types."

application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/pulls \
  -d '{
  "title": "Amazing new feature",
  "body": "Please pull these awesome changes in!",
  "head": "octocat:new-feature",
  "base": "master"
}'

Response schema (Status: 201):

Get a pull request

GET /repos/{owner}/{repo}/pulls/{pull_number}

Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
Lists details of a pull request by providing its number.
When you get, create, or edit a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the mergeable key. For more information, see "Checking mergeability of pull requests".
The value of the mergeable attribute can be true, false, or null. If the value is null, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-null value for the mergeable attribute in the response. If mergeable is true, then merge_commit_sha will be the SHA of the test merge commit.
The value of the merge_commit_sha attribute changes depending on the state of the pull request. Before merging a pull request, the merge_commit_sha attribute holds the SHA of the test merge commit. After merging a pull request, the merge_commit_sha attribute changes depending on how you merged the pull request:

If merged as a merge commit, merge_commit_sha represents the SHA of the merge commit.
If merged via a squash, merge_commit_sha represents the SHA of the squashed commit on the base branch.
If rebased, merge_commit_sha represents the commit that the base branch was updated to.

Pass the appropriate media type to fetch diff and patch formats.
This endpoint supports the following custom media types. For more information, see "Media types."

application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.
application/vnd.github.diff: For more information, see "git-diff" in the Git documentation. If a diff is corrupt, contact us through the GitHub Support portal. Include the repository name and pull request ID in your message.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER

Response schema (Status: 200):

Same response schema as Create a pull request.

Update a pull request

PATCH /repos/{owner}/{repo}/pulls/{pull_number}

Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
This endpoint supports the following custom media types. For more information, see "Media types."

application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PATCH \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER \
  -d '{
  "title": "new title",
  "body": "updated body",
  "state": "open",
  "base": "master"
}'

Response schema (Status: 200):

Same response schema as Create a pull request.

List commits on a pull request

GET /repos/{owner}/{repo}/pulls/{pull_number}/commits

Lists a maximum of 250 commits for a pull request. To receive a complete
commit list for pull requests with more than 250 commits, use the List commits
endpoint.
This endpoint supports the following custom media types. For more information, see "Media types."

application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/commits

Response schema (Status: 200):

Array of Commit:

List pull requests files

GET /repos/{owner}/{repo}/pulls/{pull_number}/files

Lists the files in a specified pull request.
Note

Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default.

This endpoint supports the following custom media types. For more information, see "Media types."

application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/files

Response schema (Status: 200):

Array of Diff Entry:

Check if a pull request has been merged

GET /repos/{owner}/{repo}/pulls/{pull_number}/merge

Checks if a pull request has been merged into the base branch. The HTTP status of the response indicates whether or not the pull request has been merged; the response body is empty.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge

Response schema (Status: 204):

Merge a pull request

PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge

Note

We recommend using the asynchronous merge API instead. This endpoint does not support stacked pull requests or merging with a merge queue.

Merges a pull request into the base branch.
This endpoint triggers notifications.
Creating content too quickly using this endpoint may result in secondary rate limiting.
For more information, see "Rate limits for the API" and "Best practices for using the REST API."

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge \
  -d '{
  "commit_title": "Expand enum",
  "commit_message": "Add a new value to the merge_method enum"
}'

Response schema (Status: 200):

Merge a pull request asynchronously

PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge-async

Merges a pull request into the base branch in the background or adds it to a merge queue. Background processing allows certain types of errors to be retried and reduces the risk of timeouts for complex merges.
This is the required API for merging stacked pull requests. For a stacked pull request, the operation includes all open downstack pull requests.
A new asynchronous merge request returns a 202 response with a UUID that can be used to fetch the result of the merge. If another asynchronous merge request is already pending for this pull request, a 409 response returns that request's UUID and merge options instead.
If the pull request is already merged or already in a merge queue, a 200 response is returned immediately. A merged result includes the merge commit OID. An enqueued result means the pull request was added to the merge queue, not that it has merged.
If the pull request cannot be merged (e.g. because it is closed, or still a draft) this result will be returned immediately with a 400 response status. Branch protection rules and repository rules are not run at this stage, only basic pull request state checks are performed.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Direct merge example 1: Status Code 200

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async \
  -d '{
  "commit_title": "Fix race condition",
  "commit_message": "Avoids a race by trying to read the file and handling the exception if it does not exist.",
  "sha": "6358cd125586d9def8c3e5943f23506202da81cc",
  "merge_method": "squash",
  "merge_action": "direct_merge"
}'

Response schema (Status: 200):

Merge queue example 2: Status Code 200

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async \
  -d '{
  "sha": "6358cd125586d9def8c3e5943f23506202da81cc",
  "merge_action": "merge_queue"
}'

Response schema (Status: 200):

Direct merge example 3: Status Code 202

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async \
  -d '{
  "commit_title": "Fix race condition",
  "commit_message": "Avoids a race by trying to read the file and handling the exception if it does not exist.",
  "sha": "6358cd125586d9def8c3e5943f23506202da81cc",
  "merge_method": "squash",
  "merge_action": "direct_merge"
}'

Response schema (Status: 202):

Merge queue example 4: Status Code 202

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async \
  -d '{
  "sha": "6358cd125586d9def8c3e5943f23506202da81cc",
  "merge_action": "merge_queue"
}'

Response schema (Status: 202):

Get the result of an asynchronous merge

GET /repos/{owner}/{repo}/pulls/{pull_number}/merge-async/{uuid}

Fetches the current result of an asynchronous merge request, identified by the UUID that was returned when the merge was requested.
While the request's status is pending, the response includes the UUID, merge method, merge action, and expected head SHA of the request. Once the asynchronous request completes, its status is one of:

merged: The pull request was merged into the base branch. The response includes the merge commit OID.
enqueued: The pull request was added to a merge queue.
failed: The request failed. The response includes a message describing the failure.

An enqueued result is final for the merge queue requests and does not mean the pull request has merged. This result does not change when the merge queue later merges the pull request. To get the eventual merge status, check if a pull request has been merged.
The result of an asynchronous merge request is retained for 24 hours after its most recent update. After this window the request expires and this endpoint returns a 404 response for its UUID.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example 1: Status Code 200

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async/UUID

Response schema (Status: 200):

Same response schema as Merge a pull request asynchronously.

Example 2: Status Code 200

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async/UUID

Response schema (Status: 200):

Same response schema as Merge a pull request asynchronously.

Example 3: Status Code 200

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async/UUID

Response schema (Status: 200):

Same response schema as Merge a pull request asynchronously.

Example 4: Status Code 200

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge-async/UUID

Response schema (Status: 200):

Same response schema as Merge a pull request asynchronously.

Update a pull request branch

PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch

Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.
Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/update-branch \
  -d '{
  "expected_head_sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
}'

Response schema (Status: 202):