Sending email
The fields of a send, copies, tags, scheduling and batches.
POST /email/emails sends one email.
POST /email/emails
Authorization: Bearer $RELEVATE_API_KEY
Idempotency-Key: order-4821:receipt
{
"from": "Shop <orders@shop.example>",
"to": ["anna@example.com", "ben@example.com"],
"cc": "manager@shop.example",
"reply_to": "help@shop.example",
"subject": "Your order is on its way",
"html": "<p>Good news: order 4821 shipped.</p>",
"tags": [{ "name": "category", "value": "shipping" }]
}| Field | |
|---|---|
from | "Name <address>" or "address", on one of your verified domains |
to | One address or up to 50 |
cc, bcc | Copies, up to 50 together (service email only) |
reply_to | Up to 10 addresses |
subject, html, text | text is made from html when left out |
message_class | service (default) or marketing |
template | Send a published template instead of a subject and body |
tags | Your own name/value labels, returned in webhooks |
topic_id | The topic a marketing email is for |
headers | Your own X- headers, and OTP-Token for sign-in codes |
attachments | Files to attach |
scheduled_at | Send later, up to 30 days ahead |
Marketing email
Marketing email goes to one person at a time, because each needs their own
unsubscribe link, and only to people who agreed to it. To email many people, use
POST /email/emails/batch with one item per person.
Sign-in codes
Put a one-time code in the OTP-Token header too, so mail apps that support it
can offer to fill it in on your site. The value is the code in quotes and the
site it signs in to:
"headers": {
"OTP-Token": "\"123456\"; origin=\"https://app.example.com\""
}The origin is https, lowercase, with no path. The header is for service email
to one person, without copies; keep the code in the body as well, since most
mail apps don't read the header yet. It follows an IETF draft, so the format
may still change.
After sending
GET /email/emails/{id}: the email and each recipient's state.GET /email/emails/{id}/events: its timeline: queued, delivered, opened, clicked, bounced and so on.PATCH /email/emails/{id}: move a scheduled email, or send it now.DELETE /email/emails/{id}: cancel before delivery starts.
A 202 means Relevate accepted the email, not that it reached the inbox. Follow
the recipient states or webhooks for that.
Refusals
| Code | Why |
|---|---|
unknown_sender | The from address isn't on a verified domain of the project |
recipient_suppressed | A recipient bounced, complained or unsubscribed |
recipient_not_on_topic | A recipient isn't on the topic_id |
invalid_variables | A template value is missing, unknown or the wrong type |
hourly_limit, daily_limit | Over your allowance: wait for Retry-After |