## Open the discussion of a post

`POST /v1/chats/messages/:messageId/comments/chat`

Opens the comment chat of a channel post in one request. The response is the same as for [loading a chat](/docs/chats/messages/load): the chat card, the first page of messages, pinned messages, participants and files. If the post has no comment chat yet, Bitrix24 creates it. You become a participant of this chat.

## Parameters

| Parameter | Type | Required | Default | Description |
|----------|-----|:-----:|-----------|---------|
| `messageId` (path) | number | yes | — | ID of the channel post, a positive integer. Posts of a channel — [Read messages](/docs/chats/messages/list) |
| `messageLimit` (query) | number | no | 50 | How many messages to take on each side of the pivot message: the page holds up to `messageLimit` messages before it, the message itself and up to `messageLimit` after. From 1 to 200: a value outside the range is clamped; the passed and applied values are in `meta.requestedMessageLimit` and `meta.appliedMessageLimit` |
| `pinLimit` (query) | number | no | 50 | How many pinned messages to return. From 1 to 200; the passed and applied values are in `meta.requestedPinLimit` and `meta.appliedPinLimit` |
| `ignoreMark` (query) | boolean | no | `false` | `true` — build the first page from the last read message, ignoring the "unread" mark |

No body is needed. Other parameters, repeated parameters and body fields are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/845/comments/chat?messageLimit=30" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/845/comments/chat?messageLimit=30" \
  -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/845/comments/chat?messageLimit=30', {
  method: 'POST',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
console.log('Comment chat:', data.chat.dialogId)
console.log('Comments:', data.messages.length)
```

### JavaScript — OAuth application

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

const { data } = await res.json()
console.log('Comment chat:', data.chat.dialogId)
console.log('Comments:', data.messages.length)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.chat` | object | The comment chat card: `id`, `dialogId`, `name`, `type`, `owner`, `role` and other fields, as for [loading a chat](/docs/chats/messages/load) |
| `data.messages` | array | The first page of messages of the comment chat |
| `data.pins` | array | Pinned messages |
| `data.users` | array | Participants mentioned on the page |
| `data.files` | array | Files attached to the messages on the page |
| `data.reactions` | array | Reactions to the messages on the page |
| `data.hasPrevPage` | boolean | Whether there are messages older than the first page |
| `data.hasNextPage` | boolean | Whether there are messages newer than the first page |
| `meta.requestedMessageLimit` | number | The passed `messageLimit` value, present when it falls outside the range from 1 to 200 |
| `meta.appliedMessageLimit` | number | The applied `messageLimit` value — only when it was clamped to a bound |
| `meta.requestedPinLimit` | number | The passed `pinLimit` value, present when it falls outside the range from 1 to 200 |
| `meta.appliedPinLimit` | number | The applied `pinLimit` value — only when it was clamped to a bound |

## Response example

```json
{
  "success": true,
  "data": {
    "chat": {
      "id": 2001,
      "dialogId": "chat2001",
      "name": "Post comments",
      "type": "comment",
      "owner": 5,
      "role": "member"
    },
    "messages": [
      {
        "id": 3002,
        "chatId": 2001,
        "authorId": 7,
        "date": "2026-10-29T10:01:00+00:00",
        "text": "Agreed",
        "params": {}
      }
    ],
    "pins": [],
    "users": [],
    "files": [],
    "reactions": [],
    "hasPrevPage": false,
    "hasNextPage": false
  }
}
```

## Error response example

403 — a request with a read-only key:

```json
{
  "success": false,
  "error": {
    "code": "WRITE_BLOCKED_READONLY_KEY",
    "message": "Key is in read-only mode. Switch the key to read and write in /keys to allow Bitrix24 data changes.",
    "details": {
      "method": "im.v2.Chat.load",
      "keyName": "Reports dashboard",
      "currentMode": "READONLY",
      "switchUrl": "/keys"
    }
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `messageId` is not a positive integer, or the request has a parameter other than `messageLimit`, `pinLimit` and `ignoreMark`, a repeated parameter, an invalid value, a body that is not a JSON object, or a body field. 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`. A missing message lands here too — with `MESSAGE_NOT_FOUND`, not with a `404` |
| 403 | `BITRIX_ACCESS_DENIED` | The user has no access to the chat — Bitrix24 refused with the `ACCESS_DENIED` code |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only: opening the discussion can create a chat and make you a participant — see [access rights](/docs/access-rights). No request is sent to Bitrix24 |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## Known specifics

**Opening changes data.** Bitrix24 can create the comment chat and add you as a participant. That is why a read-only key gets `403 WRITE_BLOCKED_READONLY_KEY`, although the response is the same as for loading a chat.

**The request is not retried automatically.** On a network failure or a `5xx` response the platform does not send the call again. Whether to retry is up to you.

**Works for a forwarded post too.** A forwarded post has no comment chat; this request creates it. To find the chat without opening it, use the [comment summary](/docs/chats/messages/comments): a post without a chat does not appear there.

## See also

- [Comment summary for posts](/docs/chats/messages/comments)
- [Load a chat](/docs/chats/messages/load)
- [Follow the comments of a post](/docs/chats/messages/comments-subscription-create)
- [Mark all channel comments as read](/docs/chats/messages/comments-read-all)
