Note: Multi-line comments on pull requests are currently in public beta and subject to change.
Note: Multi-line comments in a pull request diff is currently available for developers to preview. To access the new response fields during the preview period, you must provide a custom media type in the Accept header:
application/vnd.github.comfort-fade-preview+json
Warning: The API may change without advance notice during the preview period. Preview features are not supported for production use. If you experience any issues, contact GitHub Support or GitHub Premium Support.
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 Multi-line comment summary.
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.
POST /repos/:owner/:repo/pulls/:pull_number/comments
| Name | Type | Description |
|---|---|---|
body |
string |
Required. The text of the review comment. |
commit_id |
string |
Required. 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. |
path |
string |
Required. The relative path to the file that necessitates a comment. |
position |
integer |
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. |
side |
string |
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. |
line |
integer |
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_line |
integer |
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_side |
string |
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. |
{
"path": "test-plan.md",
"start_line": 1,
"start_side": "LEFT",
"line": 3,
"side": "RIGHT",
"body": "Can you expand on this?"
}
{
"path": "test-plan.md",
"line": 5,
"side": "LEFT",
"body": "Let's add this deleted line back."
}
Status: 201 Created
Location: https://api.github.com/repos/octocat/Hello-World/pulls/comments/1
{
"url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1",
"id": 10,
"node_id": "MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDEw",
"pull_request_review_id": 42,
"diff_hunk": "@@ -16,33 +16,40 @@ public class Connection : IConnection...",
"path": "file1.txt",
"position": 1,
"original_position": 4,
"commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"original_commit_id": "9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840",
"in_reply_to_id": 8,
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"body": "Great stuff!",
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z",
"html_url": "https://github.com/octocat/Hello-World/pull/1#discussion-diff-1",
"pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1",
"author_association": "NONE",
"_links": {
"self": {
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1"
},
"html": {
"href": "https://github.com/octocat/Hello-World/pull/1#discussion-diff-1"
},
"pull_request": {
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/1"
}
},
"start_line": 1,
"original_start_line": 1,
"start_side": "RIGHT",
"line": 2,
"original_line": 2,
"side": "RIGHT"
}
Note: New parameters and response fields are available for developers to preview. During the preview period, these response fields may change without advance notice. Please see the blog post for full details.
Use the comfort-fade preview header and the line parameter to show multi-line comment-supported fields in the response.
If you use the comfort-fade preview header, your response will show:
start_line, original_start_line, start_side, line, original_line, and side.line, original_line, and side and a null value for start_line, original_start_line, and start_side.If you don't use the comfort-fade preview header, multi-line and single-line comments will appear the same way in the response with a single position attribute. Your response will show:
position attribute.position attribute. For more information, see position in the input parameters table.