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

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

Create objects from a message

Create objects in your Bitrix24 account from an incoming message: task, event, chat, post, and a link to a CRM activity. A created CRM activity can be deleted.

Bitrix24 API: mail.message.create*, mail.message.removecrmactivity Scope: mail

Create a task from a message

POST /v1/mail/messages/:id/task

Creates a task from a message. The message identifier is taken from the path. The request body sets only the task fields and may be empty.

Parameters

Parameter In Type Required Description
Parameterid Inpath Typeinteger Requiredyes DescriptionIdentifier of the message the task is created from. List: GET /v1/mail/messages

Request body fields

Field Type Required Description
Fieldtitle Typestring Requiredno DescriptionTask title. Defaults to the message subject
FieldresponsibleId Typeinteger Requiredno DescriptionIdentifier of the responsible person. List: GET /v1/users. Defaults to the current user
Fielddescription Typestring Requiredno DescriptionTask description

Examples

curl — personal key

Terminal
curl -X POST \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Process the client request"}' \
  https://vibecode.bitrix24.com/v1/mail/messages/123/task

curl — OAuth application

Terminal
curl -X POST \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "Process the client request"}' \
  https://vibecode.bitrix24.com/v1/mail/messages/123/task

JavaScript — personal key

javascript
const res = await fetch(
  'https://vibecode.bitrix24.com/v1/mail/messages/123/task',
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ title: 'Process the client request' }),
  }
)
const body = await res.json()
if (!body.success) throw new Error(body.error.code)
console.log(`Task created: ${body.data.taskId}`)

JavaScript — OAuth application

javascript
const res = await fetch(
  'https://vibecode.bitrix24.com/v1/mail/messages/123/task',
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ title: 'Process the client request' }),
  }
)

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue on successful creation
Fielddata.success Typeboolean DescriptionInternal operation success flag
Fielddata.taskId Typeinteger DescriptionIdentifier of the created task
Fielddata.messageId Typeinteger DescriptionIdentifier of the message the task was created from

Response example

JSON
{
  "success": true,
  "data": {
    "success": true,
    "taskId": 4567,
    "messageId": 123
  }
}

Error response example

400 — message not found:

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Request object validation failed",
    "validation": [
      {
        "message": "The message was deleted or moved to another folder"
      }
    ]
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionNon-numeric or negative :id in the path — message id must be a positive integer
HTTP400 CodeINVALID_PARAMS DescriptionThe message was deleted or moved to another folder. The reason is in the validation array
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is missing
HTTP401 CodeINVALID_API_KEY DescriptionThe key is not recognized — no such key exists on the platform
HTTP401 CodeKEY_INACTIVE DescriptionKey is deactivated
HTTP401 CodeKEY_EXPIRED DescriptionKey has expired
HTTP401 CodeTOKEN_MISSING DescriptionKey is not linked to a Bitrix24 portal
HTTP403 CodeSCOPE_DENIED DescriptionKey lacks the mail scope
HTTP422 CodeBITRIX_ERROR DescriptionOther Bitrix24 errors
HTTP429 CodeRATE_LIMITED DescriptionRequest limit exceeded
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 is unavailable

Full list of common API errors — Errors.

Known specifics

  • The task is populated with only the title, responsible person, description, and the link to the message. If the Bitrix24 account has required task user fields configured, creation fails with an error.

See also