لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/mail.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Bitrix24 account mail: receiving and sending messages, managing mailboxes, and converting incoming messages into tasks, events, chats, and posts.
Scope: mail · Base URL: https://vibecode.bitrix24.com/v1 · Authorization: X-Api-Key header
Documentation sections
- Mailboxes — list, get, senders (3 endpoints)
- Messages — list, read, thread, send, reply, forward, move (7 endpoints)
- Creating objects from a message — task, event, chat, post, CRM binding and its deletion (6 endpoints)
- Recipients — search contacts and employees (2 endpoints)
Quick start
Two calls to confirm the API works: get the list of mailboxes and the first messages.
curl
# List of mailboxes
curl "https://vibecode.bitrix24.com/v1/mail/mailboxes" \
-H "X-Api-Key: YOUR_API_KEY"
# Messages in the specified mailbox
curl "https://vibecode.bitrix24.com/v1/mail/messages?mailboxId=5" \
-H "X-Api-Key: YOUR_API_KEY"
JavaScript
const BASE = 'https://vibecode.bitrix24.com/v1'
const headers = { 'X-Api-Key': 'YOUR_API_KEY' }
const mbRes = await fetch(`${BASE}/mail/mailboxes`, { headers })
const { data: mailboxes } = await mbRes.json()
const mailboxId = mailboxes[0].id
const msgsRes = await fetch(`${BASE}/mail/messages?mailboxId=${mailboxId}`, { headers })
const { data } = await msgsRes.json()
console.log(`Messages in mailbox: ${data.items.length}`)
Full example
A JavaScript scenario — seven steps: get the list of mailboxes, find the sender address, send a message, read it, reply, and create a task.
const BASE = 'https://vibecode.bitrix24.com/v1'
const HEADERS = { 'X-Api-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' }
async function api(method, path, body = null) {
const opts = { method, headers: HEADERS }
if (body) opts.body = JSON.stringify(body)
return (await fetch(`${BASE}${path}`, opts)).json()
}
// 1. List of mailboxes → mailboxId
const { data: mailboxes } = await api('GET', '/mail/mailboxes')
const mailboxId = mailboxes[0].id
// 2. Mailbox sender addresses → from string
const { data: sendersData } = await api('GET', `/mail/mailboxes/${mailboxId}/senders`)
const from = sendersData.items[0].sender // "Name <user@example.com>"
// 3. Send a message
const sendRes = await api('POST', '/mail/messages', {
from,
to: ['colleague@example.com'],
subject: 'Integration request',
body: 'Hello, please clarify the details.',
})
// → { success: true, data: { success: true, to: ["colleague@example.com"] } }
console.log('Sent:', sendRes.data.to)
// 4. Find the message in the mailbox → id
const { data: msgsData } = await api('GET', `/mail/messages?mailboxId=${mailboxId}&limit=5`)
const messageId = msgsData.items[0].id
// 5. Get the full message text (data.item field)
const { data: msgData } = await api('GET', `/mail/messages/${messageId}`)
console.log('Subject:', msgData.item.subject, '| Body:', msgData.item.body)
// 6. Reply to the message — the message is specified in the path
const replyRes = await api('POST', `/mail/messages/${messageId}/reply`, {
from,
to: ['colleague@example.com'],
subject: `Re: ${msgData.item.subject}`,
body: 'Thanks, clarification received.',
})
// → { success: true, data: { success: true, to: ["colleague@example.com"] } }
console.log('Reply sent:', replyRes.data.to)
// 7. Create a task from the message
const taskRes = await api('POST', `/mail/messages/${messageId}/task`, {
title: 'Process the incoming request',
})
// → { success: true, data: { success: true, taskId: 100, messageId: 1000 } }
console.log('Task created, id:', taskRes.data.taskId)
Endpoint reference
Mailboxes:
| Method | Path | Bitrix24 method | Description |
|---|---|---|---|
| MethodGET | Path/v1/mail/mailboxes |
Bitrix24 methodmail.mailbox.list | DescriptionList of mailboxes |
| MethodGET | Path/v1/mail/mailboxes/:id |
Bitrix24 methodmail.mailbox.get | DescriptionGet a mailbox |
| MethodGET | Path/v1/mail/mailboxes/:id/senders |
Bitrix24 methodmail.mailbox.senders | DescriptionMailbox sender addresses |
Messages:
| Method | Path | Bitrix24 method | Description |
|---|---|---|---|
| MethodGET | Path/v1/mail/messages |
Bitrix24 methodmail.message.list | DescriptionList of messages |
| MethodGET | Path/v1/mail/messages/:id |
Bitrix24 methodmail.message.get | DescriptionGet a message |
| MethodGET | Path/v1/mail/messages/:id/thread |
Bitrix24 methodmail.message.thread | DescriptionConversation thread |
| MethodPOST | Path/v1/mail/messages |
Bitrix24 methodmail.message.send | DescriptionSend a message |
| MethodPOST | Path/v1/mail/messages/:id/reply |
Bitrix24 methodmail.message.reply | DescriptionReply to a message |
| MethodPOST | Path/v1/mail/messages/:id/forward |
Bitrix24 methodmail.message.forward | DescriptionForward a message |
| MethodPOST | Path/v1/mail/messages/move |
Bitrix24 methodmail.message.movetofolder | DescriptionMove messages |
Creating objects from a message:
| Method | Path | Bitrix24 method | Description |
|---|---|---|---|
| MethodPOST | Path/v1/mail/messages/:id/task |
Bitrix24 methodmail.message.createtask | DescriptionCreate a task from a message |
| MethodPOST | Path/v1/mail/messages/:id/calendar-event |
Bitrix24 methodmail.message.createcalendarevent | DescriptionCreate an event from a message |
| MethodPOST | Path/v1/mail/messages/:id/chat |
Bitrix24 methodmail.message.createchat | DescriptionCreate a chat from a message |
| MethodPOST | Path/v1/mail/messages/:id/feed-post |
Bitrix24 methodmail.message.createfeedpost | DescriptionCreate a Feed post |
| MethodPOST | Path/v1/mail/messages/:id/crm-activity |
Bitrix24 methodmail.message.createcrmactivity | DescriptionBind a message to CRM |
| MethodDELETE | Path/v1/mail/messages/:id/crm-activity |
Bitrix24 methodmail.message.removecrmactivity | DescriptionDelete a CRM activity from a message |
Recipients:
| Method | Path | Bitrix24 method | Description |
|---|---|---|---|
| MethodPOST | Path/v1/mail/recipients/contacts |
Bitrix24 methodmail.recipient.listcontacts | DescriptionSearch CRM contacts |
| MethodPOST | Path/v1/mail/recipients/employees |
Bitrix24 methodmail.recipient.listemployees | DescriptionSearch Bitrix24 account employees |
Error codes
Mail errors
| Code | HTTP | Description |
|---|---|---|
CodeSCOPE_DENIED |
HTTP403 | DescriptionThe key has no mail scope |
CodeTOKEN_MISSING |
HTTP401 | DescriptionThe key has no Bitrix24 tokens configured |
CodeINVALID_PARAMS |
HTTP400 | Description:id or :mailboxId is not a positive integer |
CodeINVALID_PARAMS |
HTTP400 | DescriptionBitrix24 rejected the request parameters during validation |
CodeNOT_FOUND |
HTTP404 | DescriptionUnknown action (action endpoints only) |
CodeENTITY_NOT_FOUND |
HTTP404 | DescriptionMessage or mailbox not found in Bitrix24 |
CodeBITRIX_ACCESS_DENIED |
HTTP403 | DescriptionNo permission to access the mailbox or message in Bitrix24 |
CodeRATE_LIMITED |
HTTP429 | DescriptionRequest limit exceeded (header Retry-After: 2) |
CodeBITRIX_UNAVAILABLE |
HTTP502 | DescriptionBitrix24 returned a 5xx error |
CodeBITRIX_ERROR |
HTTP422 | DescriptionOther Bitrix24 errors |
System errors
| Code | HTTP | Description |
|---|---|---|
CodeMISSING_API_KEY |
HTTP401 | DescriptionThe X-Api-Key header was not provided |
CodeINVALID_API_KEY |
HTTP401 | DescriptionThe key is not recognized — no such key exists on the platform |
CodeKEY_INACTIVE |
HTTP401 | DescriptionThe key is deactivated |
CodeKEY_EXPIRED |
HTTP401 | DescriptionThe key has expired |
Full list of common API errors — Errors.