Skip to content

Sending email

Send with POST /v1/emails. A request needs from, to, subject and at least one of html or text.

POST /emails
{
"from": "Kedai Runcit <resit@kedai.my>",
"to": ["siti@example.com"],
"subject": "Resit #1042",
"html": "<p>Terima kasih atas pembelian anda.</p>",
"text": "Terima kasih atas pembelian anda.",
"reply_to": "bantuan@kedai.my",
"tags": [{ "name": "type", "value": "receipt" }]
}

Duta answers 202 Accepted:

{ "id": "msg_...", "status": "queued" }

queued means Duta accepted the message and will hand it to the mail provider. What happens next arrives as webhook events and on the email’s page in the dashboard. A send to a suppressed address answers suppressed and is not sent. A sandbox send answers sent.

from, to, cc, bcc and reply_to take any of:

  • a plain address: "siti@example.com"
  • an address with a name: "Siti Aminah <siti@example.com>"
  • an object: { "email": "siti@example.com", "name": "Siti Aminah" }

to, cc, bcc and reply_to also take a list of these. A single message can contain up to 50 recipients across to, cc and bcc. The from address must be on a domain you verified, or your sandbox address.

Each attachment has an optional filename (inferred from the URL for path attachments, or defaulted to attachment) and exactly one of:

  • content: the file as base64. A Node Buffer passed through the Resend SDK also works.
  • path: a public https URL that Duta downloads when it sends.
POST /emails
{
"from": "Kedai Runcit <resit@kedai.my>",
"to": "siti@example.com",
"subject": "Invois anda",
"text": "Invois dilampirkan.",
"attachments": [
{ "filename": "invois-1042.pdf", "content": "JVBERi0xLjcK..." }
]
}

content_type is inferred from the filename when you leave it out. For an inline image, set content_id and refer to it as cid: in the HTML. The total attachment size is capped per plan: 1 MB on Starter, 2 MB on Pro, 5 MB on Custom (see Plans and limits). Files must be on the allowed types list (PDF, images, CSV, text, Office documents). Total message MIME size cannot exceed 10 MB. Free sandbox sends take no attachments.

Tags label a message for your own records. Each name and value may contain only ASCII letters, numbers, underscores and dashes, up to 256 characters. Give them as a list of { name, value } or as an object:

{ "tags": { "type": "receipt", "store": "shah_alam" } }

headers adds custom headers to the message, such as X-Entity-Ref-ID. Duta always sets its own Message-ID. On single-recipient mail it adds the one-click unsubscribe headers, which you cannot set or remove. See Unsubscribe.

scheduled_at, template and topic_id are Resend features Duta does not have. A request that includes one is refused with 422 naming the field, so a message never goes out at the wrong time or without its template.