Send a transactional email
Call the send endpoint, schedule sends, and attach files.
Transactional email — receipts, resets, confirmations — is a single
POST /api/v1/emails. These always deliver, even to unsubscribed contacts,
because they're not marketing (unsubscribe blocks only marketing templates).
Send now
import { SendAndRetain } from "@sendandretain/sdk";
const sendandretain = new SendAndRetain(); // reads SENDANDRETAIN_API_KEY
const { data, error } = await sendandretain.emails.send(
{
to: "[email protected]",
template: "receipt",
props: { orderId: "ord_991", total: "42.50" },
from: "Acme <[email protected]>",
},
{ idempotencyKey: "receipt-ord-991" },
);from is optional — omit it to use the project's default sender. It must resolve
to a verified domain.
Schedule for later
Pass an ISO 8601 scheduled_at in the future; the worker sends it at that time.
Scheduling is handled by Send & Retain (not the provider), so it's uniform across
providers and cancellable.
{ "to": "[email protected]", "template": "reminder", "scheduled_at": "2026-08-01T09:00:00Z" }Attachments can't be combined with scheduled_at — attachment content is never
persisted, so scheduled sends can't carry it.
Attach files
Attachments are base64-encoded, up to 10 per message and ~5 MB total:
{
"to": "[email protected]",
"template": "invoice",
"attachments": [
{ "filename": "invoice.pdf", "content": "JVBERi0xLjQK...", "content_type": "application/pdf" }
]
}Idempotency
Always pass an Idempotency-Key for sends you might retry — see
Idempotency. A repeat returns the original
result with deduplicated: true.