---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/api-reference/receive-emails/send-trust/send-email

Receive Emails: Send & trust

# Send Email

Send a new email from the sender behind your token. The message is saved to Sent right away and delivered in the background.

POST `https://g.sendcorex.com/v1` command: send_email

`queued: true` means saved and waiting in the queue, not delivered. The `message_id` in the response is provisional: the real SMTP Message-ID replaces it a few seconds later and shows up in `get_messages`.

Each recipient (to + cc + bcc) gets their own copy and uses 1 credit. Bcc addresses never appear in the headers. The body is limited to 2 MB, attachments to 25 MB in total.

Recipients who refused tracking on the preferences page are never tracked, even with `true`.

Emails sent from the mailbox carry no List-Unsubscribe header or unsubscribe link unless you send `unsubscribe: true`, because they are personal emails.

Everyone who receives an email from the mailbox becomes a contact in the account’s “Webmail” list and is trusted in this mailbox: their replies go to the Inbox and the address shows up in autocomplete. Senders the mailbox blocked stay blocked.

With `unsubscribe: true`, recipients who already unsubscribed from this mailbox are refused with `RECIPIENT_UNSUBSCRIBED`, and `recipients` lists them. Replies are never blocked.

## Arguments

- `to` string | string[] required
Recipient address, or an array of up to 30 addresses (paid plans). With `unsubscribe: true` each person gets their own copy; without it, everyone in `to` and `cc` sees each other.
- `to_name` string optional
Recipient name. Defaults to the part before the `@`.
- `subject` string required
Email subject.
- `html` string optional
HTML body. Send `html` or `text`.
- `text` string optional
Plain text body. It is converted to HTML with `<br>`.
- `cc` string[] optional
Visible copies. to + cc + bcc up to 50 addresses.
- `bcc` string[] optional
Hidden copies. They never appear in the headers.
- `template_id` string optional
Fill the body (and an empty subject) from a template. Placeholders use `to_name` and `variables`.
- `variables` object optional
Your own template placeholders: `{ "company": "Acme" }` fills `{company}`.
- `attachments` object[] optional
Files: `[{ file_name, content, content_type }]`, `content` in base64. Up to 20 files, 25 MB in total. Every file is scanned.
- `compose_uid` string optional
Attachments uploaded before with `upload_attachment`.
- `attachment_ids` string[] optional
Which uploaded attachments to send. Without it, all of them.
- `followup_at` string optional
Remind you if nobody replies by this date (RFC 3339, `YYYY-MM-DD` or epoch ms).
- `label` string optional
A label to put on the sent message. It becomes `labels: [label]`.
- `track_opens` boolean optional
Track when each recipient opens the email (invisible pixel). Default `true`.
- `track_clicks` boolean optional
Track clicks on the links (each link goes through a redirect). Default `true`.
- `unsubscribe` boolean optional
Add an unsubscribe link. Put `[unsubscribe]` in the body (as a link `href` or as plain text) where the link should go; without it, a default line is added at the end. Default `false`.
- `idempotency_key` string optional
Your own key for this email (1–255 characters: letters, numbers, `_ - : .`), valid for 24 hours. A retry with the same key and the same args returns the first result with `idempotent_replayed: true`, and nothing is sent again.
- `audience` string optional
Send to an audience instead of addresses: `subscribed`, `opened`, `clicked`, `both`, `seg:<segment_id>` or `msg:<message_uid>:opened|clicked|not_opened`. `to` becomes optional. Up to 5,000 people. The unsubscribe link is turned on and the email goes out as marketing. Paid plans.

