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
toOne address or up to 50
cc, bccCopies, up to 50 together (service email only)
reply_toUp to 10 addresses
subject, html, texttext is made from html when left out
message_classservice (default) or marketing
templateSend a published template instead of a subject and body
tagsYour own name/value labels, returned in webhooks
topic_idThe topic a marketing email is for
headersYour own X- headers, and OTP-Token for sign-in codes
attachmentsFiles to attach
scheduled_atSend 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

CodeWhy
unknown_senderThe from address isn't on a verified domain of the project
recipient_suppressedA recipient bounced, complained or unsubscribed
recipient_not_on_topicA recipient isn't on the topic_id
invalid_variablesA template value is missing, unknown or the wrong type
hourly_limit, daily_limitOver your allowance: wait for Retry-After