For AI agents: markdown of this page — /docs-content-en/mail/conversions/crm-activity-create.md documentation index — /llms.txt
Create a CRM activity from a message
POST /v1/mail/messages/:id/crm-activity
Creates a CRM activity from a message and links the message to CRM. No request body is required — the message identifier is taken from the path.
Parameters
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Parameterid |
Inpath | Typeinteger | Requiredyes | DescriptionMessage identifier. List: GET /v1/mail/messages |
Examples
curl — personal key
curl -X POST \
-H "X-Api-Key: YOUR_API_KEY" \
https://vibecode.bitrix24.com/v1/mail/messages/123/crm-activity
curl — OAuth application
curl -X POST \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
https://vibecode.bitrix24.com/v1/mail/messages/123/crm-activity
JavaScript — personal key
const res = await fetch(
'https://vibecode.bitrix24.com/v1/mail/messages/123/crm-activity',
{
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
},
}
)
const body = await res.json()
if (!body.success) throw new Error(body.error.code)
console.log(`Activity created: ${body.data.result}`)
JavaScript — OAuth application
const res = await fetch(
'https://vibecode.bitrix24.com/v1/mail/messages/123/crm-activity',
{
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
}
)
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | Descriptiontrue on success |
Fielddata.result |
Typeboolean | Descriptiontrue when the CRM activity is created |
Response example
{
"success": true,
"data": {
"result": true
}
}
Error response example
400 — the message is from an employee of the Bitrix24 account:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "Request object validation failed",
"validation": [
{
"message": "Emails to employees cannot be saved to CRM"
}
]
}
}
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 is from a Bitrix24 account employee or the message is deleted. 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 |
DescriptionThe key is deactivated |
| HTTP401 | CodeKEY_EXPIRED |
DescriptionThe key has expired |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe key is not linked to a Bitrix24 account |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key lacks the mail scope |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionOther Bitrix24 errors |
| HTTP429 | CodeRATE_LIMITED |
DescriptionRequest limit exceeded |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionBitrix24 is unavailable |
The full list of common API errors — Errors.
Known specifics
- An activity is created only for messages from external senders.
- A repeated call for a message that already has an activity returns the same successful response and does not create a second activity — the operation is idempotent.