Tasks: typical scenarios
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
A scenario describes a single practical task and the sequence of methods required to perform it. In these tasks, scenarios show how to create a task, attach a file from Drive to it, add a comment with an attachment, and link a task to an SPA item.
Quick links: all scenarios
User documentation: Tasks in Bitrix24
Connection with Other Objects
Scenarios are built around a task and its related objects: Drive files, comments, and CRM. Creating and retrieving tasks is performed by the tasks.task.* method group.
-
Drive files. To attach a file to a task, first upload the file to Drive using the disk.folder.uploadfile method. The method returns a
IDof the Drive file. When creating a task, pass this identifier into theUF_TASK_WEBDAV_FILESfield of the tasks.task.add method with thenprefix, for examplen6687. If the task has already been created, attach the file using the tasks.task.files.attach method: to thefileIdparameter, pass theIDof the file without a prefix, for example6687 -
Comments. The How to create a comment in a task and attach a file to it scenario uses the task.commentitem.add method. The method continues to add comments, but its development has been halted since module version
tasks 25.700.0. For new integrations with a task chat, use tasks.task.chat.message.send, and send files using the im.disk.file.commit method -
CRM and SPAs. A task is linked to CRM objects via the
UF_CRM_TASKfield of the tasks.task.add method. The field stores an array of identifiers of linked CRM objects: leads, deals, contacts, companies, or SPA items.For an SPA, the
UF_CRM_TASKvalue is composed ofSYMBOL_CODE_SHORT— the object type code — and theiditem returned by the crm.item.list method:- Retrieve
entityTypeIdandSYMBOL_CODE_SHORTusing the crm.enum.ownertype method - Pass
entityTypeIdinto crm.item.list to find the SPA item and retrieve itsid - Pass the value into
UF_CRM_TASKin theSYMBOL_CODE_SHORT_idformat, for exampleTb1_29, whereTb1is theSYMBOL_CODE_SHORTvalue, and29is theiditem
- Retrieve
Getting Started
- Define the scenario: create a task with a file, attach a file to an existing task, add a comment with a file, or link a task to an SPA
- Select a scenario in the How to choose a scenario table
- Check which permissions and scopes are specified in the selected scenario
- Prepare the task, Drive file, user, or CRM item identifiers required for the scenario
- Execute the methods in the order described in the scenario
How to choose a scenario
|
If necessary |
Open |
|
Create a task and immediately attach a file from the Drive to it |
|
|
Upload a file to the Drive and attach it to an existing task |
|
|
Add a comment to a task using the task.commentitem.add method and attach a file to it |
|
|
Create a task linked to an SPA item |
|
|
View the full task methods reference |