# Discussions API

> 原文：[https://docs.gitlab.com/ee/api/discussions.html](https://docs.gitlab.com/ee/api/discussions.html)

*   [Discussions pagination](#discussions-pagination)
*   [Issues](#issues)
    *   [List project issue discussion items](#list-project-issue-discussion-items)
    *   [Get single issue discussion item](#get-single-issue-discussion-item)
    *   [Create new issue thread](#create-new-issue-thread)
    *   [Add note to existing issue thread](#add-note-to-existing-issue-thread)
    *   [Modify existing issue thread note](#modify-existing-issue-thread-note)
    *   [Delete an issue thread note](#delete-an-issue-thread-note)
*   [Snippets](#snippets)
    *   [List project snippet discussion items](#list-project-snippet-discussion-items)
    *   [Get single snippet discussion item](#get-single-snippet-discussion-item)
    *   [Create new snippet thread](#create-new-snippet-thread)
    *   [Add note to existing snippet thread](#add-note-to-existing-snippet-thread)
    *   [Modify existing snippet thread note](#modify-existing-snippet-thread-note)
    *   [Delete a snippet thread note](#delete-a-snippet-thread-note)
*   [Epics](#epics-ultimate)
    *   [List group epic discussion items](#list-group-epic-discussion-items)
    *   [Get single epic discussion item](#get-single-epic-discussion-item)
    *   [Create new epic thread](#create-new-epic-thread)
    *   [Add note to existing epic thread](#add-note-to-existing-epic-thread)
    *   [Modify existing epic thread note](#modify-existing-epic-thread-note)
    *   [Delete an epic thread note](#delete-an-epic-thread-note)
*   [Merge requests](#merge-requests)
    *   [List project merge request discussion items](#list-project-merge-request-discussion-items)
    *   [Get single merge request discussion item](#get-single-merge-request-discussion-item)
    *   [Create new merge request thread](#create-new-merge-request-thread)
    *   [Resolve a merge request thread](#resolve-a-merge-request-thread)
    *   [Add note to existing merge request thread](#add-note-to-existing-merge-request-thread)
    *   [Modify an existing merge request thread note](#modify-an-existing-merge-request-thread-note)
    *   [Delete a merge request thread note](#delete-a-merge-request-thread-note)
*   [Commits](#commits)
    *   [List project commit discussion items](#list-project-commit-discussion-items)
    *   [Get single commit discussion item](#get-single-commit-discussion-item)
    *   [Create new commit thread](#create-new-commit-thread)
    *   [Add note to existing commit thread](#add-note-to-existing-commit-thread)
    *   [Modify an existing commit thread note](#modify-an-existing-commit-thread-note)
    *   [Delete a commit thread note](#delete-a-commit-thread-note)

# Discussions API[](#discussions-api "Permalink")

讨论是关于以下方面的一组相关注释：

*   Snippets
*   Issues
*   Epics
*   合并要求
*   Commits

这包括系统注释，这些注释是有关对象更改的注释（例如，当里程碑更改时，将有相应的系统注释）. 标签注释不是此 API 的一部分，而是在[资源标签事件中](resource_label_events.html)记录为单独的[事件](resource_label_events.html) .

## Discussions pagination[](#discussions-pagination "Permalink")

默认情况下，因为 API 结果是分页的，所以`GET`请求一次返回 20 个结果.

阅读有关[分页的](README.html#pagination)更多信息.

## Issues[](#issues "Permalink")

### List project issue discussion items[](#list-project-issue-discussion-items "Permalink")

获取单个问题的所有讨论项目的列表.

```
GET /projects/:id/issues/:issue_iid/discussions 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |

```
[  {  "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",  "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",  "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":  "Issue",  "noteable_iid":  null,  "resolvable":  false  }  ]  }  ] 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/discussions" 
```

### Get single issue discussion item[](#get-single-issue-discussion-item "Permalink")

返回特定项目问题的单个讨论项

```
GET /projects/:id/issues/:issue_iid/discussions/:discussion_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |
| `discussion_id` | integer | yes | 讨论项目的 ID |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7" 
```

### Create new issue thread[](#create-new-issue-thread "Permalink")

为单个项目问题创建一个新线程. 这类似于创建便笺，但其他注释（回复）可以在以后添加.

```
POST /projects/:id/issues/:issue_iid/discussions 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |
| `body` | string | yes | 线程的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/discussions?body=comment" 
```

### Add note to existing issue thread[](#add-note-to-existing-issue-thread "Permalink")

向该线程添加新注释. 这也可以[从单个注释创建线程](../user/discussions/#start-a-thread-by-replying-to-a-standard-comment) .

**警告**注释可以添加到注释（系统注释等）之外的其他项目中，从而使其成为主题.

```
POST /projects/:id/issues/:issue_iid/discussions/:discussion_id/notes 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes?body=comment" 
```

### Modify existing issue thread note[](#modify-existing-issue-thread-note "Permalink")

修改问题的现有线程注释.

```
PUT /projects/:id/issues/:issue_iid/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes/1108?body=comment" 
```

### Delete an issue thread note[](#delete-an-issue-thread-note "Permalink")

删除问题的现有主题注释.

```
DELETE /projects/:id/issues/:issue_iid/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |
| `discussion_id` | integer | yes | 讨论的 ID |
| `note_id` | integer | yes | 讨论记录的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/discussions/636" 
```

## Snippets[](#snippets "Permalink")

### List project snippet discussion items[](#list-project-snippet-discussion-items "Permalink")

获取单个代码段的所有讨论项的列表.

```
GET /projects/:id/snippets/:snippet_id/discussions 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 片段的 ID |

```
[  {  "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",  "noteable_id":  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":  "Snippet",  "noteable_id":  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":  "Snippet",  "noteable_id":  null,  "resolvable":  false  }  ]  }  ] 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions" 
```

### Get single snippet discussion item[](#get-single-snippet-discussion-item "Permalink")

返回特定项目片段的单个讨论项

```
GET /projects/:id/snippets/:snippet_id/discussions/:discussion_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 片段的 ID |
| `discussion_id` | integer | yes | 讨论项目的 ID |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7" 
```

### Create new snippet thread[](#create-new-snippet-thread "Permalink")

Creates a new thread to a single project snippet. This is similar to creating a note but other comments (replies) can be added to it later.

```
POST /projects/:id/snippets/:snippet_id/discussions 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 片段的 ID |
| `body` | string | yes | 讨论内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions?body=comment" 
```

### Add note to existing snippet thread[](#add-note-to-existing-snippet-thread "Permalink")

向该线程添加新注释.

```
POST /projects/:id/snippets/:snippet_id/discussions/:discussion_id/notes 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 片段的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes?body=comment" 
```

### Modify existing snippet thread note[](#modify-existing-snippet-thread-note "Permalink")

修改代码段的现有线程注释.

```
PUT /projects/:id/snippets/:snippet_id/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 片段的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes/1108?body=comment" 
```

### Delete a snippet thread note[](#delete-a-snippet-thread-note "Permalink")

删除代码段的现有线程注释.

```
DELETE /projects/:id/snippets/:snippet_id/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 片段的 ID |
| `discussion_id` | integer | yes | 讨论的 ID |
| `note_id` | integer | yes | 讨论记录的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/discussions/636" 
```

## Epics[](#epics-ultimate "Permalink")

### List group epic discussion items[](#list-group-epic-discussion-items "Permalink")

获取单个史诗的所有讨论项的列表.

```
GET /groups/:id/epics/:epic_id/discussions 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |

```
[  {  "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",  "noteable_id":  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":  "Epic",  "noteable_id":  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":  "Epic",  "noteable_id":  null,  "resolvable":  false  }  ]  }  ] 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/discussions" 
```

### Get single epic discussion item[](#get-single-epic-discussion-item "Permalink")

返回特定小组史诗的单个讨论项

```
GET /groups/:id/epics/:epic_id/discussions/:discussion_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `discussion_id` | integer | yes | 讨论项目的 ID |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7" 
```

### Create new epic thread[](#create-new-epic-thread "Permalink")

Creates a new thread to a single group epic. This is similar to creating a note but other comments (replies) can be added to it later.

```
POST /groups/:id/epics/:epic_id/discussions 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `body` | string | yes | 线程的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/discussions?body=comment" 
```

### Add note to existing epic thread[](#add-note-to-existing-epic-thread "Permalink")

向该线程添加新注释. 这也可以[从单个注释创建线程](../user/discussions/#start-a-thread-by-replying-to-a-standard-comment) .

```
POST /groups/:id/epics/:epic_id/discussions/:discussion_id/notes 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes?body=comment" 
```

### Modify existing epic thread note[](#modify-existing-epic-thread-note "Permalink")

修改史诗的现有线程注释.

```
PUT /groups/:id/epics/:epic_id/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes/1108?body=comment" 
```

### Delete an epic thread note[](#delete-an-epic-thread-note "Permalink")

删除史诗的现有主题注释.

```
DELETE /groups/:id/epics/:epic_id/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/discussions/636" 
```

## Merge requests[](#merge-requests "Permalink")

### List project merge request discussion items[](#list-project-merge-request-discussion-items "Permalink")

获取单个合并请求的所有讨论项的列表.

```
GET /projects/:id/merge_requests/:merge_request_iid/discussions 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |

```
[  {  "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",  "noteable_iid":  null,  "resolved":  false,  "resolvable":  true,  "resolved_by":  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":  "Merge request",  "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",  "noteable_iid":  null,  "resolved":  false,  "resolvable":  true,  "resolved_by":  null  }  ]  }  ] 
```

差异评论还包含以下位置：

```
[  {  "id":  "87805b7c09016a7058e91bdbe7b29d1f284a39e6",  "individual_note":  false,  "notes":  [  {  "id":  1128,  "type":  DiffNote,  "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",  "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,  "line_range":  {  "start":  {  "line_code":  "588440f66559714280628a4f9799f0c4eb880a4a_10_10",  "type":  "new",  },  "end":  {  "line_code":  "588440f66559714280628a4f9799f0c4eb880a4a_11_11",  "type":  "old"  },  }  },  "resolved":  false,  "resolvable":  true,  "resolved_by":  null  }  ]  }  ] 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions" 
```

### Get single merge request discussion item[](#get-single-merge-request-discussion-item "Permalink")

返回特定项目合并请求的单个讨论项

```
GET /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |
| `discussion_id` | integer | yes | 讨论项目的 ID |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7 
```

### Create new merge request thread[](#create-new-merge-request-thread "Permalink")

为单个项目合并请求创建一个新线程. 这类似于创建便笺，但其他注释（回复）可以在以后添加.

```
POST /projects/:id/merge_requests/:merge_request_iid/discussions 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |
| `body` | string | yes | 线程的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |
| `position` | hash | no | 创建差异注释时的位置 |
| `position[base_sha]` | string | yes | 源分支中的基本提交 SHA |
| `position[start_sha]` | string | yes | SHA 引用目标分支中的提交 |
| `position[head_sha]` | string | yes | SHA 引用此合并请求的 HEAD |
| `position[position_type]` | string | yes | 位置参考的类型"，允许的值："文本"或"图像" |
| `position[new_path]` | string | no | 更改后的文件路径 |
| `position[new_line]` | integer | no | 更改后的行号（用于"文本"差异注释） |
| `position[old_path]` | string | no | 更改前的文件路径 |
| `position[old_line]` | integer | no | 更改前的行号（用于"文本"差异注释） |
| `position[line_range]` | hash | no | 多行差异注释的行范围 |
| `position[line_range][start]` | hash | no | 多行音符起始行 |
| `position[line_range][start][line_code]` | string | yes | 起始行的行代码 |
| `position[line_range][start][type]` | string | yes | 起始线的线型 |
| `position[line_range][end]` | hash | no | 多行注释结束行 |
| `position[line_range][end][line_code]` | string | yes | 结束行的行代码 |
| `position[line_range][end][type]` | string | yes | 终点线的线型 |
| `position[width]` | integer | no | 图片宽度（用于"图片"差异注释） |
| `position[height]` | integer | no | 图片的高度（用于"图片"差异注释） |
| `position[x]` | integer | no | X 坐标（用于"图像"差异注释） |
| `position[y]` | integer | no | Y 坐标（用于"图像"差异注释） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions?body=comment" 
```

### Resolve a merge request thread[](#resolve-a-merge-request-thread "Permalink")

解决/取消解决合并请求的整个线程.

```
PUT /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |
| `discussion_id` | integer | yes | 线程的 ID |
| `resolved` | boolean | yes | 解决/取消讨论 |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7?resolved=true" 
```

### Add note to existing merge request thread[](#add-note-to-existing-merge-request-thread "Permalink")

向该线程添加新注释. 这也可以[从单个注释创建线程](../user/discussions/#start-a-thread-by-replying-to-a-standard-comment) .

```
POST /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes?body=comment" 
```

### Modify an existing merge request thread note[](#modify-an-existing-merge-request-thread-note "Permalink")

修改或解决合并请求的现有线程注释.

```
PUT /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | no | 备注/回复的内容（必须是`body`或已`resolved`的内容之一） |
| `resolved` | boolean | no | 解析/取消解析音符（必须设置为刚好为`body`或已`resolved` |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes/1108?body=comment" 
```

解决注释：

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes/1108?resolved=true" 
```

### Delete a merge request thread note[](#delete-a-merge-request-thread-note "Permalink")

删除合并请求的现有线程注释.

```
DELETE /projects/:id/merge_requests/:merge_request_iid/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/discussions/636" 
```

## Commits[](#commits "Permalink")

### List project commit discussion items[](#list-project-commit-discussion-items "Permalink")

获取单个提交的所有讨论项的列表.

```
GET /projects/:id/commits/:commit_id/discussions 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `commit_id` | integer | yes | 提交的 ID |

```
[  {  "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",  "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",  "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",  "noteable_iid":  null,  "resolvable":  false  }  ]  }  ] 
```

差异评论还包含以下位置：

```
[  {  "id":  "87805b7c09016a7058e91bdbe7b29d1f284a39e6",  "individual_note":  false,  "notes":  [  {  "id":  1128,  "type":  DiffNote,  "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",  "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  }  ]  }  ] 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/commits/11/discussions" 
```

### Get single commit discussion item[](#get-single-commit-discussion-item "Permalink")

返回特定项目提交的单个讨论项

```
GET /projects/:id/commits/:commit_id/discussions/:discussion_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `commit_id` | integer | yes | 提交的 ID |
| `discussion_id` | integer | yes | 讨论项目的 ID |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/commits/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7" 
```

### Create new commit thread[](#create-new-commit-thread "Permalink")

为单个项目提交创建一个新线程. 这类似于创建便笺，但其他注释（回复）可以在以后添加.

```
POST /projects/:id/commits/:commit_id/discussions 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `commit_id` | integer | yes | 提交的 ID |
| `body` | string | yes | 线程的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |
| `position` | hash | no | 创建差异注释时的位置 |
| `position[base_sha]` | string | yes | 源分支中的基本提交 SHA |
| `position[start_sha]` | string | yes | SHA 引用目标分支中的提交 |
| `position[head_sha]` | string | yes | SHA 引用此提交的 HEAD |
| `position[position_type]` | string | yes | 位置参考的类型"，允许的值："文本"或"图像" |
| `position[new_path]` | string | no | 更改后的文件路径 |
| `position[new_line]` | integer | no | 变更后的行号 |
| `position[old_path]` | string | no | 更改前的文件路径 |
| `position[old_line]` | integer | no | 更改前的行号 |
| `position[width]` | integer | no | 图片宽度（用于"图片"差异注释） |
| `position[height]` | integer | no | 图片的高度（用于"图片"差异注释） |
| `position[x]` | integer | no | X 坐标（用于"图像"差异注释） |
| `position[y]` | integer | no | Y 坐标（用于"图像"差异注释） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/commits/11/discussions?body=comment" 
```

### Add note to existing commit thread[](#add-note-to-existing-commit-thread "Permalink")

向该线程添加新注释.

```
POST /projects/:id/commits/:commit_id/discussions/:discussion_id/notes 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `commit_id` | integer | yes | 提交的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | yes | 备注/回复的内容 |
| `created_at` | string | no | 日期时间字符串，ISO 8601 格式，例如 2016-03-11T03：45：40Z（需要管理员或项目/组所有者权限） |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/commits/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes?body=comment 
```

### Modify an existing commit thread note[](#modify-an-existing-commit-thread-note "Permalink")

修改或解决提交的现有线程注释.

```
PUT /projects/:id/commits/:commit_id/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `commit_id` | integer | yes | 提交的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |
| `body` | string | no | 笔记内容 |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/commits/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes/1108?body=comment" 
```

解决注释：

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/commits/11/discussions/6a9c1750b37d513a43987b574953fceb50b03ce7/notes/1108?resolved=true" 
```

### Delete a commit thread note[](#delete-a-commit-thread-note "Permalink")

删除提交的现有线程注释.

```
DELETE /projects/:id/commits/:commit_id/discussions/:discussion_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `commit_id` | integer | yes | 提交的 ID |
| `discussion_id` | integer | yes | 线程的 ID |
| `note_id` | integer | yes | 线程注释的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/commits/11/discussions/636" 
```