Queues one email and returns its ID. Works with sending and full keys.
Body
Send a JSON object with Content-Type: application/json.
| Field | Type | Description |
|---|---|---|
from | string, required | Sender, as hello@acme.com or Acme <hello@acme.com>. In live mode it must be on a verified domain or a verified sender address. |
to | string or array, required | Recipient or recipients. Up to 50 recipients across to, cc and bcc. |
subject | string, required | Up to 998 characters. |
html | string | HTML body. |
text | string | Plain text body. Send html, text or both. When you send only HTML, a text part is generated at delivery. |
cc | string or array | Carbon copy recipients. |
bcc | string or array | Blind carbon copy recipients. |
reply_to | string or array | Reply-To addresses. replyTo is also accepted. |
headers | object | Custom headers, for example {"X-Entity-Ref-ID": "1042"}. Header names may contain letters, numbers and dashes. Headers that have their own field (From, To, Subject…) cannot be set here. |
tags | array | Up to you: [{"name": "category", "value": "receipt"}]. Names and values may contain ASCII letters, numbers, _ and -, up to 256 characters. |
attachments | array | Files, see below. |
Attachments
| Field | Type | Description |
|---|---|---|
filename | string, required | File name shown to the recipient. |
content | string, required | File content, base64 encoded. |
content_type | string | Media type, for example application/pdf. |
content_id | string | Set it to embed the file inline and reference it in HTML as cid:<content_id>. Letters, numbers and . _ @ + -. |
Attachments may total up to 40 MB per email (decoded size). Attachments by URL or path are not supported yet.
Headers
| Header | Description |
|---|---|
Authorization | Bearer <your API key>. Required. |
Idempotency-Key | Optional, up to 256 characters. Retrying with the same key and body returns the first email instead of sending again, for 24 hours. See Idempotency. |
Example
curl -X POST https://robustemail.com/api/v2/emails \
-H "Authorization: Bearer $ROBUSTEMAIL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: invoice-2041" \
-d '{
"from": "Acme Billing <billing@acme.com>",
"to": ["jane@example.com"],
"reply_to": "support@acme.com",
"subject": "Your invoice #2041",
"html": "<p>Hi Jane, your invoice is attached.</p>",
"tags": [{ "name": "category", "value": "invoice" }],
"attachments": [
{
"filename": "invoice-2041.pdf",
"content": "JVBERi0xLjQKJ...",
"content_type": "application/pdf"
}
]
}'
Response
{ "id": "6adc79043cbea" }
The email is queued and delivered in the background. Follow it in Developers › Emails or with Retrieve email.
Recipients on your account’s suppression list (people who bounced, complained or were blocked) are removed before sending. If every recipient is suppressed, the email ends with the suppressed status.
Errors
| Status | name | When |
|---|---|---|
| 422 | validation_error | A field is missing or invalid. The message says which. |
| 403 | invalid_from_address | The from domain is not verified (live mode). |
| 403 | restricted_api_key | The key is limited to another domain, or the account has no active subscription. |
| 409 | invalid_idempotent_request | The Idempotency-Key was used before with a different body. |
See Errors for the full list.