Dla agentów AI: markdown tej strony — /docs-content-en/crm-api-modes.md indeks dokumentacji — /llms.txt
Artykuły dokumentacji są obecnie dostępne w języku angielskim.
CRM API modes
The CRM routes of the Vibecode API work in one of two modes: through the previous version of the Bitrix24 REST API (v2) or through the new one (v3). Route paths and field names are the same in both modes; only the data source differs.
Base URL: https://vibecode.bitrix24.com/v1 | Authorization: X-Api-Key | Mode header: X-Crm-Api
What to know first
- The mode is stored on the key. A new key receives
v2orv3according to the new-key mode set for the Bitrix24 account. When a key inherits a previous key's mode, that inherited mode takes precedence. The mode in which a Bitrix24 account issues new keys is shown by thenewKeyModefield of the key self-description. A key inv2mode behaves the same as it did before modes were introduced. A key issued to replace an active key inherits that key's mode. A Cowork key issued after the previous one was revoked, or for an additional device, takes the mode of the same person's latest Cowork key. - The header overrides the key mode. A request with the
X-Crm-Api: v2orX-Crm-Api: v3header runs in the given mode; the key mode itself does not change. - The response names the mode. The response of a route that sees the mode carries the
X-Crm-Apiheader with the valuev2orv3(the mode the request ran in) when the request sentX-Crm-Apiitself or the key works inv3mode. For a key inv2mode, the response to a request without theX-Crm-Apiheader is unchanged and carries no such header. - In
v3mode a request never silently falls back tov2. Whateverv3mode cannot do is refused with422 CRM_V3_UNSUPPORTEDand a hint to repeat the same request with theX-Crm-Api: v2header. Routes that do not see the mode run through the previous version and respond without theX-Crm-Apiheader. v3mode is available on every Bitrix24 account. It is turned on by theX-Crm-Api: v3header or by the key mode. If the Bitrix24 account does not have the new version of the Bitrix24 REST API (for example, an on-premise installation with an old REST module), a request inv3mode gets the same422 CRM_V3_UNSUPPORTEDrefusal with a hint to repeat it inv2mode.- Do not repeat a
v3write that stopped halfway. Some write operations take several Bitrix24 calls, for examplePOST /v1/deals/:id/contactswithisPrimary: true. If Bitrix24 refuses one of the later calls after the earlier ones have already saved their changes, the response is422 CRM_V3_PARTIALLY_APPLIEDwith noretryWithhint: repeating the request in either mode would apply the first part again.details.appliedStepslists the Bitrix24 calls that succeeded, anddetails.failedStepnames the call where the write stopped. Read the record and decide what to do next.
Which routes see the mode
The mode applies to the CRM entity routes: deals, contacts, companies, leads, smart processes, quotes, invoices, activities, requisites, bank details, addresses, requisite links, pipelines, CRM dictionaries and CRM user fields.
Other routes do not see the mode: they respond the same way regardless of the header and do not add the X-Crm-Api header to the response. Among them are currencies, smart process types, automated solutions and the product catalog: the new version of the Bitrix24 REST API has no methods of its own for them. For CRM entities, the main operations see the mode (list, read, create, update, delete, search, aggregation, field descriptions and import), and so do moving a record to another stage and the links between records. Other entity routes do not see the mode and run through the previous version: product rows /v1/{entity}/:id/products, lead conversion POST /v1/leads/:id/convert, record files and others. The X-Crm-Api header is not parsed on these routes: no value, not even an invalid one, changes the response, and the header is not added to the response. The absence of this header in the response shows that the previous version handled the request. Moving a record to another stage and the links between records (deal, lead and company contacts, a contact's companies) do see the mode: for a deal, contact or company they work in v3 mode (see the table below), while for a lead they are refused with 422 CRM_V3_UNSUPPORTED. Record import does see the mode: in v3 mode it is refused with 422 CRM_V3_UNSUPPORTED and a hint to repeat the request with the X-Crm-Api: v2 header. For activities, record activities /v1/{entity}/:id/activities, activity bindings, completing, rescheduling and postponing an activity, and to-dos /v1/activity-todos also see the mode. Which of them work in v3 mode is described in the v3 mode section of the activities page. Downloading an activity file, call transcripts and configurable activities do not see the mode.
These routes work in v3 mode today:
| Route | How it works in v3 mode |
|---|---|
RouteGET /v1/deals |
How it works in v3 modeFilter, sorting, limit, offset and meta.total. Records are read from Bitrix24 in pages of up to 1000. When the last page read is full, meta.total is counted by a separate request to Bitrix24 |
RouteGET /v1/deals/:id |
How it works in v3 modeWithout select, every field that has a counterpart in the new version is returned; with select, only the named fields |
RoutePOST /v1/deals/search |
How it works in v3 modeA date range in the filter is not split into windows: autoWindow has no effect in v3 mode |
RoutePOST /v1/deals/aggregate |
How it works in v3 modeComputes over the records read in v3 mode. Grouping by stageId and stageSemanticId is also computed over the records read, not by a separate count per stage |
RouteGET /v1/deals/aggregate |
How it works in v3 modeComputes the same way as POST /v1/deals/aggregate |
RoutePOST /v1/deals |
How it works in v3 modeCreates a deal. The response is the created deal, read in v3 mode |
RoutePATCH /v1/deals/:id |
How it works in v3 modeUpdates a deal. The response is the updated deal, read in v3 mode |
RouteDELETE /v1/deals/:id |
How it works in v3 modeDeletes a deal |
RoutePOST /v1/deals/:id/move |
How it works in v3 modeMoves a deal to another stage. The response is the deal after the move, read in v3 mode |
RouteGET /v1/deals/:id/contacts |
How it works in v3 modeDeal contacts without sort and roleId. The primary contact is first |
RoutePOST /v1/deals/:id/contacts |
How it works in v3 modeAdds a contact to the end of the list. With isPrimary: true, takes two Bitrix24 calls |
RoutePUT /v1/deals/:id/contacts |
How it works in v3 modeWrites the whole contact list, with the primary contact placed first |
RouteDELETE /v1/deals/:id/contacts/:relatedId |
How it works in v3 modeUnlinks a contact |
RouteDELETE /v1/deals/:id/contacts |
How it works in v3 modeUnlinks all contacts |
RouteGET /v1/contacts, GET /v1/companies |
How it works in v3 modeSame as for deals. Contacts from other pipelines and "my companies" are not in the list |
RouteGET /v1/contacts/:id, GET /v1/companies/:id |
How it works in v3 modeSame as for deals. Phones, emails and fm[] come back in the same shape as in v2 mode |
RoutePOST /v1/contacts/search, POST /v1/companies/search |
How it works in v3 modeSame as for deals |
RoutePOST /v1/contacts/aggregate, POST /v1/companies/aggregate |
How it works in v3 modeComputes over the records read in v3 mode |
RoutePOST /v1/contacts, POST /v1/companies |
How it works in v3 modeCreate. The response is the record read in v3 mode |
RoutePATCH /v1/contacts/:id, PATCH /v1/companies/:id |
How it works in v3 modeUpdate. Phones, emails, websites and messengers replace all values of their channel |
RouteDELETE /v1/contacts/:id, DELETE /v1/companies/:id |
How it works in v3 modeDelete |
RouteGET /v1/contacts/:id/companies |
How it works in v3 modeThe contact's companies, without sort and roleId. The primary one is the company in the contact's companyId |
RoutePOST /v1/contacts/:id/companies |
How it works in v3 modeAdds a company to the end of the list. isPrimary: true is refused |
RoutePUT /v1/contacts/:id/companies |
How it works in v3 modeWrites the whole list, with the primary company placed first |
RouteDELETE /v1/contacts/:id/companies/:relatedId, DELETE /v1/contacts/:id/companies |
How it works in v3 modeUnlinks one or all companies |
RouteGET /v1/companies/:id/contacts |
How it works in v3 modeCompany contacts, contactId only |
RoutePOST /v1/companies/:id/contacts, PUT /v1/companies/:id/contacts |
How it works in v3 modeAdds a contact or writes the whole list. isPrimary: true is refused |
RouteDELETE /v1/companies/:id/contacts/:relatedId, DELETE /v1/companies/:id/contacts |
How it works in v3 modeUnlinks one or all contacts |
RouteGET /v1/items/:entityTypeId, GET /v1/quotes, GET /v1/invoices |
How it works in v3 modeSame as GET /v1/deals |
RouteGET /v1/items/:entityTypeId/:id, GET /v1/quotes/:id, GET /v1/invoices/:id |
How it works in v3 modeSame as GET /v1/deals/:id |
RoutePOST /v1/items/:entityTypeId/search, POST /v1/quotes/search, POST /v1/invoices/search |
How it works in v3 modeSame as POST /v1/deals/search |
RoutePOST /v1/items/:entityTypeId/aggregate, POST /v1/quotes/aggregate, POST /v1/invoices/aggregate |
How it works in v3 modeSame as POST /v1/deals/aggregate |
RouteGET /v1/quotes/aggregate, GET /v1/invoices/aggregate |
How it works in v3 modeCompute the same way as POST /v1/deals/aggregate |
RoutePOST /v1/items/:entityTypeId, POST /v1/quotes, POST /v1/invoices |
How it works in v3 modeCreates a record. The response is the created record, read in v3 mode |
RoutePATCH /v1/items/:entityTypeId/:id, PATCH /v1/quotes/:id, PATCH /v1/invoices/:id |
How it works in v3 modeUpdates a record. The response is the updated record, read in v3 mode |
RouteDELETE /v1/items/:entityTypeId/:id, DELETE /v1/quotes/:id, DELETE /v1/invoices/:id |
How it works in v3 modeDeletes a record |
The routes of requisites, bank details, addresses and requisite links also work in v3 mode: reading, creating, updating and deleting, plus listing and searching within a single owner for requisites, bank details and addresses, and aggregation for requisites. In the new version, requisites and bank details belong to a contact or a company, so the first request for such a record may make up to two extra Bitrix24 calls to find the owner. The differences are described in the "v3 mode" sections of these entity pages.
The batch calls POST /v1/batch and POST /v1/{entity}/batch see the mode when they contain calls to CRM entities. In v3 mode the get, create, update and delete calls to these entities go to Bitrix24 as one batch of the new version and stop at the first error, while list and search run as separate requests — details are in the v3 mode section of the batch calls page. Related records of CRM entities from the include parameter are read in v3 mode as one batch of the new version. If the related entity has no read operation in v3 mode, the whole request gets 422 CRM_V3_UNSUPPORTED. Related records outside CRM, for example users, are read the same way as in v2 mode.
Activities in v3 mode can be read, deleted and completed, and record activities and bindings work: the list of routes is in the v3 mode section of the activities page.
CRM dictionaries DEAL_TYPE, SOURCE, CONTACT_TYPE, COMPANY_TYPE, INDUSTRY, EMPLOYEES and HONORIFIC also work in v3 mode: the list GET /v1/statuses, search POST /v1/statuses/search and aggregation POST /v1/statuses/aggregate with the filter[entityId] filter. How they differ is described in the v3 mode section of the CRM dictionaries page.
User fields of deals, leads, contacts, companies and quotes also work in v3 mode: list, get, create, update, delete and the type catalog. Operations on requisite fields, except the type catalog, are refused in v3 mode with 422 CRM_V3_UNSUPPORTED. The differences are described in the v3 mode section of the CRM fields page.
The differences in this mode are described in the v3 mode section of the deals, contacts, companies, smart processes, quotes and invoices pages. Every other operation on the listed entities that sees the mode returns 422 CRM_V3_UNSUPPORTED in v3 mode. Field descriptions from GET /v1/{entity}/fields are returned in v3 mode the same way as in v2 mode.
How the mode is chosen
The request mode comes from the first source that is set:
| Order | Source | Values |
|---|---|---|
| Order1 | SourceThe X-Crm-Api request header |
Valuesv2, v3, case-insensitive, surrounding spaces ignored |
| Order2 | SourceThe key mode | Valuesv2, v3: the crmApi block in the GET /v1/me response |
| Order3 | SourceDefault | Valuesv2 |
On a route that sees the mode, a header with any other value gets 400 INVALID_PARAMS. The key mode is switched in your Vibecode account: the "API Keys" section, "Edit" in the key menu, the "CRM API mode" block. The new mode takes effect with the key's next request. To run a single request in another mode without changing the key mode, send the X-Crm-Api header with it.
How to find the key mode
The GET /v1/me response for a key bound to a Bitrix24 account contains the data.crmApi block.
| Field | Type | Description |
|---|---|---|
Fieldmode |
Typestring | DescriptionKey mode: v2 or v3 |
FieldnewKeyMode |
Typestring | DescriptionThe mode in which new keys are created on this Bitrix24 account: v2 or v3 |
Fieldheader |
Typestring | DescriptionName of the header a request uses to choose its mode: X-Crm-Api |
Fieldoverride |
Typestring | DescriptionA hint about the header in the key owner's language |
{
"success": true,
"data": {
"crmApi": {
"mode": "v3",
"newKeyMode": "v2",
"header": "X-Crm-Api",
"override": "X-Crm-Api: v2|v3 — a request header on CRM routes; overrides the key mode."
}
}
}
Examples
Request a deal in v3 mode with the header. The JavaScript examples repeat the request in v2 mode if v3 mode refuses it with CRM_V3_UNSUPPORTED: getDeal(7, 'v3').
curl — personal key
curl -i "https://vibecode.bitrix24.com/v1/deals/7?select=title,amount,stageId" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "X-Crm-Api: v3"
curl — OAuth app
curl -i "https://vibecode.bitrix24.com/v1/deals/7?select=title,amount,stageId" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "X-Crm-Api: v3"
JavaScript — personal key
async function getDeal(id, mode) {
const res = await fetch(`https://vibecode.bitrix24.com/v1/deals/${id}?select=title,amount,stageId`, {
headers: { 'X-Api-Key': 'YOUR_API_KEY', ...(mode ? { 'X-Crm-Api': mode } : {}) },
})
const body = await res.json()
if (res.status === 422 && body.error?.code === 'CRM_V3_UNSUPPORTED') {
return getDeal(id, body.error.details.retryWith.value)
}
console.log('Response mode:', res.headers.get('X-Crm-Api'))
return body
}
JavaScript — OAuth app
async function getDeal(id, mode) {
const res = await fetch(`https://vibecode.bitrix24.com/v1/deals/${id}?select=title,amount,stageId`, {
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
...(mode ? { 'X-Crm-Api': mode } : {}),
},
})
const body = await res.json()
if (res.status === 422 && body.error?.code === 'CRM_V3_UNSUPPORTED') {
return getDeal(id, body.error.details.retryWith.value)
}
console.log('Response mode:', res.headers.get('X-Crm-Api'))
return body
}
The CRM_V3_UNSUPPORTED refusal
The refusal comes with status 422. error.message says what exactly v3 mode cannot do. error.details.retryWith names the header and value that make the same request run in v2 mode.
{
"success": false,
"error": {
"code": "CRM_V3_UNSUPPORTED",
"message": "Field \"probability\" has no counterpart in Bitrix24 REST v3.",
"hint": "Repeat the same request with the header X-Crm-Api: v2.",
"details": {
"retryWith": { "header": "X-Crm-Api", "value": "v2" }
}
}
}
A retry with X-Crm-Api: v2 applies to that request only: subsequent requests run in the key mode again.
An agent learns this rule from the API reference for the model: the GET /v1/guide response for a key with the crm scope contains the data.crmApiModes string — the order in which the mode is chosen and what to do on the refusal. In package versions newer than 3.4.7, the MCP server repeats such a request with X-Crm-Api: v2 itself and marks the result with the crmApiRetry field.
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe X-Crm-Api header on a route that sees the mode has a value other than v2 or v3 |
| HTTP422 | CodeCRM_V3_UNSUPPORTED |
DescriptionThe Bitrix24 account does not have the new version of the Bitrix24 REST API, or it has no method for this operation. The response carries X-Crm-Api: v3 |
| HTTP422 | CodeCRM_V3_UNSUPPORTED |
Descriptionv3 mode cannot serve this request: the operation, a field, a value format, a filter condition or the sort order. The response carries X-Crm-Api: v3 |
Other errors in v3 mode come with the same codes as in v2 mode: a missing record is 404 ENTITY_NOT_FOUND, missing permissions are 403 BITRIX_ACCESS_DENIED, an invalid field value is 400. The error text in this mode comes from the response of the new version of the Bitrix24 REST API. Full reference: Error codes.
What the new version of the Bitrix24 REST API cannot do
These requests are refused with 422 CRM_V3_UNSUPPORTED in v3 mode and run only in v2 mode:
- substring search in a filter,
- filtering by an empty value on fields other than the reference fields
companyId,contactIdandmycompanyId, - filtering and sorting by multiple-value fields, by the
utm*tracking tags, by the last-communication time fieldslastCommunication*Timeand by user fields of the typescrm,money,file,address,iblock_elementandiblock_section, - fields that have no counterpart in the new version, whether in
select, a filter, sorting or a write (for example,probabilityandadditionalInfoon a deal,isReturnCustomeron a lead), - creating and updating activities (except completion), to-dos, rescheduling and postponing an activity, and listing, searching and aggregating across all activities,
- listing and searching requisites, bank details and addresses without an owner in the filter, and listing and searching requisite links,
- statuses and stages of leads, quotes and smart invoices,
- getting, creating, updating and deleting a CRM dictionary record: it has no numeric
idin the new version.
See also
- Key self-description
- Deals: the v3 mode section
- Contacts: the v3 mode section
- Companies: the v3 mode section
- CRM dictionaries: the v3 mode section
- List deals
- Search deals
- Aggregate deals
- Recurring deals
- Filtering syntax
- Error codes