Send Email
API reference for sending transactional emails.
Send a transactional email through the PlatformXe multi-provider fallback chain.
Endpoint
POST /api/v1/messaging/email/send
Scope: messaging:send
Request body
| Field | Type | Required | Description |
|---|---|---|---|
from | string | Yes | Sender: an address or Name <address>, at most 320 characters (see Sender address) |
to | string[] | Yes | Recipients, at least one. Each entry is one address or Name <address>, at most 320 characters. A name holding , ; : ( or ) must be quoted: "Doe, Jane" <jane@acme.ng> |
cc / bcc | string[] | No | Up to 10 entries each, read like to |
subject | string | Yes | Email subject line |
html | string | Yes | Pre-rendered HTML body |
replyTo | string or string[] | No | One reply-to address, or a list of 1 to 5; each at most 320 characters and one address (Name <address> allowed) |
text | string | No | Plain-text part |
attachments | Array<{ filename: string, content: string }> | No | Attachments: a non-empty filename and its base64 content, standard or URL-safe (- and _); a contentType field is not read. The contents hold at most 4,400,000 base64 characters in all (about 3.3 MB of files). Any other shape, or more, is 400 VALIDATION_ERROR. The whole request body is limited to 4.5 MB: a larger one is refused with 413 before it is read |
callerRef | string | No | Your own tracking reference, at most 200 characters: stored with the message log entries of this email (and kept if it is queued); not sent to the recipient |
templateId | string | No | A template to render: its subject, HTML and plain-text part replace subject, html and text (send placeholders for the two required fields). A built-in template, a platform template or one of your organisation's, rendered with variables (none when absent). Another organisation's template, or an id that does not exist, answers 404 NOT_FOUND and nothing is sent |
variables | Record<string, string> | No | Values for the template's variables (with templateId; absent: none); every value a string |
Response
{
"success": true,
"data": {
"messageId": "msg_abc123def456",
"provider": "primary",
"queued": false
}
}
| Field | Type | Description |
|---|---|---|
messageId | string | Unique message identifier for tracking (absent when the email was queued) |
provider | string | The position in the fallback chain that delivered it: primary, fallback_1, fallback_2, ...; none when every provider failed. It never names a provider. |
queued | boolean | true when every provider failed and the email was queued for retry (provider: "none"). A 200 always means sent or queued: an email that could be neither is answered 429 or 503 (see Error responses) |
deduplicated | boolean | Present (true) with queued: true when your identical email is already in the retry queue (see Duplicate sends while queued). Absent otherwise |
Sender address
The sender is chosen by the API key's organisation. A customer organisation sends only from a verified sending domain: hello@<your domain>, with the domain's display name when it has one, through the route that verified the domain. If that route does not accept the email, the send is refused. Without a verified domain, an organisation may send only to its own verified members (people on its team in the portal who have signed in with an emailed code, accepted an invitation, or signed in through single sign-on), from the shared platform address; a send with any other recipient is refused. The answer is 400 BAD_REQUEST, nothing is sent, and nothing is queued. The shared platform address is reserved for Caldera. A key with no organisation uses that address. No email is ever sent from a noreply@ address. The display name on a domain is kept, but never any address text in it (anything in angle brackets or holding @, @ or ﹫ is dropped); invisible and right-to-left formatting characters are removed from it, and it is cut to 200 characters. A retry of an email already queued follows the same rule for the organisation that queued it.
Duplicate sends while queued
While every route is down, a repeat of an email that is already waiting in the retry queue is not stored a second time. The answer is 200 with queued: true and deduplicated: true: the queued email is that email, and it is sent once when a route recovers.
Two emails are the same email only when all of these match: the API key's caller service and organisation, the recipients (to, in any order), the subject, and the content (from, cc, bcc, replyTo, html, text and the attachments). An email with the same recipients and subject but another body is a different email and is queued on its own. Another organisation's emails never count, whatever they contain.
Sending limits
To stop a runaway loop from flooding one mailbox, PlatformXe limits the emails sent to one recipient set: a number per hour, and a number with the same subject per day. The limits protect the recipient, so they count every sender's emails to that recipient, not only yours. An email over a limit is not sent and not queued. The answer is 429 EMAIL_RATE_LIMITED, and its Retry-After header is the real number of seconds until the limit frees a place (up to 24 hours), so wait that long before sending the email again. Sending sooner is answered the same way.
Free plan
An organisation on the free plan (or a trial, a past-due subscription, or a cancelled one whose paid period has ended) sends at most 6 emails in any 24 hours. Without a verified domain those emails go only to verified members of your organisation (see Sender address), so the free plan is for trying the API. Each recipient is one email, and only to may be used: a send with cc or bcc, or with more than 6 recipients, is refused with 400 BAD_REQUEST. Over the allowance the send is refused before it reaches any route, with 429 EMAIL_RATE_LIMITED and Retry-After (at most 24 hours; sending again sooner is refused again). Nothing is sent or queued. Upgrade to a paid plan to send more.
A request the routes refuse
A route can refuse the request itself: an invalid recipient, replyTo or attachment. On the shared platform address, that refusal may be the route's own, so the next route in the chain is still tried, and the email is sent if any route accepts it. Only when every route refuses it does the send fail with 400 BAD_REQUEST; the message names each route's reason, by position, never by provider. Such an email is not queued and is not retried: fix the request and send it again. If at least one route failed in another way (a timeout, an outage), the email is queued and retried as usual (queued: true). A customer organisation does not use that chain: its verified domain's route is the only one tried, and a refusal or any other failure there is 400 BAD_REQUEST with nothing queued.
Examples
curl
curl -X POST https://api.platformxe.com/api/v1/messaging/email/send \
-H "Content-Type: application/json" \
-H "x-api-key: pxk_live_your_api_key_here" \
-H "x-idempotency-key: order-confirm-12345" \
-d '{
"from": "Your App <hello@yourapp.com>",
"to": ["jane@example.com"],
"subject": "Order #12345 Confirmed",
"html": "<h1>Order Confirmed</h1><p>Your order has been placed successfully.</p>",
"replyTo": "support@yourapp.com"
}'
SDK
import { PlatformXeClient } from '@caldera/platformxe-sdk';
const px = new PlatformXeClient({ apiKey: 'pxk_live_your_api_key_here' });
const result = await px.email.send({
from: 'Your App <hello@yourapp.com>',
to: ['jane@example.com'],
subject: 'Order #12345 Confirmed',
html: '<h1>Order Confirmed</h1><p>Your order has been placed successfully.</p>',
replyTo: 'support@yourapp.com',
});
console.log(result.data.messageId);
// "msg_abc123def456"
With attachments
import { readFileSync } from 'fs';
const pdf = readFileSync('./invoice.pdf').toString('base64');
const result = await px.email.send({
from: 'Your App <hello@yourapp.com>',
to: ['jane@example.com'],
subject: 'Your Invoice',
html: '<p>Please find your invoice attached.</p>',
attachments: [
{
filename: 'invoice.pdf',
content: pdf,
contentType: 'application/pdf',
},
],
});
Error responses
| Code | Description |
|---|---|
BAD_REQUEST | Missing or invalid fields in the request body (a to, cc or bcc entry that is not a string, a replyTo that is not a string or a list of 1 to 5 strings, a templateId that is not a string, variables that is not an object of strings, or a callerRef that is not a string, included), every route refused the email as sent (an invalid recipient, replyTo or attachment; see A request the routes refuse), or a customer organisation has no verified sending domain (or that domain's route did not accept the email; see Sender address). A refused email is not queued and is not retried: fix the request and send it again. A replyTo entry that is not one email address is refused the same way. |
VALIDATION_ERROR | attachments is not a list of { filename, content } with base64 content or holds more than 4,400,000 base64 characters, callerRef is longer than 200 characters, the from, or a to, cc, bcc or replyTo entry, is longer than 320 characters, or a to, cc or bcc entry is not one email address (an empty string, a name with no address, two addresses in one entry, a name holding an unquoted , ; : ( or ), or a line break or other control character anywhere in the entry, quoted or not). Nothing is sent or queued |
NOT_FOUND | The templateId names no template, or a template of another organisation. Nothing is sent |
EMAIL_RATE_LIMITED | 429, with Retry-After. A sending limit for the recipient was reached before any route was tried. Nothing was sent or queued. Retry-After is the real wait in seconds (up to 24 hours); do not send it again sooner. A 429 is never stored under an x-idempotency-key, so the later send may reuse the same key |
EMAIL_NOT_ACCEPTED | 503, with Retry-After (60 seconds). Every route failed and the retry queue could not store the email. Nothing was sent and nothing will be. It is retryable: send it again after Retry-After. A 5xx is never stored under an x-idempotency-key, so the retry may reuse the same key |
EMAIL_PROVIDER_UNAVAILABLE | 503, with Retry-After (300 seconds). No email route is available. Nothing was sent or queued; send it again later |
IDEMPOTENCY_UNAVAILABLE | 503, with Retry-After. The request carried an x-idempotency-key and the duplicate check was unavailable, so the send did not run. Send it again with the same key |
CONFLICT | 409. A request with the same x-idempotency-key is still being processed |
FORBIDDEN | API key does not have the messaging:send scope |
RATE_LIMITED | Rate limit exceeded for this API key |