MM

My Mosend Console

B2B Omnichannel & Relay

creditMo Balance

— creditMo

1 creditMo = Rp 1

WA TerputusMutasi Listener Offline
My Mosend API · v1

Dokumentasi Developer

WhatsApp dual-provider, email kompatibel Resend, QRIS dinamis dengan verifikasi mutasi otomatis, inbox omnichannel dan webhook — semua dengan satu API key. Base URL https://mymosend-api.khafi.workers.dev.

Memulai

Pengenalan & Autentikasi

My Mosend adalah gateway B2B untuk WhatsApp (Baileys & Cloud API resmi), email kompatibel Resend, verifikasi mutasi bank/QRIS dinamis, inbox omnichannel, dan widget website. Semua endpoint memakai JSON di atas HTTPS.

ItemNilai
Base URLhttps://mymosend-api.khafi.workers.dev
Tracking (open/klik)https://mymosend-api.khafi.workers.dev/o/:id.gif & https://mymosend-api.khafi.workers.dev/c/:id
Formatapplication/json, UTF-8
Mata uangcreditMo (1 creditMo = Rp 1, bilangan bulat)

Autentikasi server-to-server memakai header Authorization: Bearer mms_live_... (atau mms_test_... untuk sandbox). Buat key di menu Developers — key hanya ditampilkan sekali dan disimpan sebagai hash SHA-256.

Jangan pernah menaruh mms_live_ di frontend. Untuk browser gunakan public widget key mms_pub_... yang dibatasi allowed origins.

Semua error berbentuk { "error": { "code": "STRING_CODE", "message": "..." } } dengan HTTP status yang sesuai. Lihat tabel di bagian Kode Error.

Info workspace

GET/v1/me Gratis

Mengambil detail workspace, saldo creditMo, pemakaian kuota, serta status koneksi WhatsApp & listener mutasi.

Response

workspace

object

id, name, planTier, planExpiresAt, creditMoBalance, defaultWaProvider, webhookUrl, publicWidgetKey

usage

object

email, emailDaily, mutation, wa → { used, limit } (-1 = unlimited)

status

object

wa: connected|disconnected|pairing, mutationListener: online|offline

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/me" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Memulai

Tarif creditMo

Saldo dompet disebut creditMo. Pemakaian di dalam kuota paket tidak memotong saldo; di luar kuota (atau di paket PAYG) dipotong sesuai tarif berikut. Pengiriman WhatsApp yang gagal otomatis di-refund (event whatsapp.failed_refunded).

LayananTarif PAYG
Verifikasi mutasi / invoice lunas0,3% dari nominal (dibulatkan ke atas)
Email300 creditMo
WhatsApp Baileys500 creditMo
WhatsApp Cloud API resmi200 creditMo
Pesan masuk & chat widget0 (gratis)
PaketHarga / 30 hariEmailMutasiWAAgenFitur
PAYG00001—
Free0300 (100/hari)001—
Bronze66.0001.5003002002—
Silver110.0003.0007005005broadcast
Gold188.0003.000Unlimited1.00010broadcast, auto_reply
Diamond299.000UnlimitedUnlimited1.500Unlimitedbroadcast, auto_reply, api, webhook, custom_widget

Top up creditMo

POST/v1/billing/topup Gratis

Membuat invoice QRIS untuk menambah saldo. Saldo bertambah otomatis ketika invoice berstatus PAID.

Request body

amountwajib

integer

Nominal top up, minimal 10.000

Response

invoice

Invoice

Invoice QRIS (lihat bagian Invoice & QRIS)

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/billing/topup" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "amount": 100000
}'
Try It
POST

Riwayat saldo

GET/v1/billing/ledger?limit=50 Gratis

Buku besar dompet: top up, pemakaian, refund dan langganan.

Response

data[]

LedgerEntry

id, type (topup|debit|refund|subscription), amount, balanceAfter, description, refId, createdAt

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/billing/ledger?limit=50" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Messaging

Kirim WhatsApp

Pesan dirender di server: variabel {{nama}} diisi dari params, dan spintax {Halo|Hai|Selamat pagi} dipilih acak per pesan. Request langsung dibalas 202 dan diproses antrean (rate limit 15 pesan/menit per sesi Baileys).

