Langsung ke konten utama

Mengirim Pesan

Semua pesan dikirim melalui satu endpoint. Field type menentukan jenis pesan yang dikirim, dan field lainnya berubah sesuai dengan jenis pesan tersebut. Endpoint:
POST https://api.wappfy.io/api/instances/{instanceId}/messages/send
Header:
HeaderNilai
X-Api-KeyAPI key Anda
Content-Typeapplication/json

Pesan Teks

Kirim pesan teks biasa.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "text",
    "text": "Hello from Wappfy!"
  }'
Respons:
{
  "data": {
    "message_id": "BAE5F2C4D3B2A1",
    "status": "sent"
  }
}

Pesan Gambar

Kirim gambar dengan keterangan opsional.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "image",
    "media_url": "https://example.com/photo.jpg",
    "caption": "Check out this photo!"
  }'

Pesan Video

Kirim file video dengan keterangan opsional.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "video",
    "media_url": "https://example.com/clip.mp4",
    "caption": "Watch this!"
  }'

Pesan Audio

Kirim file audio. Pesan audio muncul sebagai pesan suara di WhatsApp.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "audio",
    "media_url": "https://example.com/voice-note.ogg"
  }'
Untuk kompatibilitas terbaik, gunakan file .ogg yang di-encode dengan codec Opus untuk pesan suara.

Pesan Dokumen

Kirim file sebagai lampiran dokumen.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "document",
    "media_url": "https://example.com/report.pdf",
    "filename": "Q1-Report.pdf",
    "caption": "Here is the quarterly report"
  }'

Pesan Lokasi

Kirim pin lokasi geografis.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "location",
    "latitude": -23.5505,
    "longitude": -46.6333,
    "name": "Sao Paulo",
    "address": "Sao Paulo, SP, Brazil"
  }'

Pesan Polling

Buat polling interaktif. Penerima dapat memberikan suara langsung di WhatsApp.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "poll",
    "poll_name": "What day works best for the meeting?",
    "poll_options": ["Monday", "Wednesday", "Friday"],
    "poll_allow_multiple": false
  }'

Pesan Kontak / vCard

Bagikan kartu kontak.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "contact",
    "contact_name": "Maria Silva",
    "contact_phone": "+5511988887777"
  }'

Teruskan Pesan

Teruskan pesan yang sudah ada ke chat lain.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "forward",
    "forward_message_id": "BAE5F2C4D3B2A1",
    "forward_chat_id": "[email protected]"
  }'

Reaksi

Bereaksi terhadap pesan dengan emoji.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "reaction",
    "reaction_message_id": "BAE5F2C4D3B2A1",
    "reaction": "\ud83d\udc4d"
  }'
Untuk menghapus reaksi, kirim string kosong sebagai nilai reaction.

Fitur Lanjutan

Membalas Pesan

Kutip pesan sebelumnya dengan menyertakan quoted_message_id. Ini berfungsi dengan semua jenis pesan.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "text",
    "text": "Yes, I agree with this!",
    "quoted_message_id": "BAE5F2C4D3B2A1"
  }'

Mengedit Pesan Terkirim

Edit pesan yang sebelumnya Anda kirim dengan menyertakan edit_message_id.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "text",
    "text": "Updated message content",
    "edit_message_id": "BAE5F2C4D3B2A1"
  }'
Anda hanya dapat mengedit pesan yang Anda kirim sendiri. Pengeditan memiliki batasan waktu yang ditetapkan oleh WhatsApp (kurang lebih 15 menit setelah pengiriman).

Mention

Mention kontak tertentu dalam pesan grup. Kontak yang di-mention akan menerima notifikasi.
curl -X POST https://api.wappfy.io/api/instances/inst_abc123/messages/send \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "[email protected]",
    "type": "text",
    "text": "Hey @Maria and @Carlos, please review this.",
    "mentions": [
      "[email protected]",
      "[email protected]"
    ]
  }'

Format Chat ID

FormatDeskripsiContoh
{phone}@s.whatsapp.netChat individual[email protected]
{id}@g.usChat grup[email protected]

Nomor Telepon Brasil

Wappfy secara otomatis menangani masalah digit ke-9 nomor Brasil. Jika pesan gagal dengan error “no LID found”, sistem akan secara otomatis mencoba ulang dengan format alternatif (menambahkan atau menghapus digit ke-9).Sebagai contoh, jika 5511999998888 gagal, sistem akan mencoba ulang dengan 551199998888, dan sebaliknya. Ini terjadi secara transparan — Anda tidak perlu menanganinya sendiri.

Referensi Jenis Pesan

JenisField WajibField Opsional
texttextquoted_message_id, edit_message_id, mentions
imagemedia_urlcaption, quoted_message_id
videomedia_urlcaption, quoted_message_id
audiomedia_urlquoted_message_id
documentmedia_urlfilename, caption, quoted_message_id
locationlatitude, longitudename, address, quoted_message_id
pollpoll_name, poll_optionspoll_allow_multiple
contactcontact_name, contact_phonequoted_message_id
forwardforward_message_id, forward_chat_id
reactionreaction_message_id, reaction

Penanganan Error

Kode StatusDeskripsi
400Payload pesan tidak valid (misalnya, field wajib tidak ada untuk jenis yang diberikan).
404Instance tidak ditemukan atau tidak terhubung.
422Validasi pesan gagal (misalnya, format nomor telepon tidak valid).
429Batas laju terlampaui. Lihat Batas Laju.
502Provider WhatsApp mengembalikan error. Periksa pesan error untuk detailnya.