Kirim
POST /emails
URL
| Field | Value |
|---|---|
| Method | POST |
| URL | https://api.mailnation.id/emails |
POST https://api.mailnation.id/emailsHeader
| Header | Wajib | Keterangan |
|---|---|---|
Authorization | ya | Basic base64(username:password) — credential SMTP dari dashboard. Atau Bearer <jwt> |
Content-Type | ya | application/json |
Idempotency-Key | ya | Key unik 1–255 karakter. Retry dengan body sama = aman |
Authorization: Basic <base64>
Content-Type: application/json
Idempotency-Key: order-123-emailBody
JSON. to + cc + bcc digabung unik (maks 50). MIME jadi maks 10 MiB.
| Field | Wajib | Keterangan |
|---|---|---|
from | ya | Alamat pengirim |
to | ya | String atau array |
cc | tidak | String atau array |
bcc | tidak | String atau array. Tidak masuk header MIME |
reply_to | tidak | Satu alamat |
subject | ya | Maks 500 karakter |
text | kondisional | Plain text |
html | kondisional | HTML |
headers | tidak | Custom MIME header (X-Invoice, List-Unsubscribe, …). Nama cadangan ditolak |
tags | tidak | String atau array, maks 20 |
attachments | tidak | Array file (lihat bawah). Maks 20 |
Minimal isi salah satu: text, html, atau attachments.
attachments[]
| Field | Wajib | Keterangan |
|---|---|---|
filename | ya | Nama file, tanpa path |
content | ya | Isi file base64 |
content_type | tidak | Default dari ekstensi, atau application/octet-stream |
content_id | tidak | Untuk inline (cid:… di HTML) |
Tanpa file
OTP / notifikasi teks saja. Tidak ada attachments.
curl -X POST https://api.mailnation.id/emails \
-u 'SMTP_USERNAME:SMTP_PASSWORD' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: otp-847291' \
-d '{
"from": "noreply@domain-anda.id",
"to": "user@gmail.com",
"subject": "Kode OTP",
"text": "847291",
"html": "<p>847291</p>"
}'Dengan file
Sama persis URL + header. Bedanya ada attachments (dan biasanya html/text pengantar).
curl -X POST https://api.mailnation.id/emails \
-u 'SMTP_USERNAME:SMTP_PASSWORD' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: invoice-8891' \
-d '{
"from": "billing@domain-anda.id",
"to": "user@gmail.com",
"subject": "Invoice #8891",
"text": "Invoice terlampir.",
"html": "<p>Invoice terlampir.</p>",
"headers": { "X-Invoice": "8891" },
"tags": ["invoice"],
"attachments": [
{
"filename": "invoice.pdf",
"content_type": "application/pdf",
"content": "JVBERi0xLjQ="
}
]
}'Inline di HTML
Pakai content_id, lalu cid: di HTML:
{
"html": "<img src=\"cid:logo\" alt=\"Logo\">",
"attachments": [
{
"filename": "logo.png",
"content_type": "image/png",
"content_id": "logo",
"content": "iVBORw0KGgo="
}
]
}Perbedaan singkat
| Tanpa file | Dengan file | |
|---|---|---|
| URL | sama | sama |
| Header | sama | sama |
| Body | text / html | + attachments[] (filename, content base64) |
| Ukuran | kecil | hitung base64; total MIME ≤ 10 MiB |
Respons attachments | [] | meta file (filename, content_type, size) |
Respons
HTTP 202
{
"id": "01JEXAMPLE",
"status": "queued",
"source": "api",
"from": "billing@domain-anda.id",
"to": ["user@gmail.com"],
"headers": { "X-Invoice": "8891" },
"tags": ["invoice"],
"attachments": [
{ "filename": "invoice.pdf", "content_type": "application/pdf", "size": 8 }
],
"credits_reserved": 1,
"request_id": "req_01JEXAMPLE"
}Cek hasil kirim: Cek status.