Para agentes de IA: markdown desta página — /docs-content-en/infra/event-subscriptions.md índice da documentação — /llms.txt
Os artigos da documentação estão disponíveis atualmente em inglês.
Portal event subscriptions
Real-time delivery of Bitrix24 events (for example ONTASKADD, ONTASKUPDATE, ONCRMDEALADD) to an application on a Black Hole server, without polling. The platform registers an event handler in Bitrix24 under the server's OAuth application and delivers each event to the application through the tunnel — with retries and wake-up for a sleeping server.
Scope: vibe:infra
Subscriptions are managed by the API key that owns the server. Receiving events does not require a public URL: delivery is managed and passes through the Black Hole tunnel.
Requirements
Push delivery works only for a server bound to a vibe_app_ authorization key — that is, to a Bitrix24 OAuth application. Under a regular vibe_api_ API key or a vibe_live_ management key you cannot register an event handler, and creating a subscription returns 400 NOT_OAUTH_APP. Registering an event in Bitrix24 is available only on a commercial plan — on the free plan it returns 502 BIND_FAILED.
How to get a server under an authorization key
You can switch an existing server to an authorization key in your Vibecode account — "Change managing key" on the server card in the "Black Hole Servers" section. The authorization key of a live application is accepted there when that application does not own a server yet. If there is no server at all, create one under the right key straight away:
- Create an authorization key.
POST /v1/appsor the application-creation form in the Vibecode dashboard registers an OAuth application in your Bitrix24 account and returns avibe_app_key. You do not need to register the application in Bitrix24 manually — the platform does it for you. See Keys and authorization. - Authorize the application in your Bitrix24 account. Open or install the application in your Bitrix24 account and complete OAuth authorization. After that Bitrix24 passes the platform an
application_tokenand a user OAuth token. Withoutapplication_token, creating a subscription returns400 NOT_OAUTH_APP. Without a user OAuth token —400 NO_USER_TOKEN. For the authorization flow, see Keys and authorization. - Bind a server to this key. Either create a new one —
POST /v1/infra/serverswith avibe_app_key — or change the managing key of an existing one in your Vibecode account (Restoring access to a server). - Deploy the application via a regular deploy (Deploy) and subscribe to events.
The 400 NOT_OAUTH_APP and 400 NO_USER_TOKEN responses contain a hint field with these same steps — in case you reached the subscription step via the API.
Create a subscription
POST /v1/infra/servers/:id/event-subscriptions
Registers a Bitrix24 event handler under the server's OAuth application. After creation, the platform delivers every event of the specified type to the application at the appPath path. The server must be backed by a vibe_app_ authorization key — the prerequisites and the steps for creating such a server are described in the Portal event subscriptions section.
Parameters
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id |
path | string (UUID) | yes | Server ID. List: GET /v1/infra/servers |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
event |
string | yes | Bitrix24 event code. Format ^[A-Z][A-Z0-9_]+$ — uppercase Latin letters, digits, underscore. Examples: ONTASKADD, ONTASKUPDATE, ONCRMDEALADD |
appPath |
string | yes | Path on the application where the event is delivered. Starts with /. Example: /api/webhooks/b24 |
Examples
curl — personal key
curl -X POST https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/event-subscriptions \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "event": "ONTASKADD", "appPath": "/api/webhooks/b24" }'
curl — OAuth application
curl -X POST https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/event-subscriptions \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "event": "ONTASKADD", "appPath": "/api/webhooks/b24" }'
JavaScript — personal key
const res = await fetch(
`https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/event-subscriptions`,
{
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ event: 'ONTASKADD', appPath: '/api/webhooks/b24' }),
}
)
const { success, data } = await res.json()
console.log('Subscription ID:', data.id, '— handler:', data.b24Handler)
JavaScript — OAuth application
const res = await fetch(
`https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/event-subscriptions`,
{
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ event: 'ONTASKADD', appPath: '/api/webhooks/b24' }),
}
)
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | true on success |
data.id |
string (UUID) | Subscription ID |
data.appId |
string | ID of the OAuth application the handler is registered under |
data.serverId |
string (UUID) | Server ID |
data.portalId |
string | Bitrix24 portal ID |
data.event |
string | Event code |
data.appPath |
string | Delivery path on the application |
data.authType |
string | Bitrix24 ID of the user who installed the application |
data.b24Handler |
string | Handler URL on the platform where Bitrix24 sends the event |
data.status |
string | Subscription status: ACTIVE, DISABLED, DEGRADED. DEGRADED — after a series of failed deliveries |
data.createdById |
string | null | ID of the Vibecode user who created the subscription |
data.createdAt |
string | Creation date (ISO 8601) |
data.updatedAt |
string | Last change date (ISO 8601) |
Response example
{
"success": true,
"data": {
"id": "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"appId": "9a1c2b3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"serverId": "e765edfc-ba0a-43de-b8ea-838dd872c522",
"portalId": "8b1f0e2a-3c4d-5e6f-7a8b-9c0d1e2f3a4b",
"event": "ONTASKADD",
"appPath": "/api/webhooks/b24",
"authType": "1",
"b24Handler": "https://vibecode.bitrix24.com/v1/portal-events/9a1c2b3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"status": "ACTIVE",
"createdById": "7f3a1c2b-9d8e-4a6f-b1c2-3d4e5f6a7b8c",
"createdAt": "2026-06-07T10:00:00.000Z",
"updatedAt": "2026-06-07T10:00:00.000Z"
}
}
Error response example
400 — the server is not backed by an OAuth application:
{
"success": false,
"error": {
"code": "NOT_OAUTH_APP",
"message": "Server is not backed by an OAuth app with a B24 application token"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_EVENT |
The event code is empty or does not match the format ^[A-Z][A-Z0-9_]+$ |
| 400 | INVALID_APP_PATH |
appPath does not start with / or contains control characters |
| 400 | NOT_OAUTH_APP |
The server is not backed by an OAuth application with an application_token. The response contains a hint field with the steps for creating such a server |
| 400 | NO_USER_TOKEN |
The application has no OAuth token — authorize the application on the portal first. The response contains a hint field |
| 403 | INFRA_FORBIDDEN_FOR_COWORK_KEY |
The call was made with a Cowork/Code key — such a key works with data only and cannot perform write operations. To issue a key that can, see Project key for deploy |
| 403 | SERVER_ROLE_FORBIDDEN |
You are on this server's development team with the Developer role, and this operation is open to the Administrator role. error.hint carries your role, the required threshold and the list of calls that are open to you. Role breakdown — List servers |
| 404 | NOT_FOUND |
The server does not exist or belongs to another API key while you are not on its development team |
| 409 | EVENT_BOUND_ELSEWHERE |
This event is already bound to another server of the same application — delete the previous subscription first |
| 502 | BIND_FAILED |
Bitrix24 rejected the event registration — for example, the portal is not on a commercial plan |
Full list of common API errors — Errors.
Known specifics
- Calling again with the same
(server, event)pair updates the subscription. If a subscription for this event already exists on the same server, calling again updatesappPathand returns200— suitable for re-running setup scripts.