Documentation

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

FieldRequiredNotes
fromyesAn address on a domain you have added.
toyesAn array, even for one recipient. 1 to 50 addresses.
subjectnoOmitted sends with an empty subject.
html / textone ofSend both when you can. See below.
cc, bccnoArrays, up to 50 each.
reply_tonoA single address.
attachmentsnoUp to 20, 25 MB total across the message.
tagsnoUp to 20. Returned on every event for this message.
scheduled_atnoMust include a UTC offset.
idempotency_keynoMakes 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.

Related