لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/infra/event-subscriptions.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Bitrix24 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 appPath. 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 Bitrix24 event subscriptions section.
Parameters
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Parameterid |
Inpath | Typestring (UUID) | Requiredyes | DescriptionServer ID. List: GET /v1/infra/servers |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
Fieldevent |
Typestring | Requiredyes | DescriptionBitrix24 event code. Format ^[A-Z][A-Z0-9_]+(?:\.[A-Z][A-Z0-9_]+)*$ — uppercase Latin letters, digits and underscores. Code parts are separated by dots. Examples: ONTASKADD, ONCRMDEALADD, CATALOG.PRODUCT.ON.ADD |
FieldappPath |
Typestring | Requiredyes | DescriptionPath 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 |
|---|---|---|
Fieldsuccess |
Typeboolean | Descriptiontrue on success |
Fielddata.id |
Typestring (UUID) | DescriptionSubscription ID |
Fielddata.appId |
Typestring | DescriptionID of the OAuth application the handler is registered under |
Fielddata.serverId |
Typestring (UUID) | DescriptionServer ID |
Fielddata.portalId |
Typestring | DescriptionBitrix24 portal ID |
Fielddata.event |
Typestring | DescriptionEvent code |
Fielddata.appPath |
Typestring | DescriptionDelivery path on the application |
Fielddata.authType |
Typestring | DescriptionBitrix24 ID of the user who installed the application |
Fielddata.b24Handler |
Typestring | DescriptionHandler URL on the platform where Bitrix24 sends the event |
Fielddata.status |
Typestring | DescriptionSubscription status: ACTIVE, DISABLED, DEGRADED. DEGRADED — after a series of failed deliveries |
Fielddata.createdById |
Typestring | null | DescriptionID of the Vibecode user who created the subscription |
Fielddata.createdAt |
Typestring | DescriptionCreation date (ISO 8601) |
Fielddata.updatedAt |
Typestring | DescriptionLast modification 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 |
|---|---|---|
| HTTP400 | CodeINVALID_EVENT |
DescriptionThe event code is empty or does not match the format ^[A-Z][A-Z0-9_]+(?:\.[A-Z][A-Z0-9_]+)*$ |
| HTTP400 | CodeINVALID_APP_PATH |
DescriptionappPath does not start with / or contains control characters |
| HTTP400 | CodeNOT_OAUTH_APP |
DescriptionThe 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 |
| HTTP400 | CodeNO_USER_TOKEN |
DescriptionThe application has no OAuth token — authorize the application on the portal first. The response contains a hint field |
| HTTP403 | CodeINFRA_FORBIDDEN_FOR_COWORK_KEY |
DescriptionThe 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 |
| HTTP403 | CodeSERVER_ROLE_FORBIDDEN |
DescriptionYou 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 |
| HTTP404 | CodeNOT_FOUND |
DescriptionThe server does not exist or belongs to another API key while you are not on its development team |
| HTTP409 | CodeEVENT_BOUND_ELSEWHERE |
DescriptionThis event is already bound to another server of the same application — delete the previous subscription first |
| HTTP502 | CodeBIND_FAILED |
DescriptionBitrix24 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— useful for re-running setup scripts. - The Bitrix24 tokens in the event body depend on the mode of the server key and the app key, and on the app address. If either key does not change Bitrix24 data, or the app address
appUrlpoints outside the platform, the subscription's events arrive withoutauth[access_token]andauth[refresh_token]— see Event body.