2020-06-23 00:09:42 +05:30
---
2020-10-24 23:57:45 +05:30
stage: Create
group: Source Code
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-10-24 23:57:45 +05:30
type: reference, api
2020-06-23 00:09:42 +05:30
---
2021-03-11 19:13:27 +05:30
# Discussions API **(FREE)**
2018-03-27 19:54:05 +05:30
2019-09-04 21:01:54 +05:30
Discussions are a set of related notes on:
- Snippets
- Issues
2022-06-21 17:19:12 +05:30
- [Epics ](../user/group/epics/index.md )
2019-09-04 21:01:54 +05:30
- Merge requests
- Commits
2018-03-27 19:54:05 +05:30
2022-06-21 17:19:12 +05:30
This includes [comments and threads ](../user/discussions/index.md ) and system notes.
System notes are notes about changes to the object (for example, when a milestone changes).
Label notes are not part of this API, but recorded as separate events in
[resource label events ](resource_label_events.md ).
2019-07-31 22:56:46 +05:30
## Discussions pagination
2019-09-30 21:07:59 +05:30
By default, `GET` requests return 20 results at a time because the API results are paginated.
2019-07-31 22:56:46 +05:30
2023-04-23 21:23:45 +05:30
Read more on [pagination ](rest/index.md#pagination ).
2019-07-31 22:56:46 +05:30
2018-03-27 19:54:05 +05:30
## Issues
2019-09-30 21:07:59 +05:30
### List project issue discussion items
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
Gets a list of all discussion items for a single issue.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
GET /projects/:id/issues/:issue_iid/discussions
```
| Attribute | Type | Required | Description |
| ------------------- | ---------------- | ---------- | ------------ |
2023-07-09 08:55:56 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `issue_iid` | integer | yes | The IID of an issue. |
2018-03-27 19:54:05 +05:30
```json
[
{
"id": "6a9c1750b37d513a43987b574953fceb50b03ce7",
"individual_note": false,
"notes": [
{
"id": 1126,
"type": "DiscussionNote",
"body": "discussion text",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-03T21:54:39.668Z",
"updated_at": "2018-03-03T21:54:39.668Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Issue",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-03-27 19:54:05 +05:30
"noteable_iid": null
},
{
"id": 1129,
"type": "DiscussionNote",
"body": "reply to the discussion",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T13:38:02.127Z",
"updated_at": "2018-03-04T13:38:02.127Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Issue",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolvable": false
2018-03-27 19:54:05 +05:30
}
]
},
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": true,
"notes": [
{
"id": 1128,
"type": null,
"body": "a single comment",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Issue",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolvable": false
2018-03-27 19:54:05 +05:30
}
]
}
]
```
2020-03-13 15:44:24 +05:30
```shell
2021-11-11 11:23:49 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > "\
"https://gitlab.example.com/api/v4/projects/5/issues/11/discussions"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Get single issue discussion item
2018-03-27 19:54:05 +05:30
2023-07-09 08:55:56 +05:30
Returns a single discussion item for a specific project issue.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
GET /projects/:id/issues/:issue_iid/discussions/:discussion_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `issue_iid` | integer | yes | The IID of an issue. |
| `discussion_id` | integer | yes | The ID of a discussion item. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/< discussion_id > "
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Create new issue thread
2018-03-27 19:54:05 +05:30
2023-07-09 08:55:56 +05:30
Creates a new thread to a single project issue. Similar to creating a note, but other comments (replies) can be added to it later.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
POST /projects/:id/issues/:issue_iid/discussions
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `issue_iid` | integer | yes | The IID of an issue. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/issues/11/discussions?body=comment"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Add note to existing issue thread
2022-08-27 11:52:29 +05:30
Adds a new note to the thread. This can also [create a thread from a single comment ](../user/discussions/index.md#create-a-thread-by-replying-to-a-standard-comment ).
2018-03-27 19:54:05 +05:30
2023-07-09 08:55:56 +05:30
WARNING:
2021-09-04 01:27:46 +05:30
Notes can be added to other items than comments, such as system notes, making them threads.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
POST /projects/:id/issues/:issue_iid/discussions/:discussion_id/notes
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the note or reply. |
| `discussion_id` | integer | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `issue_iid` | integer | yes | The IID of an issue. |
| `note_id` | integer | yes | The ID of a thread note. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights.
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/< discussion_id > /notes?body=comment"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Modify existing issue thread note
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
Modify existing thread note of an issue.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
PUT /projects/:id/issues/:issue_iid/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the note or reply. |
| `discussion_id` | integer | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `issue_iid` | integer | yes | The IID of an issue. |
| `note_id` | integer | yes | The ID of a thread note. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/< discussion_id > /notes/1108?body=comment"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Delete an issue thread note
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
Deletes an existing thread note of an issue.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
DELETE /projects/:id/issues/:issue_iid/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | integer | yes | The ID of a discussion. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `issue_iid` | integer | yes | The IID of an issue. |
| `note_id` | integer | yes | The ID of a discussion note. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/636"
2018-03-27 19:54:05 +05:30
```
## Snippets
2019-09-30 21:07:59 +05:30
### List project snippet discussion items
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
Gets a list of all discussion items for a single snippet.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
GET /projects/:id/snippets/:snippet_id/discussions
```
| Attribute | Type | Required | Description |
| ------------------- | ---------------- | ---------- | ------------|
2023-07-09 08:55:56 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `snippet_id` | integer | yes | The ID of an snippet. |
2018-03-27 19:54:05 +05:30
```json
[
{
"id": "6a9c1750b37d513a43987b574953fceb50b03ce7",
"individual_note": false,
"notes": [
{
"id": 1126,
"type": "DiscussionNote",
"body": "discussion text",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-03T21:54:39.668Z",
"updated_at": "2018-03-03T21:54:39.668Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Snippet",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2021-06-08 01:23:25 +05:30
"noteable_iid": null
2018-03-27 19:54:05 +05:30
},
{
"id": 1129,
"type": "DiscussionNote",
"body": "reply to the discussion",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T13:38:02.127Z",
"updated_at": "2018-03-04T13:38:02.127Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Snippet",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2021-06-08 01:23:25 +05:30
"noteable_iid": null,
2018-10-15 14:42:47 +05:30
"resolvable": false
2018-03-27 19:54:05 +05:30
}
]
},
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": true,
"notes": [
{
"id": 1128,
"type": null,
"body": "a single comment",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Snippet",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2021-06-08 01:23:25 +05:30
"noteable_iid": null,
2018-10-15 14:42:47 +05:30
"resolvable": false
2018-03-27 19:54:05 +05:30
}
]
}
]
```
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Get single snippet discussion item
2018-03-27 19:54:05 +05:30
2023-07-09 08:55:56 +05:30
Returns a single discussion item for a specific project snippet.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
GET /projects/:id/snippets/:snippet_id/discussions/:discussion_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | integer | yes | The ID of a discussion item.
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `snippet_id` | integer | yes | The ID of an snippet. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/< discussion_id > "
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Create new snippet thread
2018-03-27 19:54:05 +05:30
2023-07-09 08:55:56 +05:30
Creates a new thread to a single project snippet. Similar to creating
a note, but other comments (replies) can be added to it later.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
POST /projects/:id/snippets/:snippet_id/discussions
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of a discussion. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `snippet_id` | integer | yes | The ID of an snippet. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2021-11-11 11:23:49 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > "\
"https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions?body=comment"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Add note to existing snippet thread
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
Adds a new note to the thread.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
POST /projects/:id/snippets/:snippet_id/discussions/:discussion_id/notes
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the note or reply. |
| `discussion_id` | integer | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a thread note. |
| `snippet_id` | integer | yes | The ID of an snippet. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/< discussion_id > /notes?body=comment"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Modify existing snippet thread note
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
Modify existing thread note of a snippet.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
PUT /projects/:id/snippets/:snippet_id/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the note or reply. |
| `discussion_id` | integer | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a thread note. |
| `snippet_id` | integer | yes | The ID of an snippet. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/< discussion_id > /notes/1108?body=comment"
2018-03-27 19:54:05 +05:30
```
2019-09-30 21:07:59 +05:30
### Delete a snippet thread note
2018-03-27 19:54:05 +05:30
2019-09-30 21:07:59 +05:30
Deletes an existing thread note of a snippet.
2018-03-27 19:54:05 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-27 19:54:05 +05:30
DELETE /projects/:id/snippets/:snippet_id/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | integer | yes | The ID of a discussion. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a discussion note. |
| `snippet_id` | integer | yes | The ID of an snippet. |
2018-03-27 19:54:05 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/636"
2018-03-27 19:54:05 +05:30
```
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
## Epics **(ULTIMATE)**
2019-09-04 21:01:54 +05:30
2019-09-30 21:07:59 +05:30
### List group epic discussion items
2019-09-04 21:01:54 +05:30
2019-09-30 21:07:59 +05:30
Gets a list of all discussion items for a single epic.
2019-09-04 21:01:54 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
GET /groups/:id/epics/:epic_id/discussions
```
| Attribute | Type | Required | Description |
| ------------------- | ---------------- | ---------- | ------------ |
2023-07-09 08:55:56 +05:30
| `epic_id` | integer | yes | The ID of an epic. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the group ](rest/index.md#namespaced-path-encoding ). |
2019-09-04 21:01:54 +05:30
```json
[
{
"id": "6a9c1750b37d513a43987b574953fceb50b03ce7",
"individual_note": false,
"notes": [
{
"id": 1126,
"type": "DiscussionNote",
"body": "discussion text",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-03T21:54:39.668Z",
"updated_at": "2018-03-03T21:54:39.668Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Epic",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2021-06-08 01:23:25 +05:30
"noteable_iid": null,
2019-09-04 21:01:54 +05:30
"resolvable": false
},
{
"id": 1129,
"type": "DiscussionNote",
"body": "reply to the discussion",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T13:38:02.127Z",
"updated_at": "2018-03-04T13:38:02.127Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Epic",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2021-06-08 01:23:25 +05:30
"noteable_iid": null,
2019-09-04 21:01:54 +05:30
"resolvable": false
}
]
},
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": true,
"notes": [
{
"id": 1128,
"type": null,
"body": "a single comment",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Epic",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2021-06-08 01:23:25 +05:30
"noteable_iid": null,
2019-09-04 21:01:54 +05:30
"resolvable": false
}
]
}
]
```
2020-03-13 15:44:24 +05:30
```shell
2021-11-11 11:23:49 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > "\
"https://gitlab.example.com/api/v4/groups/5/epics/11/discussions"
2019-09-04 21:01:54 +05:30
```
2019-09-30 21:07:59 +05:30
### Get single epic discussion item
2019-09-04 21:01:54 +05:30
2023-07-09 08:55:56 +05:30
Returns a single discussion item for a specific group epic.
2019-09-04 21:01:54 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
GET /groups/:id/epics/:epic_id/discussions/:discussion_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | integer | yes | The ID of a discussion item. |
| `epic_id` | integer | yes | The ID of an epic. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the group ](rest/index.md#namespaced-path-encoding ). |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/< discussion_id > "
2019-09-04 21:01:54 +05:30
```
2019-09-30 21:07:59 +05:30
### Create new epic thread
2019-09-04 21:01:54 +05:30
2023-07-09 08:55:56 +05:30
Creates a new thread to a single group epic. Similar to creating
a note, but other comments (replies) can be added to it later.
2019-09-04 21:01:54 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
POST /groups/:id/epics/:epic_id/discussions
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the thread. |
| `epic_id` | integer | yes | The ID of an epic. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the group ](rest/index.md#namespaced-path-encoding ). |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/groups/5/epics/11/discussions?body=comment"
2019-09-04 21:01:54 +05:30
```
2019-09-30 21:07:59 +05:30
### Add note to existing epic thread
2019-09-04 21:01:54 +05:30
2019-09-30 21:07:59 +05:30
Adds a new note to the thread. This can also
2022-08-27 11:52:29 +05:30
[create a thread from a single comment ](../user/discussions/index.md#create-a-thread-by-replying-to-a-standard-comment ).
2019-09-04 21:01:54 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
POST /groups/:id/epics/:epic_id/discussions/:discussion_id/notes
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the note or reply. |
| `discussion_id` | integer | yes | The ID of a thread. |
| `epic_id` | integer | yes | The ID of an epic. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the group ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a thread note. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/< discussion_id > /notes?body=comment"
2019-09-04 21:01:54 +05:30
```
2019-09-30 21:07:59 +05:30
### Modify existing epic thread note
2019-09-04 21:01:54 +05:30
2019-09-30 21:07:59 +05:30
Modify existing thread note of an epic.
2019-09-04 21:01:54 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
PUT /groups/:id/epics/:epic_id/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of note or reply. |
| `discussion_id` | integer | yes | The ID of a thread. |
| `epic_id` | integer | yes | The ID of an epic. |
| `id` | integer/string | yes | The ID or [URL-encoded path of the group ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a thread note. |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/< discussion_id > /notes/1108?body=comment"
2019-09-04 21:01:54 +05:30
```
2019-09-30 21:07:59 +05:30
### Delete an epic thread note
2019-09-04 21:01:54 +05:30
2019-09-30 21:07:59 +05:30
Deletes an existing thread note of an epic.
2019-09-04 21:01:54 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
DELETE /groups/:id/epics/:epic_id/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | integer | yes | The ID of a thread. |
| `epic_id` | integer | yes | The ID of an epic. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the group ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a thread note. |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/636"
2019-09-04 21:01:54 +05:30
```
2018-10-15 14:42:47 +05:30
## Merge requests
2019-09-30 21:07:59 +05:30
### List project merge request discussion items
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Gets a list of all discussion items for a single merge request.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-10-15 14:42:47 +05:30
GET /projects/:id/merge_requests/:merge_request_iid/discussions
```
| Attribute | Type | Required | Description |
| ------------------- | ---------------- | ---------- | ------------ |
2023-07-09 08:55:56 +05:30
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `merge_request_iid` | integer | yes | The IID of a merge request. |
2018-10-15 14:42:47 +05:30
```json
[
{
"id": "6a9c1750b37d513a43987b574953fceb50b03ce7",
"individual_note": false,
"notes": [
{
"id": 1126,
"type": "DiscussionNote",
"body": "discussion text",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-03T21:54:39.668Z",
"updated_at": "2018-03-03T21:54:39.668Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Merge request",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolved": false,
"resolvable": true,
2021-03-08 18:12:59 +05:30
"resolved_by": null,
"resolved_at": null
2018-10-15 14:42:47 +05:30
},
{
"id": 1129,
"type": "DiscussionNote",
"body": "reply to the discussion",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T13:38:02.127Z",
"updated_at": "2018-03-04T13:38:02.127Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Merge request",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolved": false,
"resolvable": true,
"resolved_by": null
}
]
},
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": true,
"notes": [
{
"id": 1128,
"type": null,
"body": "a single comment",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Merge request",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolved": false,
"resolvable": true,
"resolved_by": null
}
]
}
]
```
2020-04-22 19:07:51 +05:30
Diff comments also contain position:
2018-10-15 14:42:47 +05:30
```json
[
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": false,
"notes": [
{
"id": 1128,
2021-06-08 01:23:25 +05:30
"type": "DiffNote",
2018-10-15 14:42:47 +05:30
"body": "diff comment",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Merge request",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
2021-02-22 17:27:13 +05:30
"commit_id": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
2018-10-15 14:42:47 +05:30
"position": {
"base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
"start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
"head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
"old_path": "package.json",
"new_path": "package.json",
"position_type": "text",
"old_line": 27,
2020-04-22 19:07:51 +05:30
"new_line": 27,
"line_range": {
2020-07-28 23:09:34 +05:30
"start": {
"line_code": "588440f66559714280628a4f9799f0c4eb880a4a_10_10",
2021-06-08 01:23:25 +05:30
"type": "new"
2020-07-28 23:09:34 +05:30
},
"end": {
"line_code": "588440f66559714280628a4f9799f0c4eb880a4a_11_11",
"type": "old"
2021-06-08 01:23:25 +05:30
}
2020-04-22 19:07:51 +05:30
}
2018-10-15 14:42:47 +05:30
},
"resolved": false,
"resolvable": true,
"resolved_by": null
}
]
}
]
```
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions"
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Get single merge request discussion item
2018-10-15 14:42:47 +05:30
2023-07-09 08:55:56 +05:30
Returns a single discussion item for a specific project merge request.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-10-15 14:42:47 +05:30
GET /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | string | yes | The ID of a discussion item. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `merge_request_iid` | integer | yes | The IID of a merge request. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/< discussion_id > "
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Create new merge request thread
2018-10-15 14:42:47 +05:30
2021-02-22 17:27:13 +05:30
> The `commit id` entry was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47130) in GitLab 13.7.
2023-07-09 08:55:56 +05:30
Creates a new thread to a single project merge request. Similar to creating
2023-05-27 22:25:52 +05:30
a note but other comments (replies) can be added to it later. For other approaches,
see [Post comment to commit ](commits.md#post-comment-to-commit ) in the Commits API,
and [Create new merge request note ](notes.md#create-new-merge-request-note ) in the Notes API.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-10-15 14:42:47 +05:30
POST /projects/:id/merge_requests/:merge_request_iid/discussions
```
2021-04-17 20:07:23 +05:30
Parameters for all comments:
2018-10-15 14:42:47 +05:30
2020-07-28 23:09:34 +05:30
| Attribute | Type | Required | Description |
| ---------------------------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the thread. |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `merge_request_iid` | integer | yes | The IID of a merge request. |
| `position[base_sha]` | string | yes | Base commit SHA in the source branch. |
| `position[head_sha]` | string | yes | SHA referencing HEAD of this merge request. |
| `position[start_sha]` | string | yes | SHA referencing commit in target branch. |
| `position[new_path]` | string | yes (if the position type is `text` ) | File path after change. |
| `position[old_path]` | string | yes (if the position type is `text` ) | File path before change. |
| `position[position_type]` | string | yes | Type of the position reference. Allowed values: `text` or `image` . |
| `commit_id` | string | no | SHA referencing commit to start this thread on. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
| `position` | hash | no | Position when creating a diff note. |
| `position[new_line]` | integer | no | For `text` diff notes, the line number after change. |
| `position[old_line]` | integer | no | For `text` diff notes, the line number before change. |
| `position[line_range]` | hash | no | Line range for a multi-line diff note. |
| `position[width]` | integer | no | For `image` diff notes, width of the image. |
| `position[height]` | integer | no | For `image` diff notes, height of the image. |
| `position[x]` | float | no | For `image` diff notes, X coordinate. |
| `position[y]` | float | no | For `image` diff notes, Y coordinate. |
2018-10-15 14:42:47 +05:30
2021-06-08 01:23:25 +05:30
#### Create a new thread on the overview page
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions?body=comment"
2018-10-15 14:42:47 +05:30
```
2021-06-08 01:23:25 +05:30
#### Create a new thread in the merge request diff
2021-11-11 11:23:49 +05:30
- Both `position[old_path]` and `position[new_path]` are required and must refer
to the file path before and after the change.
- To create a thread on an added line (highlighted in green in the merge request diff),
use `position[new_line]` and don't include `position[old_line]` .
- To create a thread on a removed line (highlighted in red in the merge request diff),
use `position[old_line]` and don't include `position[new_line]` .
- To create a thread on an unchanged line, include both `position[new_line]` and
`position[old_line]` for the line. These positions might not be the same if earlier
2023-07-09 08:55:56 +05:30
changes in the file changed the line number. For the discussion about a fix, see
[issue 32516 ](https://gitlab.com/gitlab-org/gitlab/-/issues/325161 ).
- If you specify incorrect `base` , `head` , `start` , or `SHA` parameters, you might run
into the bug described in [issue #296829) ](https://gitlab.com/gitlab-org/gitlab/-/issues/296829 ).
2021-06-08 01:23:25 +05:30
To create a new thread:
2023-03-04 22:38:38 +05:30
1. [Get the latest merge request version ](merge_requests.md#get-merge-request-diff-versions ):
2021-06-08 01:23:25 +05:30
2021-11-11 11:23:49 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/versions"
```
2021-06-08 01:23:25 +05:30
1. Note the details of the latest version, which is listed first in the response array.
2021-11-11 11:23:49 +05:30
```json
[
{
"id": 164560414,
"head_commit_sha": "f9ce7e16e56c162edbc9e480108041cf6b0291fe",
"base_commit_sha": "5e6dffa282c5129aa67cd227a0429be21bfdaf80",
"start_commit_sha": "5e6dffa282c5129aa67cd227a0429be21bfdaf80",
"created_at": "2021-03-30T09:18:27.351Z",
"merge_request_id": 93958054,
"state": "collected",
"real_size": "2"
},
"previous versions are here"
]
```
2021-09-04 01:27:46 +05:30
2021-06-08 01:23:25 +05:30
1. Create a new diff thread. This example creates a thread on an added line:
2021-11-11 11:23:49 +05:30
```shell
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > "\
--form 'position[position_type]=text'\
--form 'position[base_sha]=< use base_commit_sha from the versions response > '\
--form 'position[head_sha]=< use head_commit_sha from the versions response > '\
--form 'position[start_sha]=< use start_commit_sha from the versions response > '\
--form 'position[new_path]=file.js'\
--form 'position[old_path]=file.js'\
--form 'position[new_line]=18'\
--form 'body=test comment body'\
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions"
```
2021-06-08 01:23:25 +05:30
#### Parameters for multiline comments
2021-04-17 20:07:23 +05:30
Parameters for multiline comments only:
| Attribute | Type | Required | Description |
| ---------------------------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `position[line_range][end][line_code]` | string | yes | [Line code ](#line-code ) for the end line. |
2021-04-17 20:07:23 +05:30
| `position[line_range][end][type]` | string | yes | Use `new` for lines added by this commit, otherwise `old` . |
2023-07-09 08:55:56 +05:30
| `position[line_range][start][line_code]` | string | yes | [Line code ](#line-code ) for the start line. |
| `position[line_range][start][type]` | string | yes | Use `new` for lines added by this commit, otherwise `old` . |
| `position[line_range][end]` | hash | no | Multiline note ending line. |
| `position[line_range][start]` | hash | no | Multiline note starting line. |
2021-04-17 20:07:23 +05:30
#### Line code
2021-11-11 11:23:49 +05:30
A line code is of the form `<SHA>_<old>_<new>` , like this: `adc83b19e793491b1c6ea0fd8b46cd9f32e292fc_5_5`
2021-04-17 20:07:23 +05:30
- `<SHA>` is the SHA1 hash of the filename.
- `<old>` is the line number before the change.
- `<new>` is the line number after the change.
2021-11-11 11:23:49 +05:30
For example, if a commit (`< COMMIT_ID > `) deletes line 463 in the README, you can comment
on the deletion by referencing line 463 in the *old* file:
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: [ACCESS_TOKEN]" \
--form "note=Very clever to remove this unnecessary line!" \
--form "path=README" --form "line=463" --form "line_type=old" \
2021-11-11 11:23:49 +05:30
"https://gitlab.com/api/v4/projects/47/repository/commits/< COMMIT_ID > /comments"
```
If a commit (`< COMMIT_ID > `) adds line 157 to `hello.rb` , you can comment on the
addition by referencing line 157 in the *new* file:
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: [ACCESS_TOKEN]" \
--form "note=This is brilliant!" --form "path=hello.rb" \
--form "line=157" --form "line_type=new" \
2021-11-11 11:23:49 +05:30
"https://gitlab.com/api/v4/projects/47/repository/commits/< COMMIT_ID > /comments"
```
2021-04-17 20:07:23 +05:30
2019-09-30 21:07:59 +05:30
### Resolve a merge request thread
2018-10-15 14:42:47 +05:30
2022-06-21 17:19:12 +05:30
Resolve or unresolve a thread of discussion in a merge request.
Prerequisite:
- You must have at least the Developer role, or be the author of the change being reviewed.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-10-15 14:42:47 +05:30
PUT /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `discussion_id` | string | yes | The ID of a thread. |
| `merge_request_iid` | integer | yes | The IID of a merge request. |
| `resolved` | boolean | yes | Resolve or unresolve the discussion. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/< discussion_id > ?resolved=true"
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Add note to existing merge request thread
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Adds a new note to the thread. This can also
2022-08-27 11:52:29 +05:30
[create a thread from a single comment ](../user/discussions/index.md#create-a-thread-by-replying-to-a-standard-comment ).
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-10-15 14:42:47 +05:30
POST /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the note or reply. |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `discussion_id` | string | yes | The ID of a thread. |
| `merge_request_iid` | integer | yes | The IID of a merge request. |
| `note_id` | integer | yes | The ID of a thread note. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/< discussion_id > /notes?body=comment"
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Modify an existing merge request thread note
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Modify or resolve an existing thread note of a merge request.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-10-15 14:42:47 +05:30
PUT /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | string | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `merge_request_iid` | integer | yes | The IID of a merge request. |
| `note_id` | integer | yes | The ID of a thread note. |
| `body` | string | no | The content of the note or reply. Exactly one of `body` or `resolved` must be set. |
| `resolved` | boolean | no | Resolve or unresolve the note. Exactly one of `body` or `resolved` must be set. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/< discussion_id > /notes/1108?body=comment"
2018-10-15 14:42:47 +05:30
```
Resolving a note:
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/< discussion_id > /notes/1108?resolved=true"
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Delete a merge request thread note
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Deletes an existing thread note of a merge request.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-10-15 14:42:47 +05:30
DELETE /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `discussion_id` | string | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `merge_request_iid` | integer | yes | The IID of a merge request. |
| `note_id` | integer | yes | The ID of a thread note. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " \
2021-11-11 11:23:49 +05:30
"https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/636"
2018-10-15 14:42:47 +05:30
```
## Commits
2019-09-30 21:07:59 +05:30
### List project commit discussion items
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Gets a list of all discussion items for a single commit.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2022-08-27 11:52:29 +05:30
GET /projects/:id/repository/commits/:commit_id/discussions
2018-10-15 14:42:47 +05:30
```
| Attribute | Type | Required | Description |
| ------------------- | ---------------- | ---------- | ------------ |
2023-07-09 08:55:56 +05:30
| `commit_id` | string | yes | The SHA of a commit. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
2018-10-15 14:42:47 +05:30
```json
[
{
"id": "6a9c1750b37d513a43987b574953fceb50b03ce7",
"individual_note": false,
"notes": [
{
"id": 1126,
"type": "DiscussionNote",
"body": "discussion text",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-03T21:54:39.668Z",
"updated_at": "2018-03-03T21:54:39.668Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Commit",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolvable": false
},
{
"id": 1129,
"type": "DiscussionNote",
"body": "reply to the discussion",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T13:38:02.127Z",
"updated_at": "2018-03-04T13:38:02.127Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Commit",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolvable": false
}
]
},
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": true,
"notes": [
{
"id": 1128,
"type": null,
"body": "a single comment",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Commit",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"resolvable": false
}
]
}
]
```
Diff comments contain also position:
```json
[
{
"id": "87805b7c09016a7058e91bdbe7b29d1f284a39e6",
"individual_note": false,
"notes": [
{
"id": 1128,
2021-06-08 01:23:25 +05:30
"type": "DiffNote",
2018-10-15 14:42:47 +05:30
"body": "diff comment",
"attachment": null,
"author": {
"id": 1,
"name": "root",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/00afb8fb6ab07c3ee3e9c1f38777e2f4?s=80& d=identicon",
"web_url": "http://localhost:3000/root"
},
"created_at": "2018-03-04T09:17:22.520Z",
"updated_at": "2018-03-04T09:17:22.520Z",
"system": false,
"noteable_id": 3,
"noteable_type": "Commit",
2023-05-27 22:25:52 +05:30
"project_id": 5,
2018-10-15 14:42:47 +05:30
"noteable_iid": null,
"position": {
"base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
"start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
"head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
"old_path": "package.json",
"new_path": "package.json",
"position_type": "text",
"old_line": 27,
"new_line": 27
},
"resolvable": false
}
]
}
]
```
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " \
2022-10-11 01:57:18 +05:30
"https://gitlab.example.com/api/v4/projects/5/repository/commits/< commit_id > /discussions"
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Get single commit discussion item
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Returns a single discussion item for a specific project commit
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2022-08-27 11:52:29 +05:30
GET /projects/:id/repository/commits/:commit_id/discussions/:discussion_id
2018-10-15 14:42:47 +05:30
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `commit_id` | string | yes | The SHA of a commit. |
| `discussion_id` | string | yes | The ID of a discussion item. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " \
2022-10-11 01:57:18 +05:30
"https://gitlab.example.com/api/v4/projects/5/repository/commits/< commit_id > /discussions/< discussion_id > "
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Create new commit thread
2018-10-15 14:42:47 +05:30
2023-07-09 08:55:56 +05:30
Creates a new thread to a single project commit. Similar to creating
2019-02-15 15:39:39 +05:30
a note but other comments (replies) can be added to it later.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2022-08-27 11:52:29 +05:30
POST /projects/:id/repository/commits/:commit_id/discussions
2018-10-15 14:42:47 +05:30
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the thread. |
| `commit_id` | string | yes | The SHA of a commit. |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `position[base_sha]` | string | yes | SHA of the parent commit. |
| `position[head_sha]` | string | yes | The SHA of this commit. Same as `commit_id` . |
| `position[start_sha]` | string | yes | SHA of the parent commit. |
| `position[position_type]` | string | yes | Type of the position reference. Allowed values: `text` or `image` . |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such as `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
| `position` | hash | no | Position when creating a diff note. |
| `position[new_path]` | string | no | File path after change. |
| `position[new_line]` | integer | no | Line number after change. |
| `position[old_path]` | string | no | File path before change. |
| `position[old_line]` | integer | no | Line number before change. |
| `position[height]` | integer | no | For `image` diff notes, image height. |
| `position[width]` | integer | no | For `image` diff notes, image width. |
| `position[x]` | integer | no | For `image` diff notes, X coordinate. |
| `position[y]` | integer | no | For `image` diff notes, Y coordinate. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2022-10-11 01:57:18 +05:30
"https://gitlab.example.com/api/v4/projects/5/repository/commits/< commit_id > /discussions?body=comment"
2018-10-15 14:42:47 +05:30
```
2021-10-27 15:23:28 +05:30
The rules for creating the API request are the same as when
2023-07-09 08:55:56 +05:30
[creating a new thread in the merge request diff ](#create-a-new-thread-in-the-merge-request-diff ).
The exceptions:
- `base_sha`
- `head_sha`
- `start_sha`
2021-10-27 15:23:28 +05:30
2019-09-30 21:07:59 +05:30
### Add note to existing commit thread
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Adds a new note to the thread.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2022-08-27 11:52:29 +05:30
POST /projects/:id/repository/commits/:commit_id/discussions/:discussion_id/notes
2018-10-15 14:42:47 +05:30
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `body` | string | yes | The content of the note or reply. |
| `commit_id` | string | yes | The SHA of a commit. |
| `discussion_id` | string | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a thread note. |
| `created_at` | string | no | Date time string, ISO 8601 formatted, such `2016-03-11T03:45:40Z` . Requires administrator or project/group owner rights. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
2022-10-11 01:57:18 +05:30
"https://gitlab.example.com/api/v4/projects/5/repository/commits/< commit_id > /discussions/< discussion_id > /notes?body=comment
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Modify an existing commit thread note
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Modify or resolve an existing thread note of a commit.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2022-08-27 11:52:29 +05:30
PUT /projects/:id/repository/commits/:commit_id/discussions/:discussion_id/notes/:note_id
2018-10-15 14:42:47 +05:30
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `commit_id` | string | yes | The SHA of a commit. |
| `discussion_id` | string | yes | The ID of a thread. |
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `note_id` | integer | yes | The ID of a thread note. |
| `body` | string | no | The content of a note. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2022-10-11 01:57:18 +05:30
"https://gitlab.example.com/api/v4/projects/5/repository/commits/< commit_id > /discussions/< discussion_id > /notes/1108?body=comment"
2018-10-15 14:42:47 +05:30
```
Resolving a note:
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
2022-10-11 01:57:18 +05:30
"https://gitlab.example.com/api/v4/projects/5/repository/commits/< commit_id > /discussions/< discussion_id > /notes/1108?resolved=true"
2018-10-15 14:42:47 +05:30
```
2019-09-30 21:07:59 +05:30
### Delete a commit thread note
2018-10-15 14:42:47 +05:30
2019-09-30 21:07:59 +05:30
Deletes an existing thread note of a commit.
2018-10-15 14:42:47 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2022-08-27 11:52:29 +05:30
DELETE /projects/:id/repository/commits/:commit_id/discussions/:discussion_id/notes/:note_id
2018-10-15 14:42:47 +05:30
```
Parameters:
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
2023-07-09 08:55:56 +05:30
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
| `commit_id` | string | yes | The SHA of a commit. |
| `discussion_id` | string | yes | The ID of a thread. |
| `note_id` | integer | yes | The ID of a thread note. |
2018-10-15 14:42:47 +05:30
2020-03-13 15:44:24 +05:30
```shell
2023-07-09 08:55:56 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " \
2022-10-11 01:57:18 +05:30
"https://gitlab.example.com/api/v4/projects/5/repository/commits/< commit_id > /discussions/< discussion_id > /notes/636"
2018-10-15 14:42:47 +05:30
```