## Comment summary for posts

`GET /v1/chats/messages/comments`

Returns a summary of the comment threads of the specified channel posts. A comment thread is a separate chat bound to the post.

## Parameters

| Parameter | Type | Required | Default | Description |
|----------|-----|:-----:|-----------|---------|
| `messageIds` (query) | string | yes | — | Comma-separated IDs of posts from one channel, 1 to 100 IDs: `845,846`. Posts of a channel — [Read messages](/docs/chats/messages/list) |

Any other parameter, or `messageIds` given more than once, is rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/chats/messages/comments?messageIds=845,846" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/chats/messages/comments?messageIds=845,846" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/comments?messageIds=845,846', {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
console.log('Posts with comments:', data.commentInfo.map((c) => c.messageId))
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/comments?messageIds=845,846', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
console.log('Posts with comments:', data.commentInfo.map((c) => c.messageId))
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.commentInfo` | array | One item per post that has a comment thread |
| `data.commentInfo[].messageId` | number | Post ID |
| `data.commentInfo[].chatId` | number | ID of the comment chat |
| `data.commentInfo[].dialogId` | string | Dialog ID of the comment chat, `chatXXX`. Comments of the thread — [Read messages](/docs/chats/messages/list) |
| `data.commentInfo[].messageCount` | number | Number of messages in the thread. A thread opens with a system message, so a thread without comments shows `1` here |
| `data.commentInfo[].lastUserIds` | array | IDs of the latest commenters. Their details are in `data.usersShort` |
| `data.commentInfo[].isUserSubscribed` | boolean | `true` — you follow the comments of the post |
| `data.usersShort` | array | Brief details of the commenters |
| `data.usersShort[].id` | number | User ID |
| `data.usersShort[].name` | string | User name |
| `data.usersShort[].avatar` | string | Avatar URL |
| `data.usersShort[].color` | string | The user's color in the messenger, `#rrggbb` |
| `data.usersShort[].type` | string | User type, for example `user` |

## Response example

```json
{
  "success": true,
  "data": {
    "usersShort": [
      { "id": 7, "name": "Anna Smith", "avatar": "https://cdn.example.com/avatar.jpg", "color": "#df532d", "type": "user" }
    ],
    "commentInfo": [
      {
        "chatId": 2001,
        "dialogId": "chat2001",
        "messageId": 845,
        "lastUserIds": [7],
        "messageCount": 2,
        "isUserSubscribed": true
      },
      {
        "chatId": 2003,
        "dialogId": "chat2003",
        "messageId": 846,
        "lastUserIds": [],
        "messageCount": 1,
        "isUserSubscribed": true
      }
    ]
  }
}
```

## Error response example

422 — the posts belong to different channels:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "MESSAGES_IN_DIFFERENT_CHAT_ERROR",
    "b24Code": "MESSAGES_IN_DIFFERENT_CHAT_ERROR"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `messageIds` is missing, empty or given more than once, has more than 100 items or an item that is not a positive integer, or another parameter is given. Checked before any call to Bitrix24 |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned a generic "not found" code or an error with the text "not found". The portal code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error, the portal code is in `error.b24Code`. `MESSAGE_NOT_FOUND` — there is no message with this ID, `MESSAGES_IN_DIFFERENT_CHAT_ERROR` — the posts belong to different channels |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

The full list of common API errors — [Errors](/docs/errors).

## Known specifics

**The thread appears together with the post.** A thread is created as soon as the post is sent to the channel, before the first comment.

**A post without a thread is skipped without an error.** A forwarded post does not appear in `data.commentInfo`. If all `messageIds` belong to a chat that is not a channel, `data.commentInfo` is empty.

## See also

- [Open the discussion of a post](/docs/chats/messages/comments-chat)
- [Mark all channel comments as read](/docs/chats/messages/comments-read-all)
- [Follow the comments of a post](/docs/chats/messages/comments-subscription-create)
- [Stop following the comments of a post](/docs/chats/messages/comments-subscription-delete)
- [Messages around a message](/docs/chats/messages/context)