Retrying? Use an idempotency key so the email is never sent twice. [Idempotency →](https://docs.sendcorex.com/idempotency)

## Quick start

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "send_email",
        args: {
          to: "client@example.com",
          to_name: "Client",
          cc: [
            "manager@example.com"
          ],
          subject: "Quote",
          html: "<p>Here is the quote.</p>",
          attachments: [
            {
              file_name: "quote.pdf",
              content: "JVBERi0xLjcKJcfsj6IK…",
              content_type: "application/pdf"
            }
          ],
          followup_at: "2026-10-29T09:00:00+08:00",
          label: "sales"
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);
```

## Response

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "send_email",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "message_uid": "Vj0xQUJDMTIz",
        "thread_id": "thr_9a1c4e72",
        "message_id": "<5e0b9c1a-3d7f-4a21-9a6e-2f1c8d4b7e90>",
        "recipients": 2,
        "queued": true
      }
    }
  ]
}
```

### Response fields

- `message_uid`
The id of the sent message. It appears in `Sent` immediately.
- `thread_id`
The conversation of the new message.
- `message_id`
A provisional Message-ID. The real SMTP one replaces it shortly after.
- `recipients`
How many copies were queued (to + cc + bcc), 1 credit each.
- `queued`
`true` = saved and queued for delivery. It does not mean delivered.
- `idempotent_replayed`
Only on a retry: `true` when this is the stored result of an earlier call with the same `idempotency_key`. Nothing was sent again.

## Repeated sends

The same write (same args) repeated within 1.5 seconds returns the first result instead of sending again. A polling loop that sends the same email twice does not duplicate it.

## Safe retries

Always send an `idempotency_key` (for example a UUID per email). If a call times out, retry with the same key: the email is never sent twice. Only a successful send is stored, so if the send failed, a retry with the same key runs again. Keys are per mailbox: the same key in another mailbox or in `POST /v3.0/send` does not conflict.

Request body

```
{
  "commands": [
    {
      "command": "send_email",
      "args": {
        "idempotency_key": "order-1234-confirmation",
        "to": "ana@example.com",
        "subject": "Your order",
        "html": "<p>Thanks!</p>"
      }
    }
  ]
}
```

## Errors

HTTP-level errors return `type`, `code` and `message`. Errors marked CMD come back inside the command result, with HTTP 200.

- 401`TOKEN_EXPIRED`
The access token has expired. Call Refresh Token and repeat the request.
- 401`INVALID_TOKEN`
The token is malformed, unknown or revoked.
- 429`RATE_LIMITED`
More than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.
- CMD`INVALID_IDEMPOTENCY_KEY`
`idempotency_key` must have 1–255 characters: letters, numbers, `_ - : .`.
- CMD`IDEMPOTENCY_KEY_REUSED`
This `idempotency_key` was already used with different args. Use a new key for every new email.
- CMD`IDEMPOTENCY_IN_PROGRESS`
A call with the same `idempotency_key` is still running. Try again in 1 second with the same key.
- CMD`INVALID_AUDIENCE`
The audience is not valid: unknown group, a segment of another mailbox or a message this mailbox didn’t send.
- CMD`AUDIENCE_OVER_LIMIT`
The audience has more people than you can send to (up to 5,000 per email and your daily limit). `total` and `allowed` say how many.
- CMD`EMPTY_AUDIENCE`
Nobody in this audience right now.
- CMD`RECIPIENT_UNSUBSCRIBED`
One or more recipients unsubscribed from this mailbox. `recipients` lists them: remove them or send again with `unsubscribe: false`.
- CMD`PAID_PLAN_REQUIRED`
More than one address in `to` needs a paid plan.
- CMD`TOO_MANY_RECIPIENTS`
`to` has more than 30 addresses.
- CMD`INVALID_ARGS`
A required argument is missing or invalid.
- CMD`INVALID_TOADDRESS`
The to address is not a valid email.
- CMD`INVALID_CCADDRESS`
One of the cc addresses is not a valid email.
- CMD`INVALID_BCCADDRESS`
One of the bcc addresses is not a valid email.
- CMD`RECIPIENT_LIMIT_EXCEEDED`
to, cc and bcc together have more than 50 addresses.
- CMD`INVALID_ATTACHMENT`
An attachment content is not valid base64.
- CMD`FILE_BLOCKED`
A file was blocked by the security scan.
- CMD`ATTACHMENTS_TOO_LARGE`
The attachments of the email add up to more than 25 MB, or the mailbox already has 500 MB of uploads waiting to be sent.
- CMD`ATTACHMENT_MISSING`
An uploaded attachment no longer exists (uploads not sent within 48 hours, and not used by a draft or scheduled email, are deleted). Upload it again.
- CMD`NO_CREDITS`
The account has fewer email credits than recipients (1 credit per copy).
- CMD`SENDER_NOT_FOUND`
The sender behind the token is not registered.
- CMD`SENDER_NO_DOMAIN`
The sender behind the token has no domain.
- CMD`INTERNAL`
Server error. The detail is only written to the server log.
