Send an email
One POST, and the message id comes back immediately.
# the id comes back immediately; delivery is reported as events
curl -X POST https://api.mailgiri.com/v1/emails \
-H "Authorization: Bearer mg_live_your_key" \
-H "Content-Type: application/json" \
-d '{
"from": "hello@yourapp.com",
"to": ["user@example.com"],
"subject": "Welcome",
"html": "<p>Glad you are here.</p>"
}'
The response is 202 Accepted, not 200. The message is queued and the id is how you follow it — the receiving server has not answered yet, so delivery is reported through events rather than this response.
Fields
| Field | Required | Notes |
|---|---|---|
from | yes | An address on a domain you have added. |
to | yes | An array, even for one recipient. 1 to 50 addresses. |
subject | no | Omitted sends with an empty subject. |
html / text | one of | Send both when you can. See below. |
cc, bcc | no | Arrays, up to 50 each. |
reply_to | no | A single address. |
attachments | no | Up to 20, 25 MB total across the message. |
tags | no | Up to 20. Returned on every event for this message. |
scheduled_at | no | Must include a UTC offset. |
idempotency_key | no | Makes a retry safe. |
Always send a text part
One of html or text is required, but sending only html costs you twice: spam filters weigh a missing text part against you, and readers on text-only clients get a blank message.
Retrying safely
A network timeout does not tell you whether the send happened. Pass an idempotency_key and a retry with the same key returns the original message instead of sending a second copy.
scheduled_at is rejected without a UTC offset. A naive timestamp would be read in the server's timezone, which is a quiet way to send a campaign at the wrong hour.