Lewati ke konten

Pesan Template

Template WhatsApp diperlukan untuk mengirim pesan di luar window 24 jam (pembuka percakapan). Template harus dalam status APPROVED di Meta sebelum dapat digunakan.

Kelola template di cpaas.id halaman Template Pesan.

{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "template",
"template": {
"name": "order_confirmation",
"language": {
"code": "id"
},
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John Doe" },
{ "type": "text", "text": "ORD-12345" }
]
}
]
}
}
FieldTipeWajibKeterangan
namestringYaNama template (harus sudah APPROVED)
languageobjectYaObjek bahasa dengan field code
componentsarrayTidakArray komponen dinamis (header, body, button)
FieldTipeWajibKeterangan
codestringYaKode bahasa/locale, misalnya "id", "en_US", "en"
FieldTipeWajibKeterangan
typestringYaJenis komponen: "header", "body", "button"
parametersarrayTidakParameter dinamis untuk komponen ini
sub_typestringTidakSub-tipe untuk button: "url", "quick_reply"
indexstring/numberTidakIndeks button (0-based), untuk komponen button

Setiap parameter dalam parameters memiliki field type:

TipeContohKeterangan
text{ "type": "text", "text": "John" }Parameter teks
image{ "type": "image", "image": { "link": "..." } }Gambar di header
document{ "type": "document", "document": { "link": "..." } }Dokumen di header
currency{ "type": "currency", "currency": { "fallback_value": "Rp 150.000", "code": "IDR", "amount_1000": 150000000 } }Nilai mata uang
coupon_code{ "type": "coupon_code", "coupon_code": "DISKON50" }Kode kupon
{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "template",
"template": {
"name": "payment_reminder",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Budi Santoso" },
{ "type": "currency", "currency": { "fallback_value": "Rp 250.000", "code": "IDR", "amount_1000": 250000000 } }
]
},
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{ "type": "text", "text": "INV-2026-001" }
]
}
]
}
}
Terminal window
curl -X POST https://messaging.cpaas.id/v1/YOUR_PHONE_NUMBER_ID/messages \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"to": "6281234567890",
"type": "template",
"template": {
"name": "order_confirmation",
"language": { "code": "id" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John Doe" },
{ "type": "text", "text": "ORD-12345" }
]
}
]
}
}'
{
"messaging_product": "whatsapp",
"messages": [
{
"id": "msg_f7a816e2-8397-11f0-8e34-010203040506"
}
]
}
  1. message.status.sent — Template berhasil dikirim
  2. message.status.delivered — Template sampai ke perangkat penerima
  3. message.status.read — Template dibaca oleh penerima

Selain itu, Anda juga dapat menerima event terkait status template itu sendiri:

EventKeterangan
template_status_updateStatus template berubah (APPROVED, REJECTED, PENDING)
template_quality_updateUpdate kualitas template
template_category_updatePerubahan kategori template oleh Meta

Lihat halaman Webhook untuk detail format payload setiap event.