Isi fallback_to_email: true (pakai field email / email kontak) atau langsung alamat email. Bila WhatsApp gagal (nomor tidak terdaftar / sesi terputus), creditMo WA di-refund dan pesan dikirim lewat email (300 creditMo).

Kirim pesan WhatsApp

POST/v1/whatsapp/send 500 (Baileys) / 200 (Official) creditMo

Mengantrekan satu pesan WhatsApp. Saldo dipotong saat antre dan di-refund bila gagal.

Request body

towajib

string

Nomor tujuan format internasional, mis. 6281234567890

message

string

Isi pesan (mendukung {{var}} dan spintax). Wajib jika tanpa template

template

string

Nama template (Cloud API resmi)

params

Record<string,string>

Nilai variabel, mis. { "nama": "Ahmad" }

provider

"baileys" | "official"

Override provider default workspace

email

string

Email penerima (disimpan ke kontak, dipakai fallback)

fallback_to_email

boolean | string

true = fallback ke email kontak; atau alamat email cadangan

Response

id

string

ID pesan

status

"queued"

Selalu queued saat diterima

provider

string

Provider yang dipakai

charged

integer

creditMo yang dipotong (0 jika masih dalam kuota)

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/whatsapp/send" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "6281234567890",
  "message": "{Halo|Hai} {{nama}}, pesanan #2940 sudah dikirim 🚚",
  "params": {
    "nama": "Ahmad"
  },
  "provider": "baileys",
  "email": "ahmad.s@gmail.com",
  "fallback_to_email": true
}'
Try It
POST

Status sesi Baileys

GET/v1/whatsapp/session?method=qr Gratis

Status koneksi beserta QR mentah (method=qr) atau kode pairing (method=code). Dengan method=qr, sesi yang terputus otomatis dimulai ulang agar QR baru muncul; dengan method=code tidak dimulai ulang otomatis.

Response

status

"connected" | "pairing" | "disconnected"

Status sesi

method

"qr" | "code"

Metode pairing yang sedang aktif

qr

string | null

Teks QR (render dengan library QR apa pun)

pairingCode

string | null

Kode 8 karakter, mis. "ABCD-EFGH"

pairingError

string | null

Mis. kode kedaluwarsa

phone

string | null

Nomor yang terhubung

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/whatsapp/session?method=qr" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Login dengan kode pairing

POST/v1/whatsapp/pair-code Gratis

Alternatif scan QR. Di HP: WhatsApp → Perangkat tertaut → Tautkan perangkat → "Tautkan dengan nomor telepon saja" → masukkan kode. Kode berlaku ±2 menit; pantau status lewat GET /v1/whatsapp/session?method=code. Maksimal 5 permintaan per 10 menit.

Request body

phonewajib

string

Nomor WhatsApp yang ditautkan, mis. 6281234567890

Response

status

"pairing" | "connected"

"connected" bila sesi sudah tertaut

pairingCode

string

Kode 8 karakter untuk dimasukkan di HP

pairingPhone

string

Nomor yang dipasangkan

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/whatsapp/pair-code" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "phone": "6281234567890"
}'
Try It
POST

Messaging

Kirim Email (Resend-compatible)

Skema request & response mengikuti Resend sehingga integrasi Resend cukup diganti base URL & API key. Email dikirim lewat Pool B — rotasi akun Gmail/Zoho/SMTP (akun aktif dengan sentToday < dailyLimit, urutan paling lama tidak dipakai) — lengkap dengan pixel open (/o/:id.gif) dan pembungkus klik (/c/:id?url=).

PaketKuota emailOverage / PAYG
Free300/bulan, maks 100/hari300 creditMo / email
Bronze1.500/bulan300 creditMo / email
Silver3.000/bulan300 creditMo / email
Gold3.000/bulan300 creditMo / email
DiamondUnlimited—

Kirim header Idempotency-Key pada setiap request. Retry dengan key yang sama mengembalikan respons pertama (header Idempotent-Replayed: true) tanpa memotong creditMo dan tanpa mengirim ulang. Key yang sama dengan body berbeda → 409 IDEMPOTENCY_KEY_REUSED.

Alamat di suppression list (bounce, complaint, unsubscribe) otomatis dibuang dari daftar penerima dan dilaporkan di field suppressed. Bila semua penerima di-suppress, respons 422 EMAIL_SUPPRESSED dan tidak ada creditMo yang dipotong. Hard bounce dari server SMTP otomatis masuk suppression list dengan reason bounce.

