Check if a pull request has been merged

octokit.pulls.checkIfMerged({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes

See also: GitHub Developer Guide documentation.

Create a pull request

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.

You can create a new pull request.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

octokit.pulls.create({
owner,
repo,
head,
base,
});

Parameters

namerequireddescription
owneryes
repoyes
titleno

The title of the new pull request.

headyes

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.

baseyes

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.

bodyno

The contents of the pull request.

maintainer_can_modifyno

Indicates whether maintainers can modify the pull request.

draftno

Indicates whether the pull request is a draft. See "Draft Pull Requests" in the GitHub Help documentation to learn more.

issueno

See also: GitHub Developer Guide documentation.

Create a reply for a review comment

Creates a reply to a review comment for a pull request. For the comment_id, provide the ID of the review comment you are replying to. This must be the ID of a top-level review comment, not a reply to that comment. Replies to replies are not supported.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

octokit.pulls.createReplyForReviewComment({
owner,
repo,
pull_number,
comment_id,
body,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
comment_idyes

comment_id parameter

bodyyes

The text of the review comment.

See also: GitHub Developer Guide documentation.

Create a review for a pull request

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

Pull request reviews created in the PENDING state do not include the submitted_at property in the response.

Note: To comment on a specific line in a file, you need to first determine the position of that line in the diff. The GitHub REST API v3 offers the application/vnd.github.v3.diff media type. To see a pull request diff, add this media type to the Accept header of a call to the single pull request endpoint.

The position value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.

octokit.pulls.createReview({
owner,
repo,
pull_number,
comments[].path,
comments[].body
})

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
commit_idno

The SHA of the commit that needs a review. Not using the latest commit SHA may render your review comment outdated if a subsequent commit modifies the line you specify as the position. Defaults to the most recent commit in the pull request when you do not specify a value.

bodyno

Required when using REQUEST_CHANGES or COMMENT for the event parameter. The body text of the pull request review.

eventno

The review action you want to perform. The review actions include: APPROVE, REQUEST_CHANGES, or COMMENT. By leaving this blank, you set the review action state to PENDING, which means you will need to submit the pull request review when you are ready.

commentsno

Use the following table to specify the location, destination, and contents of the draft review comment.

comments[].pathyes

The relative path to the file that necessitates a review comment.

comments[].positionno

The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note below.

comments[].bodyyes

Text of the review comment.

comments[].lineno
comments[].sideno
comments[].start_lineno
comments[].start_sideno

See also: GitHub Developer Guide documentation.

Create a review comment for a pull request

Creates a review comment in the pull request diff. To add a regular comment to a pull request timeline, see "Create an issue comment." We recommend creating a review comment using line, side, and optionally start_line and start_side if your comment applies to more than one line in the pull request diff.

You can still create a review comment using the position parameter. When you use position, the line, side, start_line, and start_side parameters are not required. For more information, see the comfort-fade preview notice.

Note: The position value equals the number of lines down from the first "@@" hunk header in the file you want to add a comment. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

octokit.pulls.createReviewComment({
owner,
repo,
pull_number,
body,
path,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
bodyyes

The text of the review comment.

commit_idno

The SHA of the commit needing a comment. Not using the latest commit SHA may render your comment outdated if a subsequent commit modifies the line you specify as the position.

pathyes

The relative path to the file that necessitates a comment.

positionno

Required without comfort-fade preview. The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note above.

sideno

Required with comfort-fade preview. In a split diff view, the side of the diff that the pull request's changes appear on. Can be LEFT or RIGHT. Use LEFT for deletions that appear in red. Use RIGHT for additions that appear in green or unchanged lines that appear in white and are shown for context. For a multi-line comment, side represents whether the last line of the comment range is a deletion or addition. For more information, see "Diff view options" in the GitHub Help documentation.

lineno

Required with comfort-fade preview. The line of the blob in the pull request diff that the comment applies to. For a multi-line comment, the last line of the range that your comment applies to.

start_lineno

Required when using multi-line comments. To create multi-line comments, you must use the comfort-fade preview header. The start_line is the first line in the pull request diff that your multi-line comment applies to. To learn more about multi-line comments, see "Commenting on a pull request" in the GitHub Help documentation.

start_sideno

Required when using multi-line comments. To create multi-line comments, you must use the comfort-fade preview header. The start_side is the starting side of the diff that the comment applies to. Can be LEFT or RIGHT. To learn more about multi-line comments, see "Commenting on a pull request" in the GitHub Help documentation. See side in this table for additional context.

in_reply_tono

See also: GitHub Developer Guide documentation.

Delete a pending review for a pull request

octokit.pulls.deletePendingReview({
owner,
repo,
pull_number,
review_id,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes

review_id parameter

See also: GitHub Developer Guide documentation.

Delete a review comment for a pull request

Deletes a review comment.

octokit.pulls.deleteReviewComment({
owner,
repo,
comment_id,
});

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes

comment_id parameter

See also: GitHub Developer Guide documentation.

Dismiss a review for a pull request

Note: To dismiss a pull request review on a protected branch, you must be a repository administrator or be included in the list of people or teams who can dismiss pull request reviews.

octokit.pulls.dismissReview({
owner,
repo,
pull_number,
review_id,
message,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes

review_id parameter

messageyes

The message for the pull request review dismissal

eventno

See also: GitHub Developer Guide documentation.

Get a pull request

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.

octokit.pulls.get({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes

See also: GitHub Developer Guide documentation.

Get a review for a pull request

octokit.pulls.getReview({
owner,
repo,
pull_number,
review_id,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes

review_id parameter

See also: GitHub Developer Guide documentation.

Get a review comment for a pull request

Provides details for a review comment.

octokit.pulls.getReviewComment({
owner,
repo,
comment_id,
});

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes

comment_id parameter

See also: GitHub Developer Guide documentation.

List pull requests

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.

octokit.pulls.list({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
stateno

Either open, closed, or all to filter by state.

headno

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.

baseno

Filter pulls by base branch name. Example: gh-pages.

sortno

What to sort results by. Can be either created, updated, popularity (comment count) or long-running (age, filtering by pulls updated in the last month).

directionno

The direction of the sort. Can be either asc or desc. Default: desc when sort is created or sort is not specified, otherwise asc.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List comments for a pull request review

List comments for a specific pull request review.

octokit.pulls.listCommentsForReview({
owner,
repo,
pull_number,
review_id,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes

review_id parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List commits on a pull request

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.

octokit.pulls.listCommits({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List pull requests files

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

octokit.pulls.listFiles({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List requested reviewers for a pull request

octokit.pulls.listRequestedReviewers({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List review comments on a pull request

Lists all review comments for a pull request. By default, review comments are in ascending order by ID.

octokit.pulls.listReviewComments({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
sortno

One of created (when the repository was starred) or updated (when it was last pushed to).

directionno

Can be either asc or desc. Ignored without sort parameter.

sinceno

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List review comments in a repository

Lists review comments for all pull requests in a repository. By default, review comments are in ascending order by ID.

octokit.pulls.listReviewCommentsForRepo({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
sortno

One of created (when the repository was starred) or updated (when it was last pushed to).

directionno

Can be either asc or desc. Ignored without sort parameter.

sinceno

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List reviews for a pull request

The list of reviews returns in chronological order.

octokit.pulls.listReviews({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

Merge a pull request

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

octokit.pulls.merge({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
commit_titleno

Title for the automatic commit message.

commit_messageno

Extra detail to append to automatic commit message.

shano

SHA that pull request head must match to allow merge.

merge_methodno

Merge method to use. Possible values are merge, squash or rebase. Default is merge.

See also: GitHub Developer Guide documentation.

Remove requested reviewers from a pull request

octokit.pulls.removeRequestedReviewers({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
reviewersno

An array of user logins that will be removed.

team_reviewersno

An array of team slugs that will be removed.

See also: GitHub Developer Guide documentation.

Request reviewers for a pull request

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

octokit.pulls.requestReviewers({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
reviewersno

An array of user logins that will be requested.

team_reviewersno

An array of team slugs that will be requested.

See also: GitHub Developer Guide documentation.

Submit a review for a pull request

octokit.pulls.submitReview({
owner,
repo,
pull_number,
review_id,
event,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes

review_id parameter

bodyno

The body text of the pull request review

eventyes

The review action you want to perform. The review actions include: APPROVE, REQUEST_CHANGES, or COMMENT. When you leave this blank, the API returns HTTP 422 (Unrecognizable entity) and sets the review action state to PENDING, which means you will need to re-submit the pull request review using a review action.

See also: GitHub Developer Guide documentation.

Update a pull request

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.

octokit.pulls.update({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
titleno

The title of the pull request.

bodyno

The contents of the pull request.

stateno

State of this Pull Request. Either open or closed.

baseno

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_modifyno

Indicates whether maintainers can modify the pull request.

See also: GitHub Developer Guide documentation.

Update a pull request branch

Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.

octokit.pulls.updateBranch({
owner,
repo,
pull_number,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
expected_head_shano

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.

See also: GitHub Developer Guide documentation.

Update a review for a pull request

Update the review summary comment with new text.

octokit.pulls.updateReview({
owner,
repo,
pull_number,
review_id,
body,
});

Parameters

namerequireddescription
owneryes
repoyes
pull_numberyes
review_idyes

review_id parameter

bodyyes

The body text of the pull request review.

See also: GitHub Developer Guide documentation.

Update a review comment for a pull request

Enables you to edit a review comment.

octokit.pulls.updateReviewComment({
owner,
repo,
comment_id,
body,
});

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes

comment_id parameter

bodyyes

The text of the reply to the review comment.

See also: GitHub Developer Guide documentation.