لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/automation/workflows.md فهرس التوثيق — /llms.txt

مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.

Workflows

A workflow is a multi-step scenario that runs on a Bitrix24 document. Unlike CRM triggers, which change an entity's state instantly, a workflow can include pauses to wait for external events, conditional branching, parallel branches, and delays. Typical scenarios: approval chains, automatic document preparation, scheduled notifications.

Lifecycle: launch (start) → execution → instance inspection (list) → pause handling via an event (event) or a log entry (activity-log) → termination (terminate).

Bitrix24 API: bizproc.workflow.*, bizproc.event.*, bizproc.activity.* Scope: bizproc

Start a workflow

POST /v1/workflows/start

Starts a workflow instance from a template for a CRM entity, a list element or another Bitrix24 document. The document is given in one of two shapes: a type and ID for a deal, lead, contact or company, or an explicit Bitrix24 document identifier for everything else.

Request fields (body)

Pass templateId and exactly one document shape. A body that carries entityType or entityId together with documentId is rejected with 400 CONFLICTING_PARAMS.

Field Type Required Description
FieldtemplateId Typenumber Requiredyes DescriptionWorkflow template ID. Source: GET /v1/bizproc-templates
FieldentityType Typestring Requiredno DescriptionCRM entity type: deal, lead, contact, company. Required together with entityId when documentId is not passed
FieldentityId Typenumber Requiredno DescriptionCRM entity ID. Required together with entityType when documentId is not passed. Source: GET /v1/deals, GET /v1/leads, GET /v1/contacts, GET /v1/companies
FielddocumentId Typearray Requiredno DescriptionBitrix24 document as an array of three non-empty strings [module, class, identifier]. Required when entityType and entityId are not passed. The module is crm, lists or disk. Pass the identifier as a string: a number in the third element is rejected. Values for CRM and lists are in the table below
Fieldparameters Typeobject Requiredno DescriptionTemplate parameter values. The set of fields is defined by the specific template in Bitrix24

documentId values by module:

Module Class Identifier Example
Modulecrm ClassCCrmDocumentDeal, CCrmDocumentLead, CCrmDocumentContact, CCrmDocumentCompany IdentifierType prefix plus entity ID: DEAL_5141, LEAD_12 Example["crm", "CCrmDocumentDeal", "DEAL_5141"]
Modulelists ClassBitrix\Lists\BizprocDocumentLists IdentifierElement ID of an ordinary list. Source: GET /v1/lists/:iblockId/elements Example["lists", "Bitrix\\Lists\\BizprocDocumentLists", "7147"]
Modulelists ClassBizprocDocument IdentifierElement ID of a process in the Feed, infoblock type bitrix_processes. Source: GET /v1/lists/:iblockId/elements?iblockTypeId=bitrix_processes Example["lists", "BizprocDocument", "7171"]

The class is the second element of the template's documentType in the GET /v1/bizproc-templates response, and the iblockId for the element source is the number in the third element, iblock_<id>. Pass the class as is: an ordinary list and a process in the Feed share the module lists, but their classes differ. Templates can be read only with an OAuth app key. If your template request passes select, include moduleId and entity in it, otherwise the first two elements of documentType come back as null.

The class and the identifier are passed to Bitrix24 unchanged. In JSON, escape the backslash in the class name by doubling it, as in the Bitrix\Lists\BizprocDocumentLists example.

Examples

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/workflows/start \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"templateId":713,"entityType":"deal","entityId":5141}'

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/workflows/start \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"templateId":713,"entityType":"deal","entityId":5141}'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/workflows/start', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    templateId: 713,
    entityType: 'deal',
    entityId: 5141,
  }),
})
const data = await res.json()
console.log(data.data.workflowId)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/workflows/start', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    templateId: 713,
    entityType: 'deal',
    entityId: 5141,
  }),
})
const data = await res.json()

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue on a successful start
Fielddata.workflowId Typestring DescriptionUnique identifier of the started workflow instance

Response example

HTTP 201 Created

JSON
{
  "success": true,
  "data": {
    "workflowId": "69f0c2d5ade389.22457798"
  }
}

Error response example

400 — both document shapes in one body:

JSON
{
  "success": false,
  "error": {
    "code": "CONFLICTING_PARAMS",
    "message": "Pass either { entityType, entityId } OR { documentId }, not both. Pick the shape that matches your target document namespace."
  }
}

Errors

HTTP Code Description
HTTP400 CodeMISSING_PARAMS DescriptiontemplateId was not provided
HTTP400 CodeMISSING_PARAMS DescriptiondocumentId was not provided and the CRM shape is incomplete: entityType or entityId is missing
HTTP400 CodeCONFLICTING_PARAMS DescriptionentityType or entityId was passed together with documentId
HTTP400 CodeINVALID_DOCUMENT_ID DescriptiondocumentId is not an array, does not have three elements, or one of the elements is empty or not a string
HTTP400 CodeINVALID_DOCUMENT_ID DescriptionThe module in documentId is not crm, lists or disk
HTTP400 CodeINVALID_ENTITY_TYPE DescriptionentityType is not deal, lead, contact or company. For other documents, use documentId
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header was not provided
HTTP401 CodeINVALID_API_KEY DescriptionThe key is not recognized — no such key exists on the platform
HTTP401 CodeTOKEN_MISSING DescriptionThe key has no connected Bitrix24 tokens
HTTP401 CodeTOKEN_EXPIRED DescriptionThe OAuth user session expired — re-authorize via /v1/oauth/authorize
HTTP403 CodeSCOPE_DENIED DescriptionThe key is missing the bizproc scope
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionBitrix24 denied access
HTTP409 CodeBIZPROC_MODULE_NOT_ENABLED DescriptionBusiness Processes are not available on the account: the module is not included in the plan, or it is switched off in account settings. Ask an account administrator to enable Business Processes — until then the method answers the same way for any number of retries
HTTP422 CodeBITRIX_ERROR DescriptionNo template with the given templateId was found. message is Template not found
HTTP422 CodeBITRIX_ERROR DescriptionThe class in documentId does not match the template's document type. message is Template type and DOCUMENT_ID mismatch!
HTTP422 CodeBITRIX_ERROR DescriptionThere is no document with the identifier from the third element of documentId: the document does not exist, or a value other than its ID was passed, for example iblock_<id> from the template's documentType. message is Wrong DOCUMENT_ID!
HTTP429 CodeRATE_LIMITED DescriptionRequest limit exceeded. Retry in 1–2 seconds
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 is unavailable

Full list of common API errors — Errors.

Known specifics

  • One template — multiple instances. The same templateId can be started for different entities simultaneously. Each start receives its own unique workflowId.
  • A repeated call starts another instance. A request with the same body is not rejected and does not return the already running workflow: every 201 means a new instance on the same document. If a request may have gone through but the response was lost, check the list of running workflows before retrying. It shows only active instances: a workflow that has already finished does not appear there. No Vibecode API method returns finished instances, so an empty list does not prove that the workflow was never started.

See also