## Add a reaction

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

Adds the current user's reaction to a message. The chat is resolved from the message, so no `dialogId` is needed.

A reaction is set by a camelCase code: `like`, `fire`, `laugh`, `faceWithThermometer`. The set of codes is defined by Bitrix24 and may grow. In version `im 26.1300` there are 48: `like`, `faceWithTearsOfJoy`, `redHeart`, `neutralFace`, `fire`, `cry`, `slightlySmilingFace`, `winkingFace`, `laugh`, `kiss`, `wonder`, `slightlyFrowningFace`, `loudlyCryingFace`, `faceWithStuckOutTongue`, `faceWithStuckOutTongueAndWinkingEye`, `smilingFaceWithSunglasses`, `confusedFace`, `flushedFace`, `thinkingFace`, `angry`, `smilingFaceWithHorns`, `faceWithThermometer`, `facepalm`, `poo`, `flexedBiceps`, `clappingHands`, `raisedHand`, `dislike`, `smilingFaceWithHeartEyes`, `smilingFaceWithHearts`, `pleadingFace`, `relievedFace`, `foldedHands`, `okHand`, `signHorns`, `loveYouGesture`, `clownFace`, `partyingFace`, `questionMark`, `exclamationMark`, `lightBulb`, `bomb`, `sleepingSymbol`, `crossMark`, `whiteHeavyCheckMark`, `eyes`, `handshake`, `hundredPoints`.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `messageId` (path) | number | yes | Message ID, a positive integer — from the [chat feed](/docs/chats/messages/list) (`GET /v1/chats/:dialogId/messages`) or from the [send](/docs/chats/messages/send) response |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `reaction` | string | yes | Reaction code in camelCase |

Any other body field and any query parameter are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

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

### curl — OAuth application

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

### JavaScript — personal key

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

const { data } = await res.json()
console.log('Reaction added:', data.result)
```

### JavaScript — OAuth application

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

const { data } = await res.json()
console.log('Reaction added:', data.result)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.result` | boolean | `true` — the reaction is added |

## Response example

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

## Error response example

422 — this reaction is already on the message:

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

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `messageId` is not a positive integer, `reaction` is missing, the reaction code is not in camelCase (`LIKE`, `face_with`), or an extra body field or a query parameter is passed. Checked before any call to Bitrix24 |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 reported "not found"; the portal code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the code is in `error.b24Code`: `REACTION_ALREADY_SET` — the reaction is already set, `REACTION_NOT_FOUND` — the code is unknown to Bitrix24, `MESSAGE_NOT_FOUND` — there is no such message |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | A read-only key cannot add reactions — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## Known specifics

**One reaction per code.** Different codes on the same message are added independently. Repeating the same code returns the `REACTION_ALREADY_SET` error.

## See also

- [List reactions to a message](/docs/chats/messages/reactions-list)
- [Remove a reaction](/docs/chats/messages/reactions-delete)
- [Read messages](/docs/chats/messages/list)
- [Messages](/docs/chats/messages)
