POST /api/v1/emails
Send an email. Scope emails:send.
Checks run in a fixed order, so the refusal says which layer said no: the key, its scope and X-Barua-Account; the Idempotency-Key; whether the account may send at all (suspended, or over its daily quota), and for a sub-account whether its parent may; whether the paying account has credit; the body; the from-domain; the suppression list, and the parent's too for a sub-account. Only then does anything leave. With sandbox true every check still runs and the send is logged, but nothing is sent, counted or charged.
curl https://barua.tz/api/v1/emails \
-H "Authorization: Bearer barua_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: receipt-R-1042" \
-d '{
"from": "Duka Langu <receipts@dukalangu.co.tz>",
"to": "neema@gmail.com",
"template": {
"name": "receipt",
"receiptNumber": "R-1042",
"total": "25,000",
"paidOn": "24 September 2026",
"paymentMethod": "M-Pesa"
},
"sandbox": true
}'200
{
"id": "9b2e6d7a-3c4f-4e5a-9b1c-2d3e4f5a6b7c",
"sandbox": true
}400 invalid_jsonThe request body could not be parsed as JSON.400 invalid_idempotency_keyIdempotency-Key was sent but is empty or longer than 255 characters.402 no_creditsThe paying account has no credits and its grace window has closed.403 suspendedSending is paused on the account this request acts for, or on its parent. The message is the reason, written for the sender; a parent's pause is prefixed with: The parent account cannot send.403 domain_not_yoursThe from-address is on a domain this account has not connected.403 domain_not_readyThe domain is connected but its ownership record is not verified or sending is not yet enabled for it.409 idempotency_in_progressThe first request with this Idempotency-Key is still running. Retry in a few seconds to get its answer.413 body_too_largeThe request body is 1 MB or more.422 invalid_requestThe body or query failed validation. The message names the first field that failed.422 recipient_suppressedOne or more recipients are on the suppression list. Nothing was sent; the message names them.422 idempotency_mismatchThis Idempotency-Key was already used with a different body. Use a new key for each new email.429 quota_exceededThe daily quota of the account, or of its parent, is used up. It resets at midnight UTC.429 sandbox_limitThe account has made 1000 sandbox sends in the last 24 hours.502 send_failedBarua's mail server did not accept the message. The send is logged with status failed. Not filed under the Idempotency-Key, so a retry with the same key is a fresh attempt.