Sending transactional e-mails in a batch: one request, many messages and the result of each

E-mail·· 40 views· 3 min read

The short answer: POST /v1/email/messages/batch sends many e-mails in one request. Fields outside messages apply to all of them, and each message has its own to and variables. There is no limit on the number of messages, only on the request size (8 MB). results says what happened to each one.

An example

curl https://api.mozout.com/v1/email/messages/batch \
-H "Authorization: Bearer sandbox_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: invoices-2026-11" \
-d '{"from": "Your Company <invoices@yourcompany.com>",
"template_id": 12,
"messages": [
{"to": "ana@example.com", "variables": {"name": "Ana", "number": "FT 214"}},
{"to": "rui@example.com", "variables": {"name": "Rui", "number": "FT 215"}}]}'

The shared fields are from, subject, html, text, template_id, reply_to and send_at. Each message can change any of them, and follows the same rules as a normal send.

Reading the answer

Field What it says
total How many messages the request had
accepted / rejected How many were accepted and how many refused
credits The credits used
results One line per message, in request order: index, id, status and, if it failed, error and field

A message with an invalid address comes back with "status": "rejected" and "error": "invalid_recipient", and the others go ahead anyway. Use the index to find which one to fix.

What goes at once and what joins the queue

The first 20 messages go out straight away; the rest join the queue, which runs every minute. So a big batch takes a few minutes to go out completely: follow each id in the log or through the webhook.

Without credits or at the daily limit, the rest are refused. If the balance runs out or the daily limit is reached part-way, the remaining messages come back as rejected, with the reason insufficient_credits or daily_limit_reached. Check your balance before a big batch: credits and the daily limit.
A batch is for individual messages. Each person gets their own invoice or notice. The same news for your whole list is a campaign, with an unsubscribe link: see e-mail marketing.

Want to send all of this month’s invoices at once? See the API page.

See the API page

SEE ALSO

Sending a transactional e-mail through the API: the fields of POST /v1/email/messages

Transactional e-mail templates with variables: write once, fill in each customer's details

To, Cc, Bcc and Reply-To in transactional e-mail: how many recipients and what each one costs

Email Center credits and the daily limit: what a credit pays for and when it comes back

Email Center webhooks: receiving delivery, bounce and complaint events in your system

Scheduling a transactional e-mail with send_at, and cancelling it before it goes out

RECOMMENDED PRODUCT

Professional e-mail on your domain

Mailboxes in your company name, no adverts, with spam filtering. from KSh858.00/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.