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](https://docs.github.com/[email protected]/rest/reference/issues#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](https://docs.github.com/[email protected]/rest/reference/pulls#create-a-review-comment-for-a-pull-request-preview-notices). **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](https://docs.github.com/en/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/[email protected]/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/[email protected]/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details.
/repos/{owner}/{repo}/pulls/{pull_number}/comments- Source
github-v3-rest.json- Revision
f5f067c1e6f6- Active snapshot
85e53e3d0d65
Request
Path Parameters
- owner stringrequired
- repo stringrequired
- pull_number integerrequired
Body Params
requiredThe text of the review comment.
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`.
The ID of the review comment to reply to. To find the ID of a review comment with ["List review comments on a pull request"](#list-review-comments-on-a-pull-request). When specified, all parameters other than `body` in the request body are ignored.
Example: 2
**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.
The relative path to the file that necessitates a comment.
**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.
**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](https://docs.github.com/en/articles/about-comparing-branches-in-pull-requests#diff-view-options)" in the GitHub Help documentation.
**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](https://docs.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)" in the GitHub Help documentation.
**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](https://docs.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)" in the GitHub Help documentation. See `side` in this table for additional context.
Responses
Response
Headers
Example: https://api.github.com/repos/octocat/Hello-World/pulls/comments/1
_links objectrequired
html objectrequired
Example: https://github.com/octocat/Hello-World/pull/1#discussion-diff-1
pull_request objectrequired
Example: https://api.github.com/repos/octocat/Hello-World/pulls/1
self objectrequired
Example: https://api.github.com/repos/octocat/Hello-World/pulls/comments/1
How the author is associated with the repository.
Example: OWNER
The text of the comment.
Example: We should probably include a check for null values here.
Example: "<p>comment body</p>"
Example: "comment body"
The SHA of the commit to which the comment applies.
Example: 6dcb09b5b57875f334f61aebed695e2e4193db5e
Example: 2011-04-14T16:00:49Z
The diff of the line that the comment refers to.
Example: @@ -16,33 +16,40 @@ public class Connection : IConnection...
HTML URL for the pull request review comment.
Example: https://github.com/octocat/Hello-World/pull/1#discussion-diff-1
The ID of the pull request review comment.
Example: 1
The comment ID to reply to.
Example: 8
The line of the blob to which the comment applies. The last line of the range for a multi-line comment
Example: 2
The node ID of the pull request review comment.
Example: MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDEw
The SHA of the original commit to which the comment applies.
Example: 9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840
The line of the blob to which the comment applies. The last line of the range for a multi-line comment
Example: 2
The index of the original line in the diff to which the comment applies.
Example: 4
The first line of the range for a multi-line comment.
Example: 2
The relative path of the file to which the comment applies.
Example: config/database.yaml
The line index in the diff to which the comment applies.
Example: 1
The ID of the pull request review to which the comment belongs.
Example: 42
URL for the pull request that the review comment belongs to.
Example: https://api.github.com/repos/octocat/Hello-World/pulls/1
reactions Reaction Rollup objectoptional
The side of the diff to which the comment applies. The side of the last line of the range for a multi-line comment
The first line of the range for a multi-line comment.
Example: 2
The side of the first line of the range for a multi-line comment.
Example: 2011-04-14T16:00:49Z
URL for the pull request review comment
Example: https://api.github.com/repos/octocat/Hello-World/pulls/comments/1
user Simple User objectrequiredSimple User
Simple User
Example: https://github.com/images/error/octocat_happy.gif
Example: https://api.github.com/users/octocat/events{/privacy}
Example: https://api.github.com/users/octocat/followers
Example: https://api.github.com/users/octocat/following{/other_user}
Example: https://api.github.com/users/octocat/gists{/gist_id}
Example: 41d064eb2195891e12d0413f63227ea7
Example: https://github.com/octocat
Example: 1
Example: octocat
Example: MDQ6VXNlcjE=
Example: https://api.github.com/users/octocat/orgs
Example: https://api.github.com/users/octocat/received_events
Example: https://api.github.com/users/octocat/repos
Example: "2020-07-09T00:17:55Z"
Example: https://api.github.com/users/octocat/starred{/owner}{/repo}
Example: https://api.github.com/users/octocat/subscriptions
Example: User
Example: https://api.github.com/users/octocat
Forbidden
Validation failed