Siklus status: queued → sent (diterima server SMTP) → delivered (dibuka/diklik penerima). Gagal permanen menjadi bounced (alamat ditolak) atau failed; keduanya me-refund creditMo otomatis dan memicu webhook email.failed. Bila WhatsApp gagal dengan fallback_to_email: true, creditMo WA di-refund dan pesan dikirim ulang lewat email (300 creditMo).

Provider akun pengirimKredensialAlamat from
custom_smtpsmtpHost, smtpPort (465/587), smtpUser, password — hosting/cPanel, Google WorkspaceMailbox yang login
gmail_smtpsmtpUser + App Password (smtp.gmail.com:465, ±450/hari)Alamat @gmail.com akun tersebut
zoho_smtpsmtpUser + App-Specific Password (smtp.zoho.com:465)Mailbox yang login
brevo_apiapiKey v3 + fromEmail di domain terverifikasiAlamat apa pun di domain terverifikasi
resend_apiapiKey + fromEmail di domain terverifikasiAlamat apa pun di domain terverifikasi
Tambah akun SMTP domain sendiri
curl -X POST https://mymosend-api.khafi.workers.dev/v1/email/pool \
  -H "Authorization: Bearer mms_live_xxx" -H "Content-Type: application/json" \
  -d '{"provider":"custom_smtp","smtpHost":"mail.tokoanda.com","smtpPort":465,"smtpUser":"halo@tokoanda.com","password":"rahasia","fromName":"Toko Anda","dailyLimit":300}'

Aktifkan "Hanya kirim lewat domain sendiri" (PUT /v1/email/settings {"ownDomainOnly":true}) agar email tidak pernah dialihkan ke Pool B bersama. Dalam mode ini, request dengan domain from yang belum terdaftar ditolak 422 EMAIL_DOMAIN_NOT_CONFIGURED. Port 25 diblokir Cloudflare Workers.

Kirim email

POST/v1/emails 300 creditMo (setelah kuota paket habis)

Mengirim satu email transaksional. Kuota/creditMo dipotong atomik saat request diterima; di-refund otomatis jika gagal.

Header tambahan

Idempotency-Key

string

Contoh: order-3001-paid

Request body

fromwajib

string

"Nama <alamat@domain>"

towajib

string | string[]

Penerima (to+cc+bcc maks 50)

subjectwajib

string

Subjek

html

string

Isi HTML (pixel & link tracking disisipkan otomatis)

text

string

Isi teks polos

cc / bcc

string | string[]

Tembusan

reply_to

string | string[]

Alamat balasan

tags

{ name, value }[]

Tag (ikut dikirim di payload webhook)

Response

id

string (uuid)

ID email = trackingId

status

"queued" | "sent"

"sent" langsung untuk kunci mms_test_ (simulasi)

suppressed

string[]

Penerima yang dibuang karena suppression list

charged / charge_source

number / "quota" | "wallet"

creditMo yang dipotong & sumbernya

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/emails" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Idempotency-Key: order-3001-paid" \
  -H "Content-Type: application/json" \
  -d '{
  "from": "Toko Berkah <noreply@tokoberkah.id>",
  "to": [
    "ahmad.s@gmail.com"
  ],
  "subject": "Pembayaran ORDER-3001 diterima",
  "html": "<html><body><p>Halo Ahmad, terima kasih! <a href=\"https://tokoberkah.id/order/3001\">Lihat pesanan</a></p></body></html>",
  "tags": [
    {
      "name": "order",
      "value": "3001"
    }
  ]
}'
Try It
POST

Kirim batch

POST/v1/emails/batch 300 creditMo / email

Hingga 100 email dalam satu request. Setiap item diproses mandiri; HTTP 207 bila sebagian gagal. Idempotency-Key berlaku untuk seluruh batch.

Header tambahan

Idempotency-Key

string

Contoh: promo-payday-2026-11

Request body

[]wajib

EmailReq[]

Maksimal 100 item

Response

data[]

{ index, id, status } | { index, error }

Hasil per item sesuai urutan

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/emails/batch" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Idempotency-Key: promo-payday-2026-11" \
  -H "Content-Type: application/json" \
  -d '[
  {
    "from": "Toko Berkah <noreply@tokoberkah.id>",
    "to": "rina@contoh.id",
    "subject": "Promo Payday",
    "text": "Diskon 15% s/d Minggu!"
  },
  {
    "from": "Toko Berkah <noreply@tokoberkah.id>",
    "to": "budi@contoh.id",
    "subject": "Promo Payday",
    "text": "Diskon 15% s/d Minggu!"
  }
]'
Try It
POST

