## Remove message anchors

`POST /v1/chats/anchors/read`

Removes your anchors on the given messages. For what an anchor is and how to remove all anchors in a chat, see [`POST /v1/chats/:dialogId/anchors/read`](/docs/chats/messages/anchors).

## Request body fields

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `messageIds` | number[] | yes | IDs of messages in one chat: 1 to 100 items, each a positive integer. The IDs come from the [chat feed](/docs/chats/messages/list) |

Other body fields and query parameters are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/anchors/read" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "messageIds": [1001, 1002] }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/anchors/read" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "messageIds": [1001, 1002] }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/anchors/read', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ messageIds: [1001, 1002] }),
})

const { success } = await res.json()
console.log('Anchors removed:', success)
```

### JavaScript — OAuth application

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

const { success } = await res.json()
console.log('Anchors removed:', success)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | boolean | `true`, even when there was nothing to remove |

## Response example

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

## Error response example

422 — the messages belong to different chats:

```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, not an array, empty, has more than 100 items or contains an item that is not a positive integer. Also a query parameter or an extra body field. 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`. `MESSAGES_IN_DIFFERENT_CHAT_ERROR` — the messages belong to different chats |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

For the full list of common API errors, see [Errors](/docs/errors).

## Known specifics

**This is a write operation, even though the method is called `read`.** The call deletes marks, so a read-only key gets `403 WRITE_BLOCKED_READONLY_KEY` before any call to Bitrix24.

**Messages are not marked as read.** Removing anchors does not move the read marker — to do that, [mark the messages as read](/docs/chats/messages/read-messages).

## See also

- [Remove chat anchors](/docs/chats/messages/anchors)
- [Mark messages as read](/docs/chats/messages/read-messages)
- [Messages around a message](/docs/chats/messages/context)
