
## Re-subscribe to events

`POST /v1/bots/:botId/resubscribe`

Restores the bot's subscription to Bitrix24 events. Use it when the bot is active but `GET /v1/bots/:botId/events` has stopped returning events. No request body is required.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `botId` | number | yes | Bot ID (path parameter) |

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/resubscribe \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/resubscribe \
  -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/bots/42/resubscribe', {
  method: 'POST',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})
const { data } = await res.json()
console.log(data) // { resubscribed: true, eventMode: 'fetch' }
```

### JavaScript — OAuth application

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `data.resubscribed` | boolean | `true` on successful re-subscription |
| `data.eventMode` | string | The bot's event delivery mode: `fetch` or `webhook` |

## Response example

```json
{
  "success": true,
  "data": {
    "resubscribed": true,
    "eventMode": "fetch"
  }
}
```

## Error response example

404 — bot not found:

```json
{
  "success": false,
  "error": {
    "code": "BOT_NOT_FOUND",
    "message": "Bot 42 not found. Register it first via POST /v1/bots."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_BOT_ID` | `botId` is not a number |
| 404 | `BOT_NOT_FOUND` | Bot not found |
| 403 | `BOT_ACCESS_DENIED` | The bot belongs to a different API key |
| 403 | `SCOPE_DENIED` | The API key does not have the `imbot` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

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

## Known specifics

**When to use.** The bot is registered and active — messages arrive in chats and the bot appears in the `GET /v1/bots` list — but the event queue has been empty for several polls in a row, and a `hint` field has appeared in the `GET /v1/bots/:botId/events` response. Re-subscription restores delivery and preserves the Open Channels and welcome-bot bindings, unlike re-registration via `POST /v1/bots`.

**Repeated calls are safe.** Each request re-sends the bot's delivery mode to Bitrix24, so re-subscription can be called several times in a row.

**The `webhook` mode.** For a bot with `eventMode: "webhook"`, re-subscription also re-sends the stored webhook address.

## See also

- [Events](/docs/bots/events)
- [Troubleshooting](/docs/bots/troubleshooting)
- [Bot re-authorization](/docs/bots/management/reauth)
