| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Use the REST API to interact with 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:
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."
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Name, Type, Description |
|---|
state string Either open, closed, or all to filter by state. Default: open Can be one of: open, closed, all |
head string Filter pulls by head user or head organization and branch name in the format of user:ref-name or organization:ref-name. For example: github:new-script-format or octocat:test-branch. |
base string Filter pulls by base branch name. Example: gh-pages. |
sort string What to sort results by. popularity will sort by the number of comments. long-running will sort by date created and will limit the results to pull requests that have been open for more than a month and have had activity within the past month. Default: created Can be one of: created, updated, popularity, long-running |
direction string The direction of the sort. Default: desc when sort is created or sort is not specified, otherwise asc. Can be one of: asc, desc |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: 30 |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: 1 |
| Status code | Description |
|---|---|
| 200 | OK |
| 304 | Not modified |
| 422 | Validation failed, or the endpoint has been spammed. |
Response
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."
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Name, Type, Description |
|---|
title string The title of the new pull request. Required unless issue is specified. |
head string Required The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch. |
head_repo string The name of the repository where the changes in the pull request were made. This field is required for cross-repository pull requests if both repositories are owned by the same organization. |
base string Required The name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository. |
body string The contents of the pull request. |
maintainer_can_modify boolean Indicates whether maintainers can modify the pull request. |
draft boolean Indicates whether the pull request is a draft. See "Draft Pull Requests" in the GitHub Help documentation to learn more. |
issue integer An issue in the repository to convert to a pull request. The issue title, body, and comments will become the title, body, and comments on the new pull request. Required unless title is specified. |
| Status code | Description |
|---|---|
| 201 | Created |
| 403 | Forbidden |
| 422 | Validation failed, or the endpoint has been spammed. |
Response
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:
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."
This endpoint works with the following fine-grained token types:
The fine-grained token must have at least one of the following permission sets:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Status code | Description |
|---|---|
| 200 | Pass the appropriate media type to fetch diff and patch formats. |
| 304 | Not modified |
| 404 | Resource not found |
| 406 | Unacceptable |
| 500 | Internal Error |
| 503 | Service unavailable |
Pass the appropriate media type to fetch diff and patch formats.
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."
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Name, Type, Description |
|---|
title string The title of the pull request. |
body string The contents of the pull request. |
state string State of this Pull Request. Either open or closed. Can be one of: open, closed |
base string The name of the branch you want your changes pulled into. This should be an existing branch on the current repository. You cannot update the base branch on a pull request to point to another repository. |
maintainer_can_modify boolean Indicates whether maintainers can modify the pull request. |
| Status code | Description |
|---|---|
| 200 | OK |
| 403 | Forbidden |
| 422 | Validation failed, or the endpoint has been spammed. |
Response
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."
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Name, Type, Description |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: 30 |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: 1 |
| Status code | Description |
|---|---|
| 200 | OK |
Response
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."
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Name, Type, Description |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: 30 |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: 1 |
| Status code | Description |
|---|---|
| 200 | OK |
| 422 | Validation failed, or the endpoint has been spammed. |
| 500 | Internal Error |
| 503 | Service unavailable |
Response
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Status code | Description |
|---|---|
| 204 | Response if pull request has been merged |
| 404 | Not Found if pull request has not been merged |
Response if pull request has been merged
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."
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Name, Type, Description |
|---|
commit_title string Title for the automatic commit message. |
commit_message string Extra detail to append to automatic commit message. |
sha string SHA that pull request head must match to allow merge. |
merge_method string The merge method to use. Can be one of: merge, squash, rebase |
| Status code | Description |
|---|---|
| 200 | if merge was successful |
| 403 | Forbidden |
| 404 | Resource not found |
| 405 | Method Not Allowed if merge cannot be performed |
| 409 | Conflict if sha was provided and pull request head did not match |
| 422 | Validation failed, or the endpoint has been spammed. |
if merge was successful
Merges a pull request into the base branch in the background. Merging in this way allows certain types of errors to be retried, and avoids the risk of timeouts for particularly complex merges.
This is the required method for merging stacked PRs, but also supports unstacked PRs. When using this endpoint to merge a stacked pull request, all pull requests in the stack up to and including the requested PR will be merged into the base branch.
The response includes a UUID that can be used to fetch the result of the merge. If another asynchronous merge request has already been made for this pull request, the UUID of that request will be returned instead with a 409 response status to indicate that the merge options may be different from those that were requested. If there isn't an existing asynchronous merge request, a 202 response status is used.
If the pull request is already merged, the merge commit OID will be returned immediately with a 200 status.
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Name, Type, Description |
|---|
commit_title string Title for the automatic commit message. |
commit_message string Extra detail to append to automatic commit message. |
sha string SHA that pull request head must match to allow merge. If not provided, the current head of the PR at the time of the request will be used; if the PR is pushed in between the merge being requested and being executed, the merge will be cancelled. |
merge_method string The merge method to use. Can be one of: merge, squash, rebase |
merge_action string The action that will be taken to merge the pull request. direct_merge merges the pull request directly without using a merge queue; merge_queue adds the pull request to a merge queue; default selects the most appropriate option. Can be one of: default, direct_merge, merge_queue |
| Status code | Description |
|---|---|
| 200 | if the pull request was already merged, or is already in a merge queue |
| 202 | if the merge request was accepted and will run in the background |
| 400 | if the pull request is not ready to be merged, e.g. because it is closed |
| 403 | Forbidden |
| 404 | Resource not found |
| 409 | if there is an existing merge request already enqueued for this pull request |
| 422 | Validation failed, or the endpoint has been spammed. |
Already merged
Fetches the current result of an asynchronous merge request, identified by the UUID that was returned when the merge was requested.
While the merge is still queued, the response includes the UUID, merge method, and expected head SHA of the request. Once the merge has completed, the response reports whether it was merged, including the merge commit OID on success or a message describing why it could not be merged on failure.
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
uuid string Required The UUID of the asynchronous merge request, as returned when the merge was requested. |
| Status code | Description |
|---|---|
| 200 | the current result of the asynchronous merge request |
| 403 | Forbidden |
| 404 | Resource not found |
Still queued
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
pull_number integer Required The number that identifies the pull request. |
| Name, Type, Description |
|---|
expected_head_sha string The expected SHA of the pull request's HEAD ref. This is the most recent commit on the pull request's branch. If the expected SHA does not match the pull request's HEAD, you will receive a 422 Unprocessable Entity status. You can use the "List commits" endpoint to find the most recent commit SHA. Default: SHA of the pull request's current HEAD ref. |
| Status code | Description |
|---|---|
| 202 | Accepted |
| 403 | Forbidden |
| 422 | Validation failed, or the endpoint has been spammed. |
Response
| Back | FazBrowse Home | New Git URL |