
## Rate an answer

`POST /v1/chats/messages/:messageId/vote`

Rates a message with "like" or "dislike" — the v2 messenger method `im.v2.Chat.Message.Vote.send`. Meant for rating CoPilot answers.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `messageId` (path) | number | yes | Message ID. Get it from `data.messages[].id` of the [draft chat](/docs/chats/copilot/draft) or of the [message history in the v2 mode](/docs/chats/messages/list) |

Query parameters are not accepted and are rejected with `400 INVALID_PARAMS`.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `value` | string | yes | The rating: `like` or `dislike` |

Other body fields are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/chats/messages/9002/vote \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value": "like"}'
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/chats/messages/9002/vote \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"value": "like"}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/9002/vote', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ value: 'like' }),
})

const { success, data } = await res.json()
console.log('Rating sent:', data.result)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/9002/vote', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ value: 'like' }),
})

const { success, data } = await res.json()
console.log('Rating sent:', data.result)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.result` | boolean | `true` — the rating was sent |

## Response example

```json
{
  "success": true,
  "data": {
    "result": true
  }
}
```

## Error response example

400 — an invalid `value`:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "`value` must be `like` or `dislike`."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `messageId` is not a positive integer, `value` is missing or is neither `like` nor `dislike`, or another body field or a query parameter was sent. Checked before any call to Bitrix24 |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned "not found"; the portal code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code` |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — the call may make the key owner a chat member |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## Known specifics

**The call may make you a member.** If the message's chat allows auto-join — for example, a comment chat, a collab or a task chat — the call adds the current user as a member, just as opening the chat in the Bitrix24 interface does. The call therefore counts as a write.

**Rating any message.** Bitrix24 accepts a rating for any message and returns `result: true`: the rating is sent as a Bitrix24 event, and CoPilot handlers process it for answers in a CoPilot chat. This endpoint cannot read a rating back.

## See also

- [CoPilot](/docs/chats/copilot)
- [Regenerate a CoPilot answer](/docs/chats/copilot/regenerate)
- [CoPilot draft chat](/docs/chats/copilot/draft)