Daftar email

GET/v1/emails?status=delivered&limit=20 Gratis

Riwayat email terbaru. Filter `status` (queued, sent, delivered, bounced, failed), `limit` (maks 100), paginasi `before` (ISO date dari `next_before`).

Response

data[]

Email

Tanpa isi html/text

has_more / next_before

boolean / string

Paginasi

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/emails?status=delivered&limit=20" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Detail email & riwayat event

GET/v1/emails/4f8c2a1e-6b0d-4e7a-9a51-2d3c8e9f1a20 Gratis

Status, isi, dan timeline event (queued, sent, opened, clicked, bounced, failed) beserta user agent & IP.

Response

status

string

queued | sent | delivered | bounced | failed

events[]

{ type, at, target_url?, user_agent?, ip_address? }

Riwayat berurutan

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/emails/4f8c2a1e-6b0d-4e7a-9a51-2d3c8e9f1a20" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Daftar suppression

GET/v1/emails/suppressions?reason=bounce Gratis

Alamat yang tidak akan pernah dikirimi email. Filter opsional `reason`.

Response

data[]

{ id, email, reason, created_at }

reason: bounce | complaint | unsubscribe

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/emails/suppressions?reason=bounce" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Tambah suppression

POST/v1/emails/suppressions Gratis

Blokir satu atau banyak alamat (maks 500). Hapus dengan `DELETE /v1/emails/suppressions/:email`.

Request body

email / emailswajib

string | string[]

Alamat yang diblokir

reason

"bounce" | "complaint" | "unsubscribe"

Default unsubscribe

Response

data[]

{ email, reason, suppressed }

Alamat tersimpan

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/emails/suppressions" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "emails": [
    "rina@contoh.id"
  ],
  "reason": "unsubscribe"
}'
Try It
POST

Pembayaran

Invoice & QRIS

Invoice qris menghasilkan qrString QRIS dinamis (EMVCo, CRC16) dari merchant statis kamu — render sebagai kode QR. Invoice bank_transfer menambahkan uniqueCode 3 digit agar mutasi bisa dicocokkan. Saat mutasi cocok, status menjadi PAID dan webhook invoice.paid dikirim.

Fee verifikasi 0,3% dipotong dari saldo creditMo hanya ketika invoice lunas (atau memakai kuota mutasi paket).

Buat invoice

POST/v1/invoices 0,3% saat lunas

Membuat invoice QRIS dinamis atau transfer bank.

Request body

amountwajib

integer

Nominal rupiah

method

"qris" | "bank_transfer"

Default qris

reference

string

Nomor order kamu (unik)

description

string

Keterangan

conversationId

string

Tautkan ke percakapan inbox

expiresInMinutes

integer

Default 60

Response

invoice.id

string

ID invoice

invoice.totalAmount

integer

amount + uniqueCode

invoice.qrString

string | null

Payload QRIS dinamis

invoice.status

"UNPAID" | "PAID" | "EXPIRED"

Status

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/invoices" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "amount": 150000,
  "method": "qris",
  "reference": "ORDER-3001",
  "description": "Hijab Sage x3",
  "expiresInMinutes": 60
}'
Try It
POST

Cek status invoice

GET/v1/invoices/inv_01JD3001 Gratis

Polling status invoice (lebih disarankan memakai webhook invoice.paid).

Response

invoice

Invoice

Objek invoice terbaru

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/invoices/inv_01JD3001" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Pembayaran

Ingest Mutasi

Endpoint ingest terpadu menerima mutasi dari aplikasi Android Listener (token perangkat mmd_...), scraper internal, atau integrasi kustom. Gateway mencocokkan nominal dengan invoice UNPAID dan menandainya lunas.

  • Pair perangkat: POST /v1/devices/pair → masukkan pairingCode di aplikasi.
  • Aplikasi menyimpan deviceToken dan mengirim tiap notifikasi uang masuk.
  • Gunakan externalId unik agar mutasi yang sama tidak diproses dua kali.

Pair perangkat Android

POST/v1/devices/pair Gratis

Membuat kode pairing & token perangkat untuk Android Listener.

