Skip to content
Reference

The send API

POST /api/v1/send sends one transactional mail: a receipt, a reset link, a notice.

The send API is for mail your own app sends to one person at a time: a receipt, a password reset, a download link. One request is one mail. It goes out as transactional mail, so it has no marketing footer, it reaches people who never joined your list, and anyone it adds to your audience is never marketed to.

How to send a mail

  1. Create a key with the send scope under Settings > API keys and copy it. It is shown once.
  2. Export it in your shell as KOLEA_API_KEY.
  3. Check that the from address is on a sending domain you have verified.
  4. Send the request.
curl -X POST https://kolea.pro/api/v1/send \
  -H "Authorization: Bearer $KOLEA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "reader@example.com",
    "from_email": "you@your-verified-domain.com",
    "subject": "Your receipt",
    "markdown": "Thanks for your order, **Ada**.",
    "idempotency_key": "order-1234"
  }'

The request

The body is JSON. to is required, and so is exactly one of markdown, document, or template.

FieldWhat it is
toThe recipient's address. Required.
nameThe recipient's name, up to 200 characters.
subjectRequired unless a template supplies one.
markdownThe body as Markdown, up to 200,000 characters.
documentThe body as an editor document (JSON).
templateThe slug of a template under Mail > Transactional.
variablesValues for the template: up to 100 names made of letters, digits, and underscores; values are text, numbers, or true/false.
from_emailMust be on a verified domain. Defaults to your account's from address.
from_nameUp to 120 characters.
reply_toAn address for replies.
idempotency_keyUp to 255 characters. Send the same key again and you get the first answer back, not a second mail.
tracktrue to track opens and clicks. Off unless you ask.

html is refused by name. Send Markdown, a document, or a template.

The response

202 Accepted comes back as soon as the mail is safely queued. It does not wait for delivery.

{"id": "...", "status": "queued", "to": "reader@example.com",
 "idempotency_key": "order-1234", "template": null}

A repeated idempotency key answers with the original body and the header Idempotent-Replayed: true.

A refusal is JSON, {"error": {"code": ..., "message": ..., "field": ...}}:

StatusCodeWhen
401unauthorizedThe key is missing, wrong, or revoked.
403forbiddenThe key's scope is not send or admin.
404not_foundNo template with that slug.
422invalidA field is wrong; fields lists every problem.
422from_domain_unverifiedfrom_email is not on a verified domain.
422account_unverifiedYour account email is not confirmed yet.
429rate_limitedOver the key's rate. Wait the seconds in Retry-After.

Things to know

  • Each key allows 120 accepted requests a minute unless you set a different rate when you create it.
  • A person who hard bounced or complained is not mailed; the message is recorded as suppressed.
  • A plan limit never refuses transactional mail.
  • The rest of the API is described at https://kolea.pro/api/v1/openapi.json, and a send key can call none of it.