Lewati ke isi
MarsistenDocs

Kirim Pesan lewat API

Teks, gambar, audio, video, dokumen, lokasi, kartu kontak, dan template — beserta aturan WhatsApp yang diperiksa.

± 5 menit

Satu endpoint untuk semua jenis: POST https://api.marsisten.com/v1/messages dengan header Idempotency-Key (wajib, mis. UUID baru per pesan).

Tujuan & kanal#

  • to = nomor tujuan (0812… atau 62812…), atau conversation_id = percakapan yang sudah ada di Inbox.
  • channel_id wajib bila Profil punya lebih dari satu nomor (lihat GET /channels).
  • ai_tetap_aktif: true bila AI Agent tetap boleh membalas percakapan itu (bawaan: AI berhenti seperti saat CS membalas).

Contoh per jenis#

text

Teks ≤ 1.000 karakter.

type: text
{
  "to": "6281234567890",
  "type": "text",
  "text": {
    "body": "Pesanan Anda sudah dikirim 🙏"
  }
}

image

JPG/PNG ≤ 5 MB, keterangan opsional.

type: image
{
  "to": "6281234567890",
  "type": "image",
  "image": {
    "url": "https://contoh.com/produk.jpg",
    "caption": "Warna sage ready kak"
  }
}

document

PDF/Office ≤ 50 MB (API Official ≤ batas Meta).

type: document
{
  "to": "6281234567890",
  "type": "document",
  "document": {
    "media_id": "md_0123456789abcdef",
    "filename": "invoice-1024.pdf"
  }
}

video

MP4 ≤ 16 MB.

type: video
{
  "to": "6281234567890",
  "type": "video",
  "video": {
    "url": "https://contoh.com/demo.mp4",
    "caption": "Cara pakai"
  }
}

audio

OGG (Opus) dikirim sebagai voice note di API Official; WhatsApp Device mengirimnya sebagai pesan audio.

type: audio
{
  "to": "6281234567890",
  "type": "audio",
  "audio": {
    "media_id": "md_0123456789abcdef"
  }
}

location

Pin lokasi (WhatsApp Device & API Official).

type: location
{
  "to": "6281234567890",
  "type": "location",
  "location": {
    "latitude": -6.9175,
    "longitude": 107.6191,
    "name": "Toko Rina",
    "address": "Jl. Asia Afrika 1, Bandung"
  }
}

contact

Kartu kontak (WhatsApp Device & API Official).

type: contact
{
  "to": "6281234567890",
  "type": "contact",
  "contact": {
    "name": "CS Toko Rina",
    "phone": "6281311112222"
  }
}

template

Wajib di luar 24 jam (API Official). Isi variables sesuai jumlah {{…}} template.

type: template
{
  "to": "6281234567890",
  "type": "template",
  "template": {
    "name": "info_pesanan",
    "language": "id",
    "variables": [
      "Rina",
      "INV-1024"
    ]
  }
}

Aturan sebelum kirim#

Jendela 24 jam (API Official)Di luar 24 jam sejak pesan terakhir pelanggan hanya template yang boleh.
STOPNomor yang membalas STOP tidak dikirimi dari jalur mana pun.
Kuota pesan baru (Device)Pesan ke orang yang belum chat dalam 24 jam memakai kuota harian yang sama dengan broadcast.
Jeda (Device)Pesan diantre per nomor dengan jeda acak seperti dasbor — kirim massal hanya lewat /broadcasts.
Ukuran mediaGambar ≤ 5 MB, audio & video ≤ 16 MB, dokumen ≤ 50 MB.

Status pesan#

GET https://api.marsisten.com/v1/messages/{id} → queued, sent, delivered, read, atau failed (+ alasan). Lebih hemat: berlangganan event message.status.

Status
curl -X GET "https://api.marsisten.com/v1/messages/kk_0123456789abcdef0123456789abcdef0123" \
  -H "Authorization: Bearer KUNCI_API_ANDA"