## Send a CRM e-mail

`POST /v1/deals/:id/emails`

`POST /v1/leads/:id/emails`

`POST /v1/contacts/:id/emails`

`POST /v1/companies/:id/emails`

Send a real e-mail from CRM using an available sender. The e-mail is linked to the specified CRM record.

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` (path) | integer | yes | Record identifier from [deals](/docs/entities/deals), [leads](/docs/entities/leads), [contacts](/docs/entities/contacts) or [companies](/docs/entities/companies). |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `to` | string[] | yes | Primary recipients. |
| `subject` | string or null | no | E-mail subject. |
| `body` | string | yes | E-mail body. |
| `cc` | string[] or null | no | CC recipients. |
| `bcc` | string[] or null | no | BCC recipients. |
| `from` | string or null | no | Available sender address. |
| `senderId` | integer or null | no | Sender identifier accepted by Bitrix24. |
| `mailboxId` | integer or null | no | Identifier from [mailboxes](/docs/mail/mailboxes/list). |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/deals/741/emails" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to": ["reader@example.com"], "body": "Hello", "subject": "Integration request"}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/deals/741/emails" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"to": ["reader@example.com"], "body": "Hello", "subject": "Integration request"}'
```

### JavaScript — personal key

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/deals/741/emails', {
  method: 'POST',
  headers: {"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
  body: JSON.stringify({"to": ["reader@example.com"], "body": "Hello", "subject": "Integration request"}),
})
const result = await response.json()
```

### JavaScript — OAuth application

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/deals/741/emails', {
  method: 'POST',
  headers: {"X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN", "Content-Type": "application/json"},
  body: JSON.stringify({"to": ["reader@example.com"], "body": "Hello", "subject": "Integration request"}),
})
const result = await response.json()
```

## Response fields

| Field | Description |
|---|---|
| `data.activityId` | Created activity identifier. Read it through [e-mail content](./get.md). |
| `data.parentActivityId` | Original activity identifier, or `null`. |
| `data.from` | Sender. |
| `data.to` | Primary recipients. |
| `data.cc` | CC recipients. |
| `data.bcc` | BCC recipients. |
| `data.isSyncedToImap` | Whether a copy was saved in the connected mailbox. |
| `data.warnings` | Sending and synchronization warnings. |

## Response example

Response structure with neutral sample data.

```json
{
  "success": true,
  "data": {
    "activityId": 1204,
    "parentActivityId": null,
    "from": "sender@example.com",
    "to": [
      "reader@example.com"
    ],
    "cc": [],
    "bcc": [],
    "isSyncedToImap": false,
    "warnings": []
  }
}
```

## Error response example

400 — unknown query parameter or a missing required field:

```json
{
  "success": false,
  "error": {
    "code": "MISSING_REQUIRED_FIELDS",
    "message": "to and body are required"
  }
}
```

## Errors

| HTTP | Code | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | Invalid type or identifier. |
| 400 | `UNKNOWN_FILTER_FIELD` | Unknown query parameter. |
| 400 | `MISSING_REQUIRED_FIELDS` | Missing required body field. |
| 400 | `UNKNOWN_FIELD` | Unknown body field. |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 credentials. |
| 403 | `SCOPE_DENIED` | The `crm` scope is required. |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key access mode forbids writes. |
| 404 | `ENTITY_NOT_FOUND` | The record is absent or inaccessible. |
| 404 | `CRM_EMAIL_ACTIVITY_NOT_FOUND` | The e-mail activity was not found. |
| 422 | `METHOD_NOT_YET_AVAILABLE` | The method is absent on the account. `error.release` names the required release. |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned an invalid response shape. |

Other Bitrix24 refusals retain their original code and message. Common [API errors](/docs/errors).

## Known behavior

These are CRM activity e-mails. The [Mail module](/docs/mail) uses different message identifiers.

Never blindly retry after a timeout, interrupted response or 502: the real e-mail may already have been sent. Read the e-mail list first.

## See also

- [CRM settings](/docs/entities/crm-settings)
- [CRM e-mails](/docs/entities/crm-emails)