Response

pairingCode

string

Kode 6 digit untuk aplikasi

deviceToken

string

Token mmd_... (tampil sekali)

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/devices/pair" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
Try It
POST

Ingest mutasi

POST/v1/ingest/mutation Gratis (fee saat cocok)Bearer mmd_…

Mengirim satu mutasi masuk untuk dicocokkan dengan invoice.

Request body

sourcewajib

"android_listener" | "klikbca" | "gobiz" | "dana_bisnis"

Asal mutasi

bankCodewajib

string

BCA, QRIS, GOPAY, DANA, ...

amountwajib

integer

Nominal masuk

descriptionwajib

string

Keterangan mutasi

rawText

string

Teks notifikasi asli

externalId

string

ID unik untuk deduplikasi

receivedAt

ISO 8601

Waktu diterima

Response

matched

boolean

Apakah cocok dengan invoice

invoiceId

string | null

Invoice yang dilunasi

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/ingest/mutation" \
  -H "Authorization: Bearer $MYMOSEND_DEVICE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "source": "android_listener",
  "bankCode": "QRIS",
  "amount": 150000,
  "description": "Pembayaran QRIS diterima Rp150.000",
  "rawText": "BCA: Dana masuk Rp150.000 via QRIS",
  "externalId": "notif-1732874620123",
  "receivedAt": "2026-11-29T10:03:39.000Z"
}'
Try It
POST

Messaging

Omnichannel

Semua pesan masuk dari WhatsApp Baileys, Cloud API resmi, dan widget website digabung menjadi percakapan per kontak. Balasan otomatis dikirim lewat kanal asal. Pesan bertipe qris membawa meta = { invoiceId, amount, qrString, status } sehingga klien bisa menampilkan kartu pembayaran.

Daftar percakapan

GET/v1/conversations?status=open&channel=wa_baileys Gratis

Filter berdasarkan status, kanal, dan kata kunci (q).

Response

data[]

Conversation

id, contact, channel, status, assignedAgentId, unreadCount, lastMessageAt, lastMessagePreview

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/conversations?status=open&channel=wa_baileys" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY"
Try It
GET

Balas percakapan

POST/v1/conversations/cv_01/reply Sesuai kanal (WA 500/200, widget 0)

Mengirim balasan teks atau kartu QRIS ke kontak.

Request body

bodywajib

string

Isi pesan

type

"text" | "qris"

Default text

invoiceId

string

Wajib jika type = qris

Response

message

Message

Pesan yang dibuat

charged

integer

creditMo terpotong

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/conversations/cv_01/reply" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "body": "Dynamic QRIS payment",
  "type": "qris",
  "invoiceId": "inv_01JD3001"
}'
Try It
POST

Perbarui kontak

PATCH/v1/contacts/ct_01 Gratis

Ubah nama, email, atau tag kontak (dipakai untuk target broadcast).

Request body

name

string

Nama

email

string

Email

tags

string[]

Mengganti seluruh tag

Response

contact

Contact

Kontak terbaru

curl -X PATCH "https://mymosend-api.khafi.workers.dev/v1/contacts/ct_01" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "tags": [
    "Banten",
    "VIP Member",
    "Reseller"
  ]
}'
Try It
PATCH

Integrasi

Widget website

Cukup tempel satu baris script. Widget memuat konfigurasi (warna, sapaan, mode, nomor WA, QRIS) dari workspace kamu memakai public key mms_pub_.... Ubah tampilan kapan saja dari menu Channels › Website Widget tanpa mengubah kode.

Script tag
<!-- Tempel sebelum </body> -->
<script src="https://mymosend-app.pages.dev/widget.js" data-key="mms_pub_xxxxxxxxxxxxxxxx" async></script>
  • WordPress: Appearance › Theme File Editor › footer.php, atau plugin “Insert Headers and Footers”.
  • Shopify: Online Store › Themes › Edit code › theme.liquid sebelum </body>.
  • Google Tag Manager: tag Custom HTML, trigger All Pages.
  • Isi allowed origins agar key tidak bisa dipakai di domain lain.

Konfigurasi widget

GET/v1/widget/config GratisX-MyMosend-Key

Dipanggil otomatis oleh widget.js.

Response

name

string

Nama workspace

theme

{ primary, position }

Warna & posisi

greeting

string

Sapaan

mode

