# Create a commit comment

From **GitHub v3 REST API**.

`POST /repos/{owner}/{repo}/commits/{commit_sha}/comments`

Create a comment for a commit using its `:commit_sha`.

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`

### `commit_sha`

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

commit_sha parameter

## Request body

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

- Type: `object`

```json
{
  "body": "Great stuff",
  "line": 1,
  "path": "file1.txt",
  "position": 4
}
```

```json
{"properties":{"body":{"description":"The contents of the comment.","type":"string"},"line":{"description":"**Deprecated**. Use **position** parameter instead. Line number in the file to comment on.","type":"integer"},"path":{"description":"Relative path of the file to comment on.","type":"string"},"position":{"description":"Line index in the diff to comment on.","type":"integer"}},"required":["body"],"type":"object"}
```

## Responses

### `201`

Response

#### Headers

##### `Location`

- Type: `string`

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

### `application/json`

- Type: `object`

Commit Comment

```json
{
  "author_association": "COLLABORATOR",
  "body": "Great stuff",
  "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
  "created_at": "2011-04-14T16:00:49Z",
  "html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1",
  "id": 1,
  "line": 14,
  "node_id": "MDEzOkNvbW1pdENvbW1lbnQx",
  "path": "file1.txt",
  "position": 4,
  "updated_at": "2011-04-14T16:00:49Z",
  "url": "https://api.github.com/repos/octocat/Hello-World/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":"Commit Comment","properties":{"author_association":{"$ref":"#/components/schemas/author_association"},"body":{"type":"string"},"commit_id":{"type":"string"},"created_at":{"format":"date-time","type":"string"},"html_url":{"format":"uri","type":"string"},"id":{"type":"integer"},"line":{"nullable":true,"type":"integer"},"node_id":{"type":"string"},"path":{"nullable":true,"type":"string"},"position":{"nullable":true,"type":"integer"},"reactions":{"$ref":"#/components/schemas/reaction-rollup"},"updated_at":{"format":"date-time","type":"string"},"url":{"format":"uri","type":"string"},"user":{"$ref":"#/components/schemas/nullable-simple-user"}},"required":["url","html_url","id","node_id","user","position","line","path","commit_id","body","author_association","created_at","updated_at"],"title":"Commit 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}/commits/{commit_sha}/comments \
  --header 'content-type: application/json' \
  --data '{
  "body": "Great stuff",
  "line": 1,
  "path": "file1.txt",
  "position": 4
}'
```
