# Create a review comment for a pull request

From **GitHub v3 REST API**.

`POST /repos/{owner}/{repo}/pulls/{pull_number}/comments`

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/enterprise-server@3.0/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/enterprise-server@3.0/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/enterprise-server@3.0/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/enterprise-server@3.0/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details.

## Parameters

### `owner`

- Location: path
- Required: true
- Type: `string`

### `repo`

- Location: path
- Required: true
- Type: `string`

### `pull_number`

- Location: path
- Required: true
- Type: `integer`

## Request body

- Required: true
### `application/json`

- Type: `object`

```json
{
  "body": "Great stuff!",
  "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
  "line": 2,
  "path": "file1.txt",
  "side": "RIGHT",
  "start_line": 1,
  "start_side": "RIGHT"
}
```

```json
{"properties":{"body":{"description":"The text of the review comment.","type":"string"},"commit_id":{"description":"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`.","type":"string"},"in_reply_to":{"description":"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,"type":"integer"},"line":{"description":"**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.","type":"integer"},"path":{"description":"The relative path to the file that necessitates a comment.","type":"string"},"position":{"description":"**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.","type":"integer"},"side":{"description":"**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.","enum":["LEFT","RIGHT"],"type":"string"},"start_line":{"description":"**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.","type":"integer"},"start_side":{"description":"**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.","enum":["LEFT","RIGHT","side"],"type":"string"}},"required":["body"],"type":"object"}
```

## Responses

### `201`

Response

#### Headers

##### `Location`

- Type: `string`

- Example: `https://api.github.com/repos/octocat/Hello-World/pulls/comments/1`

### `application/json`

- Type: `object`

Pull Request Review Comments are comments on a portion of the Pull Request's diff.

```json
{
  "_links": {
    "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"
    },
    "self": {
      "href": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1"
    }
  },
  "author_association": "NONE",
  "body": "Great stuff!",
  "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
  "created_at": "2011-04-14T16:00:49Z",
  "diff_hunk": "@@ -16,33 +16,40 @@ public class Connection : IConnection...",
  "html_url": "https://github.com/octocat/Hello-World/pull/1#discussion-diff-1",
  "id": 10,
  "in_reply_to_id": 8,
  "line": 2,
  "node_id": "MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDEw",
  "original_commit_id": "9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840",
  "original_line": 2,
  "original_position": 4,
  "original_start_line": 1,
  "path": "file1.txt",
  "position": 1,
  "pull_request_review_id": 42,
  "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1",
  "side": "RIGHT",
  "start_line": 1,
  "start_side": "RIGHT",
  "updated_at": "2011-04-14T16:00:49Z",
  "url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1",
  "user": {
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "events_url": "https://api.github.com/users/octocat/events{/privacy}",
    "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}",
    "gravatar_id": "",
    "html_url": "https://github.com/octocat",
    "id": 1,
    "login": "octocat",
    "node_id": "MDQ6VXNlcjE=",
    "organizations_url": "https://api.github.com/users/octocat/orgs",
    "received_events_url": "https://api.github.com/users/octocat/received_events",
    "repos_url": "https://api.github.com/users/octocat/repos",
    "site_admin": false,
    "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
    "type": "User",
    "url": "https://api.github.com/users/octocat"
  }
}
```