"chat" | "whatsapp" | "both"

Mode tampilan

whatsappNumber

string

Nomor WA

qrisEnabled

boolean

Checkout QRIS aktif

curl -X GET "https://mymosend-api.khafi.workers.dev/v1/widget/config" \
  -H "X-MyMosend-Key: $MYMOSEND_PUBLIC_KEY"
Try It
GET

Checkout QRIS dari widget

POST/v1/widget/checkout 0,3% saat lunasX-MyMosend-Key

Membuat invoice QRIS dari pengunjung website.

Request body

amountwajib

integer

Nominal

name

string

Nama pengunjung

email

string

Email pengunjung

description

string

Keterangan

Response

invoice

Invoice

Invoice QRIS

curl -X POST "https://mymosend-api.khafi.workers.dev/v1/widget/checkout" \
  -H "X-MyMosend-Key: $MYMOSEND_PUBLIC_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "amount": 99000,
  "name": "Siti",
  "email": "siti.nur@outlook.com",
  "description": "Langganan 3 bulan"
}'
Try It
POST

Integrasi

Webhook (integrasi 2 arah)

Integrasi 2 arah: (1) aplikasi kamu memanggil REST API My Mosend (kirim WA, buat invoice, dll.) dengan API key; (2) My Mosend memanggil balik URL webhook kamu setiap ada kejadian — invoice lunas, pesan terkirim/gagal, email dibuka.

ArahPemanggilAutentikasi
Client → My MosendServer kamuAuthorization: Bearer mms_live_...
My Mosend → ClientGateway My MosendX-MyMosend-Signature = HMAC-SHA256 hex atas raw body

Body webhook: { id, type, created_at, data }. Signature: X-MyMosend-Signature = hex(HMAC_SHA256(webhookSecret, rawBody)) — hitung dari raw body persis seperti diterima, bandingkan dengan perbandingan waktu-konstan. Header tambahan: X-MyMosend-Event (tipe event), X-MyMosend-Delivery (= id, simpan untuk dedupe) dan X-MyMosend-Timestamp (unix detik). Balas 2xx dalam 10 detik; kegagalan dicoba ulang dengan backoff hingga 5 kali.

EventKapandata
invoice.paidMutasi cocok dengan invoiceInvoice (status PAID, paidAt)
whatsapp.inboundPesan WA masuk{ conversationId, from, text }
whatsapp.sentPesan WA terkirim/terbaca{ id, to, provider, status }
whatsapp.failed_refundedWA gagal & creditMo dikembalikan{ id, to, reason, refunded }
email.sentEmail diterima server SMTP/API{ email_id, from, to, subject, tags, provider_message_id, charged, sent_at }
email.failedGagal permanen / bounce (creditMo di-refund){ email_id, to, status, error, refunded }
email.openedPixel open pertama terbaca{ email_id, to, subject, user_agent, ip_address, opened_at }
email.clickedLink di email diklik{ email_id, to, url, user_agent, ip_address, clicked_at }
Contoh payload invoice.paid
POST /api/mymosend/webhook HTTP/1.1
Content-Type: application/json
X-MyMosend-Event: invoice.paid
X-MyMosend-Delivery: evt_01JDB0Q1
X-MyMosend-Signature: 5f2b7c0e9a41d3...

{
  "id": "evt_01JDB0Q1",
  "type": "invoice.paid",
  "created_at": "2026-11-29T10:03:40.000Z",
  "data": {
    "id": "inv_01JD3001",
    "reference": "ORDER-3001",
    "totalAmount": 150000,
    "status": "PAID",
    "paidAt": "2026-11-29T10:03:40.000Z"
  }
}
Contoh payload email.opened
POST /api/mymosend/webhook HTTP/1.1
Content-Type: application/json
X-MyMosend-Event: email.opened
X-MyMosend-Delivery: evt_01JDB2X7
X-MyMosend-Signature: 9a0c51e2b7...

{
  "id": "evt_01JDB2X7",
  "type": "email.opened",
  "created_at": "2026-11-29T10:05:41.000Z",
  "data": {
    "email_id": "4f8c2a1e-6b0d-4e7a-9a51-2d3c8e9f1a20",
    "from": "Toko Berkah <noreply@tokoberkah.id>",
    "to": ["ahmad.s@gmail.com"],
    "subject": "Pembayaran ORDER-3001 diterima",
    "tags": [{ "name": "order", "value": "3001" }],
    "user_agent": "Mozilla/5.0",
    "ip_address": "66.249.84.10",
    "opened_at": "2026-11-29T10:05:40.000Z"
  }
}

