
## Unsubscribe from events

`POST /v1/chats/events/unsubscribe`

Stops accumulating messenger events for the current user. After unsubscribing, new events are no longer accumulated. If there was no subscription, the call does not return an error.

## Parameters

The endpoint takes no parameters. The request body is an empty object `{}`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/events/unsubscribe" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/events/unsubscribe" \
  -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/events/unsubscribe', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log('Unsubscribe:', data) // true
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/events/unsubscribe', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | boolean | `true` — unsubscribed successfully |

## Response example

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

## Error response example

403 — no `im` scope:

```json
{
  "success": false,
  "error": {
    "code": "SCOPE_DENIED",
    "message": "This endpoint requires 'im' scope"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error (error text in `message`) |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |

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

## Known specifics

**OAuth key.** For a `vibe_app_…` key add the `Authorization: Bearer <session_token>` header — without it the request returns `401 TOKEN_MISSING`. Learn more — [Keys and authorization](/docs/keys-auth).

## See also

- [Subscribe to events](/docs/chats/events/subscribe)
- [Get events](/docs/chats/events/poll)
- [Messenger events](/docs/chats/events)
- [Keys and authorization](/docs/keys-auth)
