Developer guideSending
Sending email
POST /v1/emails in detail. Fields, recipients as a string or a list, idempotency, batch sending, scheduling, tags, metadata, attachments and the pre-send check.
POST /v1/emails sends an email (send scope). The 202 Accepted response has the id and the status, and it only comes back after the email is in the queue. If something prevents the send, you get an error, never a fake success.
{ "id": "msg_9w2k7c1x0d4e5f6g", "status": "queued" }With a ck_test_ key the status is captured and nothing is delivered (see Test mode). When the account already reached its daily limit and the project keeps emails for the next day, the status is queued_for_tomorrow (see Daily limit).
When something in the email hurts delivery but does not stop it, the 202 answer brings warnings. Today: reply_to_free_mailbox, a Reply-To on a free mailbox (Gmail, Outlook, Yahoo...) while the sender is on another domain, which spam filters read as a forged reply address. An email with only HTML gets a plain-text part made from it when it is sent.
{ "id": "msg_4f8s2d9q1abcdefg", "status": "queued", "warnings": [{ "code": "reply_to_free_mailbox", "param": "reply_to", "message": "The Reply-To is a gmail.com address while the sender is on another domain..." }] }Fields#
| Field | Type | Required | Description |
|---|---|---|---|
from |
string | yes | sender on one of the project's verified domains: "hi@example.com" or "Shop <orders@example.com>". A subdomain of a verified domain works too |
to |
string or string[] | yes | one address ("ana@example.com") or a list |
cc, bcc |
string or string[] | no | carbon copy and blind carbon copy, also a string or a list |
reply_to |
string or string[] | no | where replies go |
subject |
string | yes (without template) |
subject, 1 to 998 characters |
html |
string | one of the two | HTML body (up to 5 MB) |
text |
string | one of the two | plain text body (up to 5 MB) |
attachments |
object[] | no | up to 20 attachments (see below) |
headers |
object | no | extra headers, such as { "X-Order": "1042" } |
tags |
object | no | string key and value pairs to filter and group by |
metadata |
object | no | your own string data, returned in webhooks |
scheduled_at |
ISO 8601 string | no | send later, up to 30 days ahead |
stream |
transactional or marketing |
no | stream; defaults to transactional |
on_daily_limit |
queue or reject |
no | what to do when the account already reached its daily limit: keep for the next day or refuse. The default comes from the project (see Daily limit) |
template + variables |
string + object | no | saved template (tpl_... or its name) and the values of its {{name}} variables; replaces html and text |
personalize |
object | no | { instructions, fields? }: AI rewrites the passages marked with {{#ai}}...{{/ai}} using variables, on every send, for 1 credit per recipient. See AI |
- At most 50 recipients per email, across
to,ccandbcc. For more, use a batch. - The request body can be up to 30 MB, counting Base64 attachments.
- Always send
textalong withhtml. Providers trust emails with both parts more, and plain-text readers will thank you.
{
"from": "Example Shop <orders@example.com>",
"to": "ana@example.com",
"cc": ["finance@example.com", "shipping@example.com"],
"reply_to": "support@example.com",
"subject": "Order 1042 confirmed",
"html": "<p>Your order 1042 is confirmed.</p>",
"text": "Your order 1042 is confirmed.",
"tags": { "type": "order" },
"metadata": { "order_id": "1042" }
}Idempotency#
Networks drop, functions restart, queues retry. To avoid sending the same email twice, send the Idempotency-Key header (up to 255 characters) with a value unique to the business operation:
Idempotency-Key: order-1042-confirmation- For 24 hours, repeating the call with the same key and the same body returns the same response, with the
Idempotent-Replayed: trueheader, without sending again. - The same key with a different body returns
409 idempotency_conflict. - If the first request is still running, the retry gets
409 idempotency_in_progresswithRetry-After: 1. 5xx,409and429responses are not stored: you can retry with the same key.- It works on every
POST, including batches.
Use something tied to the event, such as order-{id}-confirmation or password-{user}-{timestamp}. A fresh UUID on every attempt does not protect against retries.
Suppressed recipients#
If some recipients are on the suppression list, the email goes to the others and the timeline gets a suppressed event for each skipped address. If every recipient is suppressed, the response is 422 recipient_suppressed, with param pointing to the first one (to[0]).
Addresses that would surely bounce#
Before any email leaves Couryo, each recipient is checked. If one of them would surely bounce the email, the answer is 422 recipient_undeliverable, with param pointing to it, and nothing is sent:
- the domain does not receive email (it has no mail server in DNS, as in
ana@gmial.com); - the mailbox does not exist: its provider recently answered, to any Couryo sender, that the address is unknown;
- in marketing, role addresses such as
abuse@,postmaster@andnoreply@.
Every bounce weighs on sending reputation, yours and everyone's who sends through Couryo. That is why this check applies to the API, SMTP, MCP, campaigns (the contact shows as skipped) and sequences. ck_test_ keys skip it.
At send time, the checks run again#
A scheduled email, one kept for the next day or one waiting in the queue may go out hours or days after it was accepted. When it goes out, Couryo checks again the suppression list, whether the domain is still verified, and whether the account was paused or scheduled for deletion. If something changed, the email does not go out: its status becomes failed, with the reason in the timeline, and the day's limit goes back to the account.
Each email reaches the sending engine only once. If the engine's answer gets lost on the way (network drop, restart), Couryo waits for the engine's confirmation before trying again, instead of risking a double send.
Batch sending#
POST /v1/emails/batch takes up to 100 emails per call, in the emails field. Each item has the same fields as POST /v1/emails and is validated on its own: one bad item does not take down the others.
curl https://api.couryo.com/v1/emails/batch \
-H "Authorization: Bearer $COURYO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: reminders-2026-10-07" \
-d '{
"emails": [
{ "from": "hi@example.com", "to": "ana@example.com", "subject": "Reminder", "text": "Your class starts at 7 pm." },
{ "from": "hi@example.com", "to": ["bruno@example.com"], "subject": "Reminder", "text": "Your class starts at 7 pm." }
]
}'The response is 200 with one result per item, in the same order. Error params include the item index:
{
"data": [
{ "id": "msg_4h8s1m2p0q7r6t5u", "status": "queued" },
{
"error": {
"type": "invalid_request",
"code": "recipient_suppressed",
"message": "The address bruno@example.com is on the suppression list.",
"param": "emails[1].to[0]",
"doc_url": "https://couryo.com/docs/errors#recipient_suppressed",
"request_id": "req_2m9x4k7c1v0b8n3q"
}
}
]
}- More than 100 items:
400 batch_too_large, and nothing is sent. - A limit error (
daily_limit_reached,daily_queue_full,monthly_limit_reachedorspend_limit_reached) stops the rest of the batch: the item that hit the limit and every item after it come back with the same error. When the daily limit keeps emails for the next day, the items above the limit come back withqueued_for_tomorrow. - A pause (
sending_paused) works per stream: with marketing paused, only the marketing items are refused and the transactional ones go on within their limit.
Scheduling#
Pass scheduled_at as ISO 8601 with a time zone (Z or -03:00), up to 30 days ahead. The email stays queued until then. A time in the past (by more than 1 minute) or beyond 30 days returns invalid_field.
{
"from": "hi@example.com",
"to": "ana@example.com",
"subject": "Your class starts in 1 hour",
"text": "See you soon!",
"scheduled_at": "2026-10-08T21:00:00Z"
}Reschedule or cancel#
While a scheduled email has not started sending, you can change its time or cancel it (scope send). Once the time comes, or if it was already sent or cancelled, both calls answer 409 email_not_scheduled.
curl -X PATCH https://api.couryo.com/v1/emails/msg_8k2p9w4x1abcdefg \
-H "Authorization: Bearer $COURYO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "scheduled_at": "2026-10-09T12:00:00Z" }'curl -X POST https://api.couryo.com/v1/emails/msg_8k2p9w4x1abcdefg/cancel \
-H "Authorization: Bearer $COURYO_API_KEY"- The new time follows the same rules as sending: from now up to 30 days ahead.
- Once cancelled, the email has status
cancelled, the timeline gets acancelledevent (also sent to webhooks subscribed to it) and the quota goes back to the account. It cannot be undone: to send later, send it again. - Both answers bring the updated email, as in
GET /v1/emails/{id}. In the dashboard, the page of a scheduled email has Reschedule and Cancel send buttons. Through MCP,reschedule_emailandcancel_email.
Daily limit: refuse or keep for the next day#
When the account already used the day's limit (of the trust level or the plan), a send through the API, SMTP or MCP has two paths:
- Keep for the next day (the default, for both streams): the email is accepted (
202) with statusqueued_for_tomorrowand goes out at the turn of the day, in the account time zone. Nothing goes above the limit and nothing is lost. - Refuse (
429 daily_limit_reached): your system learns right away, and the email never leaves Couryo. Good for transactional email that is useless the next day, such as login codes and password resets.
{ "id": "msg_4f8s2d9q1abcdefg", "status": "queued_for_tomorrow", "scheduled_at": "2026-10-13T03:01:12Z" }Per project, under Settings > Projects > "When the daily limit is reached", or with GET and PATCH /v1/daily-limit (scope admin to change it). Per send, the on_daily_limit field ("queue" or "reject") wins over the project setting; over SMTP, the X-Couryo-On-Daily-Limit header.
curl -X PATCH https://api.couryo.com/v1/daily-limit \
-H "Authorization: Bearer $COURYO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "transactional": "reject" }'How the queue works:
- First come, first served. At the turn of the day (midnight in the account time zone, plus a few seconds per account), the kept emails enter the new day's limit, oldest first, spread over up to 5 minutes. What does not fit stays kept for the following day, in the same order. While there is a queue, a new send that can also be kept goes behind it.
- Never above the limit. Each email reserves the limit of the day it goes out, like any send. An email with more recipients than a whole day's limit is refused.
- On the timeline, the
queuedevent explains why and when it goes out; anotherqueuedmarks when it leaves the queue. The list's status filter (status=queued_for_tomorrow) and the notice on Home show how many are kept. - Queue cap: the account keeps at most 5 days of limit in recipients (500 on level 1). Above it,
429 daily_queue_full. - The monthly limit is never queued. When the month's quota (or the spending limit) ran out, the answer is still
monthly_limit_reached(orspend_limit_reached), and a kept email that finds the month used up at the turn of the day fails with the reason. Nothing waits for the next month. - Cancel: a kept email is cancelled like a scheduled one, with
POST /v1/emails/{id}/cancel(or in the dashboard and with MCPcancel_email). To change its time, cancel and send again. - Paused account: the queue waits; an email kept for more than 5 days fails with the reason.
- Campaigns and sequences do not use this setting: they already wait for the next day on their own.
Tags and metadata#
tagslet you filter the list (GET /v1/emails?tag=type:order) and group in the dashboard:{ "type": "order", "campaign": "october" }. Keys use letters, numbers,_and-(up to 64); values up to 256 characters.metadatais yours: it comes back in every webhook, handy to tie the email to a record in your system:{ "order_id": "1042" }. Keys up to 64 characters; values up to 1,024.
Both accept string values only.
Attachments#
Each attachment has filename (up to 255 characters), content (the file in Base64) and, optionally, content_type. Up to 20 per email.
{ "filename": "receipt.pdf", "content": "JVBERi0xLjcK...", "content_type": "application/pdf" }Bills and invoices: send a link, not an attachment. Bill attachments are a classic scam pattern, and spam filters know it. The pre-send check warns about it (
billing_attachment).
Headers#
Headers in headers go out as you sent them, except the ones that belong to the platform or break authentication, which are ignored: From, To, Cc, Bcc, Subject, Message-ID, Date, Return-Path, DKIM-Signature, List-Unsubscribe, List-Unsubscribe-Post, Content-Type, Content-Transfer-Encoding and MIME-Version.
Transactional and marketing#
The stream field separates the streams. A marketing unsubscribe never blocks transactional email (password, login, billing). On marketing, Couryo adds the one-click unsubscribe (List-Unsubscribe and List-Unsubscribe-Post, RFC 8058) that Gmail and Yahoo require, and whoever clicks it is suppressed on the marketing stream. Opens and clicks are tracked on the marketing stream and, on transactional, only when the project turns it on (see Open and click tracking).
Pre-send check#
POST /v1/emails/check (send scope) takes the same body as a send and returns a score from 0 to 100 and a list of issues, without sending anything. Good for CI.
{ "score": 90, "issues": [{ "code": "missing_text_part", "severity": "warning", "message": "The email has no text part." }] }code |
Severity | What it flags |
|---|---|---|
domain_not_verified |
error | the from domain is not verified: the send would be refused |
link_shortener |
error | a shortened link; use the full link on your own domain |
missing_text_part |
warning | html without text |
insecure_link |
warning | links without HTTPS |
html_too_large |
warning | HTML over 100 KB (Gmail clips the message) |
subject_all_caps |
warning | an all-caps subject |
billing_attachment |
warning | a bill, invoice or tax receipt as an attachment |
image_without_alt |
info | an image without alternative text |
spelling |
warning | possible Portuguese spelling mistakes, with suggestions in the spelling field (see Spelling) |
List and fetch#
| Method and path | Scope | What it does |
|---|---|---|
GET /v1/emails |
read |
newest first; filters status, recipient (part of the address), tag (key:value or a free term) and period (24h, 7d, 30d), with limit and starting_after |
GET /v1/emails/{id} |
read |
one email with its timeline, the content (html and text), the main headers (headers) and attachment names and sizes; test emails also bring review_url (the review link) |
PATCH /v1/emails/{id} |
send |
reschedules a scheduled email (scheduled_at) |
POST /v1/emails/{id}/cancel |
send |
cancels a scheduled email |
GET /v1/emails/export |
read |
exports the emails as CSV (see below) |
Export as CSV#
GET /v1/emails/export (scope read) downloads the log as a CSV file, newest first, with the same filters as the list (status, recipient, tag, period) plus stream and an exact period with from and to (ISO 8601). In the dashboard, Export CSV on the Emails page uses the filters on screen.
curl "https://api.couryo.com/v1/emails/export?status=bounced&from=2026-09-01T00:00:00-03:00&to=2026-10-01T00:00:00-03:00" \
-H "Authorization: Bearer $COURYO_API_KEY" -o bounces.csv- Columns:
id,created_at,scheduled_at,sent_at,status,stream,mode,from,to,cc,bcc,subject,tags(key:value;...),metadata(JSON),template_idandtemplate_version. Never the content. - UTF-8 with BOM and comma, so spreadsheets open it with the right accents. Values a spreadsheet would run as a formula (starting with
=,+,-or@) get a leading'. - The file comes as a stream, up to 100,000 rows. When there is more, the header
Couryo-Export-Truncated: truesays so: narrow the period. - One export per project at a time (another one meanwhile answers
409 export_in_progress). - Only what your plan's log retention still keeps (Free 7 days, Pro 30, Scale 90, Enterprise 365).