# Issue Comments

This resource lets you work with comments of an issue.
|  Resource  |     ```GENERIC /api/issues/{issueID}/comments ```    |
| --- | --- |
|  Returned entity  |  [IssueComment](api-entity-IssueComment.html). For the description of the entity attributes, see [Supported Fields](#IssueComment-supported-fields) section.  |
|  Supported methods  |      * `GET`: [Read a List of IssueComments](#get_all-IssueComment-method).    * `POST`: [Add a New IssueComment](#create-IssueComment-method).    |
|  Supported sub-resources  |      * [/api/issues/{issueID}/comments/{commentID}](operations-api-issues-issueID-comments.html)    * [/api/issues/{issueID}/comments/{commentID}/reactions](resource-api-issues-issueID-comments-commentID-reactions.html)    |

## IssueComment attributes

Represents an existing issue comment.

### Related Resources

Below you can find the list of resources that let you work with this entity.

* [Issue Comments]()

### Attributes

This table describes attributes of the `IssueComment` entity.

* To receive an attribute in the response from the server, specify it explicitly in the `fields` request parameter.

* To update an attribute, provide it in the body of a POST request.

|  Field  |  Type  |  Description  |
| --- | --- | --- |
|  id  |  String  |  The ID of the vote for the duplicate issue. `Read-only`.  |
|  attachments  |  [Array of IssueAttachments](api-entity-IssueAttachment.html)  |  The list of attachments that are attached to the comment.  |
|  author  |  [User](api-entity-User.html)  |  The user who created the comment. `Read-only`. `Can be null`.  |
|  created  |  Long  |  The timestamp in milliseconds indicating the moment the comment was posted. Stored as a unix timestamp at UTC. `Read-only`.  |
|  deleted  |  Boolean  |  When `true`, the comment is considered to be deleted, otherwise false.  |
|  issue  |  [Issue](api-entity-Issue.html)  |  The issue the comment belongs to. `Read-only`. `Can be null`.  |
|  pinned  |  Boolean  |  Determines whether the comment is pinned in the issue.  |
|  reactions  |  [Array of Reactions](api-entity-Reaction.html)  |  The list of reactions that users added to this comment.  |
|  text  |  String  |  The text of the comment. `Can be null`.  |
|  textPreview  |  String  |  The comment text as it is shown in UI after processing with wiki/markdown (including HTML markup). `Read-only`.  |
|  updated  |  Long  |  The timestamp in milliseconds indicating the last update of the comment. Stored as a unix timestamp at UTC. `Read-only`. `Can be null`.  |
|  visibility  |  [Visibility](api-entity-Visibility.html)  |  Visibility settings of the comment. They define who is allowed to see the comment. `Can be null`.  |

## Read a List of IssueComments

Get all accessible comments of the specific issue.

### Request syntax

```GENERIC
GET /api/issues/{issueID}/comments?{fields}&{$top}&{$skip}
```

|  null  |  The database ID of IssueComment  |
| --- | --- |

### Request parameters

|  Parameter  |  Type  |  Description  |
| --- | --- | --- |
|  fields  |  String  |  A list of IssueComment attributes that should be returned in the response. If no field is specified, only the `entityID` is returned.  |
|  $skip  |  Int  |  Optional. Lets you set a number of returned entities to skip before returning the first one.  |
|  $top  |  Int  |     Optional. Lets you specify the maximum number of entries that are returned in the response. If you don't set the $top value, the server limits the maximum number of returned entries.       The server returns a maximum of 42 entries for most resources that return collections. For more information, see [Pagination](api-concept-pagination.html).     |

### Sample

#### Sample request

```CURL
https://example.youtrack.cloud/api/issues/2-31/comments?fields=id,author%28login,name,id%29,deleted,text,updated,visibility%28permittedGroups%28name,id%29,permittedUsers%28id,name,login%29%29
```

#### Sample response body

```JSON
[
  {
    "author": {
      "login": "jane.doe",
      "name": "Jane Doe",
      "id": "1-3"
    },
    "deleted": false,
    "updated": null,
    "text": "@john.doe let's update the summary and description",
    "visibility": {
      "permittedGroups": [
        {
          "name": "Sample Project Team",
          "id": "3-2"
        }
      ],
      "permittedUsers": [],
      "$type": "LimitedVisibility"
    },
    "id": "4-0"
  },
  {
    "author": {
      "login": "john.doe",
      "name": "John Doe",
      "id": "1-2"
    },
    "deleted": false,
    "updated": 1533223079255,
    "text": "okay, let's do it, @jane.doe. I am btw updating this from rest",
    "visibility": {
      "$type": "UnlimitedVisibility"
    },
    "id": "4-2"
  }
]
```

## Add a New IssueComment

Add a new comment to an issue with a specific ID.

Required fields: `text`.

### Required permissions

Requires permissions: Create Comment

### Request syntax

```GENERIC
POST /api/issues/{issueID}/comments?{fields}&{draftId}&{muteUpdateNotifications}
```

|  null  |  The database ID of IssueComment  |
| --- | --- |

### Request parameters

|  Parameter  |  Type  |  Description  |
| --- | --- | --- |
|  fields  |  String  |  A list of IssueComment attributes that should be returned in the response. If no field is specified, only the `entityID` is returned.  |
|  draftId  |  String  |  ID of an existing draft that should be published. This parameter is optional.  |
|  muteUpdateNotifications  |  Boolean  |  Set this parameter to `true` if no notifications should be sent on changes made by this request. This doesn't mute notifications sent by any workflow rules. Using this parameter requires Apply Commands Silently permission in all projects affected by the request. Available since 2021.3.  |

### Sample

#### Sample request

```CURL
https://example.youtrack.cloud/api/issues/2-6/comments?fields=id,author%28login,name,id%29,deleted,text,updated,visibility%28permittedGroups%28name,id%29,permittedUsers%28id,name,login%29%29
```

#### Sample request body

```JSON
{
  "text": "Disregard the previous comment. The problem still requires investigation.",
  "visibility": {
    "permittedGroups": [
      {
        "id": "3-2"
      }
    ],
    "$type": "LimitedVisibility"
  }
}
```

#### Sample response body

```JSON
{
  "author": {
    "login": "john.doe",
    "name": "John Doe",
    "id": "1-2",
    "$type": "User"
  },
  "deleted": false,
  "text": "Disregard the previous comment. The problem still requires investigation.",
  "visibility": {
    "permittedUsers": [],
    "permittedGroups": [
      {
        "name": "Sample Project Team",
        "id": "3-2",
        "$type": "UserGroup"
      }
    ],
    "$type": "LimitedVisibility"
  },
  "updated": null,
  "id": "4-14",
  "$type": "IssueComment"
}
```

