MailnationDocs

Kirim

POST /emails

URL

FieldValue
MethodPOST
URLhttps://api.mailnation.id/emails
POST https://api.mailnation.id/emails
HeaderWajibKeterangan
AuthorizationyaBasic base64(username:password) — credential SMTP dari dashboard. Atau Bearer <jwt>
Content-Typeyaapplication/json
Idempotency-KeyyaKey unik 1–255 karakter. Retry dengan body sama = aman
Authorization: Basic <base64>
Content-Type: application/json
Idempotency-Key: order-123-email

Body

JSON. to + cc + bcc digabung unik (maks 50). MIME jadi maks 10 MiB.

FieldWajibKeterangan
fromyaAlamat pengirim
toyaString atau array
cctidakString atau array
bcctidakString atau array. Tidak masuk header MIME
reply_totidakSatu alamat
subjectyaMaks 500 karakter
textkondisionalPlain text
htmlkondisionalHTML
headerstidakCustom MIME header (X-Invoice, List-Unsubscribe, …). Nama cadangan ditolak
tagstidakString atau array, maks 20
attachmentstidakArray file (lihat bawah). Maks 20

Minimal isi salah satu: text, html, atau attachments.

attachments[]

FieldWajibKeterangan
filenameyaNama file, tanpa path
contentyaIsi file base64
content_typetidakDefault dari ekstensi, atau application/octet-stream
content_idtidakUntuk 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 fileDengan file
URLsamasama
Headersamasama
Bodytext / html+ attachments[] (filename, content base64)
Ukurankecilhitung 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.

On this page