---
title: "Create a comment on a commit"
method: POST
path: "/api/v4/projects/{id}/repository/commits/{sha}/comments"
tags: ["commits"]
---

# Create a comment on a commit

`POST /api/v4/projects/{id}/repository/commits/{sha}/comments`

## Request

- Base URL: `https://gitlab.com`
- URL: `https://gitlab.com/api/v4/projects/{id}/repository/commits/{sha}/comments`
- Auth: none declared

Creates a comment on a commit. To comment on a specific line in a file, specify the full commit SHA, `path`, `line`, and set `line_type` to `new`.

## Path parameters

- `id` string, required
- `sha` string, required

## Request body

- PostApiV4ProjectsIdRepositoryCommitsShaComments: Create a comment on a commit
  - `note` string, required: The text of the comment
  - `path` string: The file path
  - `line` integer, required: The line number
  - `line_type` 'new' | 'old', required: The type of the line

## Response `200`

Create a comment on a commit

- APIEntitiesCommitNote: API_Entities_CommitNote model
  - `note` string, required
  - `path` string, required
  - `line` integer, required
  - `line_type` string, required
  - `author` APIEntitiesUserBasic, required: API_Entities_UserBasic model
    - `id` integer, required
    - `username` string, required
    - `public_email` string, required
    - `name` string, required
    - `state` string, required
    - `locked` boolean, required
    - `avatar_url` string, required
    - `avatar_path` string
    - `custom_attributes` APIEntitiesCustomAttribute[]
      - `key` string, required
      - `value` string, required
    - `web_url` string, required
  - `created_at` string, date-time, required

## Other responses

- `400`: Bad request
- `404`: Not found

---

[API](https://skmtc.dev/gitlab/apis/gitlab-api.md) - [All operations](https://skmtc.dev/gitlab/apis/gitlab-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitlab/apis/gitlab-api/revisions/b234947ef3f2?raw)
