Skip to content
Docs menu

Guides

Features

API

Integrations

Send an email

Sends one message to up to 50 recipients, from a template or inline.

Wakio sends inline html and text as you give them, apart from filling in merge tags from merge_data: it adds no footer, no tracking and no unsubscribe link.

Replace YOUR_EMAIL_ADDRESS with your own address before you run the example. Wakio refuses the placeholder, so a pasted example never sends to it. Leave out from and the message goes from no-reply@ one of your sendable domains. With more than one, pass from to choose.

POST /v1/emails

Example

curl https://api.wakio.net/v1/emails \
  -H "Authorization: Bearer $WAKIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "YOUR_EMAIL_ADDRESS",
  "subject": "Hello from Wakio",
  "html": "<p>It works.</p>"
}'

Response 202:

{
  "id": 272531,
  "status": "queued"
}

Parameters

NameTypeRequiredDescription
tostring or array of stringsNoAddresses such as [email protected] or Maya Lee <[email protected]>; quote a name that contains a comma. The name shows in the recipient's To line, and duplicates, suppressions and the response match on the address alone. to, cc and bcc together need at least one address and at most 50 once duplicates collapse, ignoring case. Naming more than 200 addresses is refused before duplicates collapse.
ccstring or array of stringsNoCopied recipients, counted with to.
bccstring or array of stringsNoBlind-copied recipients, counted with to.
templatestringNoThe key of a published template, set up with Wakio. Send either template or an inline message (subject plus html or text), never both.
merge_dataobjectNoValues for {{placeholders}} in the template or the inline message. A placeholder with no value is sent as written. Values are HTML-escaped where they land in the HTML part, so send plain text, not markup. Each value must be a string, number, boolean or null, or the request answers 422. At most 256 KB as JSON.
subjectstringNoInline subject. Required for an inline message. At most 998 bytes, no line breaks or control characters.
htmlstringNoInline HTML body. At most 512 KB.
textstringNoInline plain-text body. At most 256 KB.
fromstringNoA bare address or Name <address> on one of your sendable domains. Omitted, mail goes from no-reply@ one of your sendable domains; with more than one, pass from to choose.
reply_toarray of stringsNoUp to 10 bare addresses.
attachmentsarray of objectsNoEach { "filename", "content_type", "content" }, with content base64-encoded and content_type a bare MIME type such as application/pdf. Up to 20 files, filenames up to 255 bytes, 10 MB decoded and 15 MB encoded per request, and the decoded size times the number of recipients at most 50 MB.
Idempotency-KeyheaderNoAny string up to 255 bytes. A blank key is treated as no key. Once a request with this key is accepted, a retry with a byte-identical body gets the first response back instead of sending again, for 24 hours. In that time the same key with any other body, even the same JSON with its keys reordered, is refused. A request refused before anything was accepted frees its key.

Response

NameTypeRequiredDescription
idintegerNoThe delivery's id. Returned when the request names exactly one recipient.
statusstringNoReturned with id. A status of suppressed means Wakio did not send to that address.
deliveriesarrayNoOne { "email", "id", "status" } per recipient. Returned when the request names more than one. A status of suppressed means Wakio did not send to that address.

Errors

Every error this endpoint itself returns is {"error": "<code>"}, sometimes with one more field that explains it. The API overview lists the responses that do not follow that shape.

StatusCodeWhat happenedWhat to do
401invalid_api_keyThe Authorization header is missing, malformed, or names no active key.Send Authorization: Bearer <key> with an active key from API keys in the dashboard.
402not_entitledThe account has no active plan. reason says why.Choose a plan under Billing.
403account_suspendedThe account is suspended. detail gives the reason.Email [email protected].
409request_in_flightA retry with the same Idempotency-Key and the same body arrives while the first request is still being processed, or after it failed with some recipients already accepted. In that case the key stays in flight for 24 hours.Wait and retry with the same key. If it still answers 409, check Deliveries for what went out before sending the rest under a new key.
422invalid_requestA field is missing, malformed or over its limit. detail names it.Fix the field detail names.
422unknown_templateNo published template has that key. template echoes it.Check the key. Templates are set up with Wakio for now; email [email protected].
422no_verified_sending_domainThe account has no domain it can send from, or from is not on one.Finish verifying a domain under Sending domains.
422idempotency_key_reusedThis Idempotency-Key was already used with a different body.Use a new key for a different message.

Send from a template

Use a template's key instead of an inline message, and merge_data fills its placeholders. Templates are not managed in the dashboard yet. To have one set up, email [email protected].

curl https://api.wakio.net/v1/emails \
  -H "Authorization: Bearer $WAKIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "YOUR_EMAIL_ADDRESS",
  "template": "welcome",
  "merge_data": {
    "first_name": "Maya"
  }
}'

Notes

Send an Idempotency-Key when a duplicate would be worse than a missing send. A retry gets the first response back only if it sends the byte-identical body, for 24 hours.

A suppressed address is accepted, not refused, and its status says so. A request for one recipient answers with its id and status. A request for several answers with deliveries, one entry per address. A status of suppressed means Wakio did not send to that address.

Using Rails? The Rails guide sends through Action Mailer without calling this endpoint yourself. On WordPress, the WordPress plugin does the same for every email your site sends.