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:
self: The API location of this pull requesthtml: The HTML location of this pull requestissue: The API location of this pull request's issuecomments: The API location of this pull request's issue commentsreview_comments: The API location of this pull request's review commentsreview_comment: The URL template to construct the API location for a review comment in this pull request's repositorycommits: The API location of this pull request's commitsstatuses: The API location of this pull request's commit statuses, which are the statuses of its head branchNote
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.
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.
accept (string)application/vnd.github+json is recommended.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.
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
200 - OK
304 - Not modified
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/pulls
Response schema (Status: 200):
Array of Pull Request Simple:
url: required, string, format: uriid: required, integer, format: int64node_id: required, stringhtml_url: required, string, format: uridiff_url: required, string, format: uripatch_url: required, string, format: uriissue_url: required, string, format: uricommits_url: required, string, format: urireview_comments_url: required, string, format: urireview_comment_url: required, stringcomments_url: required, string, format: uristatuses_url: required, string, format: urinumber: required, integerstate: required, stringlocked: required, booleantitle: required, stringuser: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringbody: required, string or nulllabels: required, array of objects:
id: required, integer, format: int64node_id: required, stringurl: required, stringname: required, stringdescription: required, stringcolor: required, stringdefault: required, booleanarchived_by: required, all of:
milestone: required, any of:
url: required, string, format: urihtml_url: required, string, format: urilabels_url: required, string, format: uriid: required, integernode_id: required, stringnumber: required, integerstate: required, string, enum: open, closed, default: "open"title: required, stringdescription: required, string or nullcreator: required, any of:
open_issues: required, integerclosed_issues: required, integercreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeclosed_at: required, string or null, format: date-timedue_on: required, string or null, format: date-timeactive_lock_reason: string or nullcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeclosed_at: required, string or null, format: date-timemerged_at: required, string or null, format: date-timeassignees: array of Simple User (see above)requested_reviewers: array of Simple User (see above)requested_teams: array of Team:
id: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerhead: required, object:
label: required, stringref: required, stringrepo: required, Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringlicense: required, any of:
key: required, stringname: required, stringurl: required, string or null, format: urispdx_id: required, string or nullnode_id: required, stringhtml_url: string, format: uriforks: required, integerpermissions: object:
admin: required, booleanpull: required, booleantriage: booleanpush: required, booleanmaintain: booleanowner: required, Simple User (see above)private: required, boolean, default: falsehtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: required, stringmirror_url: required, string or null, format: urihooks_url: required, string, format: urisvn_url: required, string, format: urihomepage: required, string or null, format: urilanguage: required, string or nullforks_count: required, integerstargazers_count: required, integerwatchers_count: required, integersize: required, integerdefault_branch: required, stringopen_issues_count: required, integeris_template: boolean, default: falsetopics: array of stringhas_issues: required, boolean, default: truehas_projects: required, boolean, default: truehas_wiki: required, boolean, default: truehas_pages: required, booleanhas_discussions: boolean, default: falsehas_pull_requests: boolean, default: truepull_request_creation_policy: string, enum: all, collaborators_onlyarchived: required, boolean, default: falsedisabled: required, booleanvisibility: string, default: "public"pushed_at: required, string or null, format: date-timecreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeallow_rebase_merge: boolean, default: truetemp_clone_token: stringallow_squash_merge: boolean, default: trueallow_auto_merge: boolean, default: falsedelete_branch_on_merge: boolean, default: falseallow_update_branch: boolean, default: falsesquash_merge_commit_title: string, enum: PR_TITLE, COMMIT_OR_PR_TITLEsquash_merge_commit_message: string, enum: PR_BODY, COMMIT_MESSAGES, BLANKmerge_commit_title: string, enum: PR_TITLE, MERGE_MESSAGEmerge_commit_message: string, enum: PR_BODY, PR_TITLE, BLANKallow_merge_commit: boolean, default: trueallow_forking: booleanweb_commit_signoff_required: boolean, default: falseopen_issues: required, integerwatchers: required, integerstarred_at: stringanonymous_access_enabled: booleancode_search_index_status: object:
lexical_search_ok: booleanlexical_commit_sha: stringsha: required, stringuser: required, any of:
base: required, object:
label: required, stringref: required, stringrepo: required, Repository (see above)sha: required, stringuser: required, any of:
_links: required, object:
comments: required, Link:
href: required, stringcommits: required, Link (see above)statuses: required, Link (see above)html: required, Link (see above)issue: required, Link (see above)review_comments: required, Link (see above)review_comment: required, Link (see above)self: required, Link (see above)author_association: required, string, enum: COLLABORATOR, CONTRIBUTOR, FIRST_TIMER, FIRST_TIME_CONTRIBUTOR, MANNEQUIN, MEMBER, NONE, OWNERauto_merge: required, Auto merge:
enabled_by: required, Simple User (see above)merge_method: required, string, enum: merge, squash, rebasecommit_title: required, stringcommit_message: required, stringstack: Pull Request Stack:
base: required, object:
ref: required, stringsha: required, stringsize: integerposition: integerid: integernumber: integerdraft: booleanPOST /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.
accept (string)application/vnd.github+json is recommended.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.
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.
201 - Created
403 - Forbidden
422 - Validation failed, or the endpoint has been spammed.
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):
url: required, string, format: uriid: required, integer, format: int64node_id: required, stringhtml_url: required, string, format: uridiff_url: required, string, format: uripatch_url: required, string, format: uriissue_url: required, string, format: uricommits_url: required, string, format: urireview_comments_url: required, string, format: urireview_comment_url: required, stringcomments_url: required, string, format: uristatuses_url: required, string, format: urinumber: required, integerstate: required, string, enum: open, closedlocked: required, booleantitle: required, stringuser: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringbody: required, string or nulllabels: required, array of objects:
id: required, integer, format: int64node_id: required, stringurl: required, stringname: required, stringdescription: required, string or nullcolor: required, stringdefault: required, booleanarchived_by: required, all of:
milestone: required, any of:
url: required, string, format: urihtml_url: required, string, format: urilabels_url: required, string, format: uriid: required, integernode_id: required, stringnumber: required, integerstate: required, string, enum: open, closed, default: "open"title: required, stringdescription: required, string or nullcreator: required, any of:
open_issues: required, integerclosed_issues: required, integercreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeclosed_at: required, string or null, format: date-timedue_on: required, string or null, format: date-timeactive_lock_reason: string or nullcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeclosed_at: required, string or null, format: date-timemerged_at: required, string or null, format: date-timeassignees: array of Simple User (see above)requested_reviewers: array of Simple User (see above)requested_teams: array of Team Simple:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerhead: required, object:
label: required, stringref: required, stringrepo: required, Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringlicense: required, any of:
key: required, stringname: required, stringurl: required, string or null, format: urispdx_id: required, string or nullnode_id: required, stringhtml_url: string, format: uriforks: required, integerpermissions: object:
admin: required, booleanpull: required, booleantriage: booleanpush: required, booleanmaintain: booleanowner: required, Simple User (see above)private: required, boolean, default: falsehtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: required, stringmirror_url: required, string or null, format: urihooks_url: required, string, format: urisvn_url: required, string, format: urihomepage: required, string or null, format: urilanguage: required, string or nullforks_count: required, integerstargazers_count: required, integerwatchers_count: required, integersize: required, integerdefault_branch: required, stringopen_issues_count: required, integeris_template: boolean, default: falsetopics: array of stringhas_issues: required, boolean, default: truehas_projects: required, boolean, default: truehas_wiki: required, boolean, default: truehas_pages: required, booleanhas_discussions: boolean, default: falsehas_pull_requests: boolean, default: truepull_request_creation_policy: string, enum: all, collaborators_onlyarchived: required, boolean, default: falsedisabled: required, booleanvisibility: string, default: "public"pushed_at: required, string or null, format: date-timecreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeallow_rebase_merge: boolean, default: truetemp_clone_token: stringallow_squash_merge: boolean, default: trueallow_auto_merge: boolean, default: falsedelete_branch_on_merge: boolean, default: falseallow_update_branch: boolean, default: falsesquash_merge_commit_title: string, enum: PR_TITLE, COMMIT_OR_PR_TITLEsquash_merge_commit_message: string, enum: PR_BODY, COMMIT_MESSAGES, BLANKmerge_commit_title: string, enum: PR_TITLE, MERGE_MESSAGEmerge_commit_message: string, enum: PR_BODY, PR_TITLE, BLANKallow_merge_commit: boolean, default: trueallow_forking: booleanweb_commit_signoff_required: boolean, default: falseopen_issues: required, integerwatchers: required, integerstarred_at: stringanonymous_access_enabled: booleancode_search_index_status: object:
lexical_search_ok: booleanlexical_commit_sha: stringsha: required, stringuser: required, Simple User (see above)base: required, object:
label: required, stringref: required, stringrepo: required, Repository (see above)sha: required, stringuser: required, Simple User (see above)_links: required, object:
comments: required, Link:
href: required, stringcommits: required, Link (see above)statuses: required, Link (see above)html: required, Link (see above)issue: required, Link (see above)review_comments: required, Link (see above)review_comment: required, Link (see above)self: required, Link (see above)author_association: required, string, enum: COLLABORATOR, CONTRIBUTOR, FIRST_TIMER, FIRST_TIME_CONTRIBUTOR, MANNEQUIN, MEMBER, NONE, OWNERauto_merge: required, Auto merge:
enabled_by: required, Simple User (see above)merge_method: required, string, enum: merge, squash, rebasecommit_title: required, stringcommit_message: required, stringstack: Pull Request Stack:
base: required, object:
ref: required, stringsha: required, stringsize: integerposition: integerid: integernumber: integerdraft: booleanmerged: required, booleanmergeable: required, boolean or nullrebaseable: boolean or nullmergeable_state: required, stringmerged_by: required, any of:
comments: required, integerreview_comments: required, integermaintainer_can_modify: required, booleancommits: required, integeradditions: required, integerdeletions: required, integerchanged_files: required, integerGET /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.
accept (string)application/vnd.github+json is recommended.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.
200 - Pass the appropriate media type to fetch diff and patch formats.
304 - Not modified
404 - Resource not found
406 - Unacceptable
422 - Validation failed, or the endpoint has been spammed.
500 - Internal Error
503 - Service unavailable
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.
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.
accept (string)application/vnd.github+json is recommended.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.
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.
200 - OK
403 - Forbidden
422 - Validation failed, or the endpoint has been spammed.
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.
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.
accept (string)application/vnd.github+json is recommended.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.
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
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/commits
Response schema (Status: 200):
Array of Commit:
url: required, string, format: urisha: required, stringnode_id: required, stringhtml_url: required, string, format: uricomments_url: required, string, format: uricommit: required, object:
url: required, string, format: uriauthor: required, any of:
name: stringemail: stringdate: string, format: date-timecommitter: required, any of:
message: required, stringcomment_count: required, integertree: required, object:
sha: required, stringurl: required, string, format: uriverification: Verification:
verified: required, booleanreason: required, stringpayload: required, string or nullsignature: required, string or nullverified_at: required, string or nullauthor: required, one of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringcommitter: required, one of:
parents: required, array of objects:
sha: required, stringurl: required, string, format: urihtml_url: string, format: uristats: object:
additions: integerdeletions: integertotal: integerfiles: array of Diff Entry:
sha: required, string or nullfilename: required, stringstatus: required, string, enum: added, removed, modified, renamed, copied, changed, unchangedadditions: required, integerdeletions: required, integerchanges: required, integerblob_url: required, string, format: uriraw_url: required, string, format: uricontents_url: required, string, format: uripatch: stringprevious_filename: stringGET /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.
accept (string)application/vnd.github+json is recommended.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.
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
200 - OK
422 - Validation failed, or the endpoint has been spammed.
500 - Internal Error
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/files
Response schema (Status: 200):
Array of Diff Entry:
sha: required, string or nullfilename: required, stringstatus: required, string, enum: added, removed, modified, renamed, copied, changed, unchangedadditions: required, integerdeletions: required, integerchanges: required, integerblob_url: required, string, format: uriraw_url: required, string, format: uricontents_url: required, string, format: uripatch: stringprevious_filename: stringGET /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.
accept (string)application/vnd.github+json is recommended.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.
204 - Response if pull request has been merged
404 - Not Found if pull request has not been merged
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/merge
Response schema (Status: 204):
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."
accept (string)application/vnd.github+json is recommended.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.
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
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.
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):
sha: required, stringmerged: required, booleanmessage: required, stringPUT /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.
accept (string)application/vnd.github+json is recommended.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.
commit_title (string)
Title for the automatic commit message. Only supported for direct merges.
commit_message (string)
Extra detail to append to automatic commit message. Only supported for direct merges.
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 for a direct merge. Only supported for direct merges.
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 uses a merge queue if one is configured for the target branch, or merges directly otherwise. If omitted, defaults to default.
Can be one of: default, direct_merge, merge_queue
bypass_rules (boolean)
Whether to bypass repository rules that the authenticated actor is permitted to bypass.
Default: false
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.
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):
status: required, string, enum: pending, merged, enqueued, faileddetails: required, any of:
message: required, stringuuid: required, stringmerge_method: required, string, enum: default, merge, squash, rebasemerge_action: required, string, enum: default, merge_queue, direct_mergeexpected_head_sha: required, stringbypass_rules: boolean, default: falsemessage: required, stringmessage: required, stringmessage: required, stringsha: required, stringRequest:
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):
status: required, string, enum: pending, merged, enqueued, faileddetails: required, any of:
message: required, stringuuid: required, stringmerge_method: required, string, enum: default, merge, squash, rebasemerge_action: required, string, enum: default, merge_queue, direct_mergeexpected_head_sha: required, stringbypass_rules: boolean, default: falsemessage: required, stringmessage: required, stringmessage: required, stringsha: required, stringRequest:
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):
status: required, string, enum: pending, merged, enqueued, faileddetails: required, any of:
message: required, stringuuid: required, stringmerge_method: required, string, enum: default, merge, squash, rebasemerge_action: required, string, enum: default, merge_queue, direct_mergeexpected_head_sha: required, stringbypass_rules: boolean, default: falsemessage: required, stringmessage: required, stringmessage: required, stringsha: required, stringRequest:
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):
status: required, string, enum: pending, merged, enqueued, faileddetails: required, any of:
message: required, stringuuid: required, stringmerge_method: required, string, enum: default, merge, squash, rebasemerge_action: required, string, enum: default, merge_queue, direct_mergeexpected_head_sha: required, stringbypass_rules: boolean, default: falsemessage: required, stringmessage: required, stringmessage: required, stringsha: required, stringGET /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.
accept (string)application/vnd.github+json is recommended.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.
200 - the current result of the asynchronous merge request
403 - Forbidden
404 - Resource not found
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.
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.
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.
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.
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.
accept (string)application/vnd.github+json is recommended.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.
expected_head_sha (string)202 - Accepted
403 - Forbidden
422 - Validation failed, or the endpoint has been spammed.
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):
message: stringurl: string