```json
{"description":"Pull Request Review Comments are comments on a portion of the Pull Request's diff.","properties":{"_links":{"properties":{"html":{"properties":{"href":{"example":"https://github.com/octocat/Hello-World/pull/1#discussion-diff-1","format":"uri","type":"string"}},"required":["href"],"type":"object"},"pull_request":{"properties":{"href":{"example":"https://api.github.com/repos/octocat/Hello-World/pulls/1","format":"uri","type":"string"}},"required":["href"],"type":"object"},"self":{"properties":{"href":{"example":"https://api.github.com/repos/octocat/Hello-World/pulls/comments/1","format":"uri","type":"string"}},"required":["href"],"type":"object"}},"required":["self","html","pull_request"],"type":"object"},"author_association":{"$ref":"#/components/schemas/author_association"},"body":{"description":"The text of the comment.","example":"We should probably include a check for null values here.","type":"string"},"body_html":{"example":"\"\u003cp\u003ecomment body\u003c/p\u003e\"","type":"string"},"body_text":{"example":"\"comment body\"","type":"string"},"commit_id":{"description":"The SHA of the commit to which the comment applies.","example":"6dcb09b5b57875f334f61aebed695e2e4193db5e","type":"string"},"created_at":{"example":"2011-04-14T16:00:49Z","format":"date-time","type":"string"},"diff_hunk":{"description":"The diff of the line that the comment refers to.","example":"@@ -16,33 +16,40 @@ public class Connection : IConnection...","type":"string"},"html_url":{"description":"HTML URL for the pull request review comment.","example":"https://github.com/octocat/Hello-World/pull/1#discussion-diff-1","format":"uri","type":"string"},"id":{"description":"The ID of the pull request review comment.","example":1,"type":"integer"},"in_reply_to_id":{"description":"The comment ID to reply to.","example":8,"type":"integer"},"line":{"description":"The line of the blob to which the comment applies. The last line of the range for a multi-line comment","example":2,"type":"integer"},"node_id":{"description":"The node ID of the pull request review comment.","example":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDEw","type":"string"},"original_commit_id":{"description":"The SHA of the original commit to which the comment applies.","example":"9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840","type":"string"},"original_line":{"description":"The line of the blob to which the comment applies. The last line of the range for a multi-line comment","example":2,"type":"integer"},"original_position":{"description":"The index of the original line in the diff to which the comment applies.","example":4,"type":"integer"},"original_start_line":{"description":"The first line of the range for a multi-line comment.","example":2,"nullable":true,"type":"integer"},"path":{"description":"The relative path of the file to which the comment applies.","example":"config/database.yaml","type":"string"},"position":{"description":"The line index in the diff to which the comment applies.","example":1,"type":"integer"},"pull_request_review_id":{"description":"The ID of the pull request review to which the comment belongs.","example":42,"nullable":true,"type":"integer"},"pull_request_url":{"description":"URL for the pull request that the review comment belongs to.","example":"https://api.github.com/repos/octocat/Hello-World/pulls/1","format":"uri","type":"string"},"reactions":{"$ref":"#/components/schemas/reaction-rollup"},"side":{"default":"RIGHT","description":"The side of the diff to which the comment applies. The side of the last line of the range for a multi-line comment","enum":["LEFT","RIGHT"],"type":"string"},"start_line":{"description":"The first line of the range for a multi-line comment.","example":2,"nullable":true,"type":"integer"},"start_side":{"default":"RIGHT","description":"The side of the first line of the range for a multi-line comment.","enum":["LEFT","RIGHT"],"nullable":true,"type":"string"},"updated_at":{"example":"2011-04-14T16:00:49Z","format":"date-time","type":"string"},"url":{"description":"URL for the pull request review comment","example":"https://api.github.com/repos/octocat/Hello-World/pulls/comments/1","type":"string"},"user":{"$ref":"#/components/schemas/simple-user"}},"required":["url","id","node_id","pull_request_review_id","diff_hunk","path","position","original_position","commit_id","original_commit_id","user","body","created_at","updated_at","html_url","pull_request_url","author_association","_links"],"title":"Pull Request Review Comment","type":"object"}
```

### `403`

Forbidden

### `application/json`

- Type: `object`

Basic Error

```json
{"description":"Basic Error","properties":{"documentation_url":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"}},"title":"Basic Error","type":"object"}
```

### `422`

Validation failed

### `application/json`

- Type: `object`

Validation Error

```json
{"description":"Validation Error","properties":{"documentation_url":{"type":"string"},"errors":{"items":{"properties":{"code":{"type":"string"},"field":{"type":"string"},"index":{"type":"integer"},"message":{"type":"string"},"resource":{"type":"string"},"value":{"oneOf":[{"nullable":true,"type":"string"},{"nullable":true,"type":"integer"},{"items":{"type":"string"},"nullable":true,"type":"array"}]}},"required":["code"],"type":"object"},"type":"array"},"message":{"type":"string"}},"required":["message","documentation_url"],"title":"Validation Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request POST \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/pulls/{pull_number}/comments \
  --header 'content-type: application/json' \
  --data '{
  "body": "Great stuff!",
  "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
  "line": 2,
  "path": "file1.txt",
  "side": "RIGHT",
  "start_line": 1,
  "start_side": "RIGHT"
}'
```