Verifikasi signature

import crypto from 'node:crypto';
import express from 'express';

const app = express();
const SECRET = process.env.MYMOSEND_WEBHOOK_SECRET!;

// X-MyMosend-Signature = hex(HMAC-SHA256(webhookSecret, rawBody))
// Penting: pakai raw body — JSON yang sudah di-parse mengubah byte & merusak signature.
app.post('/api/mymosend/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const signature = req.header('X-MyMosend-Signature') ?? '';
  const rawBody = req.body as Buffer;

  const expected = crypto.createHmac('sha256', SECRET).update(rawBody).digest('hex');
  const valid =
    signature.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(expected, 'hex'), Buffer.from(signature, 'hex'));
  if (!valid) return res.status(401).json({ error: 'invalid signature' });

  const event = JSON.parse(rawBody.toString('utf8')) as { id: string; type: string; created_at: string; data: any };
  // Simpan event.id (= header X-MyMosend-Delivery) agar retry tidak diproses dua kali.
  switch (event.type) {
    case 'email.sent':
      console.log('terkirim', event.data.email_id, event.data.provider_message_id);
      break;
    case 'email.opened':
      console.log('dibuka', event.data.email_id, event.data.opened_at);
      break;
    case 'email.clicked':
      console.log('diklik', event.data.email_id, event.data.url);
      break;
    case 'email.failed':
      // creditMo sudah di-refund otomatis; status "bounced" → alamat masuk suppression list
      break;
    case 'invoice.paid':
      // tandai order lunas: event.data.reference, event.data.totalAmount
      break;
  }
  res.json({ received: true });
});

app.listen(3000);

Atur URL webhook

PUT/v1/webhook Gratis (paket Diamond)

Menyimpan URL tujuan dan membuat signing secret baru (tampil sekali).

Request body

urlwajib

string (https)

Endpoint penerima webhook

Response

webhookUrl

string

URL tersimpan

webhookSecret

string

Secret HMAC whsec_...

curl -X PUT "https://mymosend-api.khafi.workers.dev/v1/webhook" \
  -H "Authorization: Bearer $MYMOSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://tokoberkah.id/api/mymosend/webhook"
}'
Try It
PUT

Referensi

Kode Error

Periksa error.code (bukan hanya HTTP status) untuk menangani kasus spesifik.

HTTPKodeArti & penanganan
400VALIDATION_ERRORBody/parameter tidak valid. Periksa error.message.
401UNAUTHORIZEDAPI key tidak ada, salah, atau sudah dicabut.
402INSUFFICIENT_CREDIT_MOSaldo creditMo tidak cukup. Top up lalu ulangi.
403FORBIDDEN / PLAN_FEATURE_LOCKEDOrigin widget tidak diizinkan, atau fitur butuh paket lebih tinggi.
404NOT_FOUNDResource tidak ditemukan.
422WA_PAIRING_FAILEDWhatsApp gagal menerbitkan kode pairing (nomor salah / terlalu sering). Coba lagi atau pakai scan QR.
409IDEMPOTENCY_CONFLICTRequest dengan Idempotency-Key yang sama masih diproses. Tunggu lalu ulangi.
409IDEMPOTENCY_KEY_REUSEDIdempotency-Key dipakai ulang dengan body berbeda.
422EMAIL_SUPPRESSEDSemua penerima ada di suppression list — tidak dikirim, tidak dipotong. Lihat error.details.suppressed.
422EMAIL_DOMAIN_NOT_CONFIGUREDMode domain sendiri aktif, tetapi domain alamat from belum punya akun pengirim.
422WA_SESSION_DISCONNECTEDSesi WhatsApp Baileys terputus — scan ulang QR atau pakai provider official.
429RATE_LIMIT_EXCEEDEDTerlalu banyak request (WA: 15/menit per sesi). Ulangi dengan backoff.
500INTERNAL_ERRORKesalahan server. Aman untuk retry dengan Idempotency-Key.
Contoh respons error
HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": {
    "code": "INSUFFICIENT_CREDIT_MO",
    "message": "Saldo creditMo tidak cukup (butuh 500, sisa 120)."
  }
}