WASERVICES DEVELOPER PLATFORM

API Documentation

Integrasikan WhatsApp device, pesan asynchronous, status delivery, webhook, contact, campaign, dan workflow WaServices.

Production base URLhttps://wa.shockedlizard.com/api/public/v1

01

Authentication

Public API memakai bearer API key. Secret hanya tampil sekali saat dibuat atau dirotasi; PostgreSQL hanya menyimpan hash.

Authorization: Bearer wsk_<prefix>.<secret>
Content-Type: application/json
X-Request-Id: your-unique-request-id
Scopedevices:read, messages:read, messages:send
RestrictionKey dapat dibatasi berdasarkan IP, device, expiry, dan request per menit.
RotationRotasi mencabut key lama dan menghasilkan secret baru satu kali.

02

Quick start

  1. Hubungkan devicePastikan status CONNECTED.
  2. Buat API keyPilih scope dan device minimum.
  3. Ambil device IDPanggil GET /devices.
  4. Kirim pesanPanggil POST /messages/text.
  5. Pantau hasilGunakan webhook untuk status akhir.
curl -X POST 'https://wa.shockedlizard.com/api/public/v1/messages/text' \
  -H 'Authorization: Bearer wsk_xxx.yyy' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: order-2026-0001' \
  -d '{"deviceId":"cm_device","recipient":"628123456789","text":"Halo dari WaServices","clientReferenceId":"order-2026-0001"}'

03

Public API endpoints

Endpoint berikut boleh dipanggil sistem eksternal menggunakan API key.

POST/devicesBuat devicedevices:write

Buat dan alokasikan device ke gateway node. Error NO_NODE_CAPACITY bila slot penuh.

JSON body

{"name":"Customer Service"}

Response

{"data":{"id":"cm_device","name":"Customer Service","status":"DISCONNECTED","enabled":true}}
GET/devices/:idDetail devicedevices:read

Detail satu device milik tenant.

Response

{"data":{"id":"cm_device","name":"Customer Service","phone":"62812...","status":"CONNECTED","enabled":true}}
PATCH/devices/:idUpdate devicedevices:write

Rename atau enable/disable device.

JSON body

{"name":"CS Utama","enabled":true}

Response

{"data":{"id":"cm_device","name":"CS Utama","enabled":true}}
DELETE/devices/:idHapus devicedevices:write

Nonaktifkan device dan lepaskan slot node.

Response

{"data":{"id":"cm_device","status":"DISABLED","enabled":false}}
GET/devices/:id/qrMinta QR logindevices:write

QR untuk scan WhatsApp. Berlaku singkat, jangan dibagikan.

Response

{"data":{"qr":"data:image/png;base64,...","expiresInSeconds":30}}
POST/devices/:id/pairing-codeMinta pairing codedevices:write

Pairing lewat nomor telepon tanpa scan QR.

JSON body

{"phone":"628123456789"}

Response

{"data":{"code":"ABCD-1234"}}
POST/devices/:id/statusRefresh status devicedevices:read

Tarik status terbaru dari provider.

Response

{"data":{"id":"cm_device","status":"CONNECTED"}}
POST/devices/:id/reconnectReconnect devicedevices:write

Minta provider menyambungkan ulang sesi.

Response

{"data":{"id":"cm_device","status":"RECONNECTING"}}
POST/devices/:id/logoutLogout devicedevices:write

Putuskan sesi WhatsApp di device.

Response

{"data":{"id":"cm_device","status":"LOGGED_OUT"}}
GET/messagesDaftar pesanmessages:read

Filter deviceId/status/type, cursor pagination (take max 100).

Response

{"data":[{"id":"cm_message","deviceId":"cm_device","direction":"OUTBOUND","type":"TEXT","status":"SENT","recipient":"62812...","text":"Halo"}],"nextCursor":null}
GET/messages/:idDetail pesanmessages:read

Termasuk attempt history dan event.

Response

{"data":{"id":"cm_message","status":"DELIVERED","attemptHistory":[],"events":[]}}
DELETE/messages/:idBatalkan pesanmessages:send

Hanya untuk status DRAFT/SCHEDULED/QUEUED.

Response

{"data":{"id":"cm_message","status":"CANCELED"}}
POST/messages/:id/retryRetry pesan gagalmessages:send

Hanya failure sementara (gateway/timeout) yang bisa di-retry.

Response

{"data":{"id":"cm_message","status":"QUEUED"}}
POST/messages/textKirim pesan teksmessages:send

Persist pesan dan antrekan ke BullMQ. HTTP 202 berarti queued, bukan delivered.

JSON body

{"deviceId":"cm_device","recipient":"628123456789","text":"Halo dari API","clientReferenceId":"order-2026-0001"}

Response

{"data":{"id":"cm_message","status":"QUEUED","type":"TEXT","recipient":"628123456789"}}
POST/messages/imageKirim gambarmessages:send

multipart/form-data: deviceId, recipient, file, caption opsional. Juga tersedia /document, /video, /audio, /voice, /sticker.

JSON body

multipart: deviceId=cm_device recipient=628123456789 file=@foto.jpg caption=Promo

Response

{"data":{"id":"cm_message","status":"QUEUED","type":"IMAGE"}}
POST/messages/locationKirim lokasimessages:send

Kirim koordinat latitude/longitude.

JSON body

{"deviceId":"cm_device","recipient":"628123456789","latitude":-6.2,"longitude":106.8}

Response

{"data":{"id":"cm_message","status":"QUEUED","type":"LOCATION"}}
POST/messages/contactKirim kartu kontakmessages:send

Kirim vCard sederhana.

JSON body

{"deviceId":"cm_device","recipient":"628123456789","contactName":"Admin","contactPhone":"628999999999"}

Response

{"data":{"id":"cm_message","status":"QUEUED","type":"CONTACT"}}
GET/contactsDaftar kontakcontacts:read

Filter search/tag, cursor pagination.

Response

{"data":[{"id":"cm_contact","phone":"628123456789","name":"Budi","tags":["vip"]}]}
POST/contactsBuat kontakcontacts:write

Phone dinormalisasi ke format internasional.

JSON body

{"phone":"08123456789","name":"Budi","email":"budi@mail.com","tags":["vip"]}

Response

{"data":{"id":"cm_contact","phone":"628123456789","name":"Budi"}}
GET/contacts/:idDetail kontakcontacts:read

Termasuk keanggotaan grup.

Response

{"data":{"id":"cm_contact","phone":"628123456789","name":"Budi","groupMembers":[]}}
PATCH/contacts/:idUpdate kontakcontacts:write

Update sebagian field kontak.

JSON body

{"name":"Budi Santoso","tags":["vip","reseller"]}

Response

{"data":{"id":"cm_contact","name":"Budi Santoso"}}
DELETE/contacts/:idHapus kontakcontacts:write

Respons 204 tanpa body.

Response

(204 No Content)
GET/campaignsDaftar campaigncampaigns:read

Filter status/search, cursor pagination.

Response

{"data":[{"id":"cm_campaign","name":"Promo","status":"RUNNING","messageType":"TEXT"}]}
POST/campaignsBuat campaigncampaigns:write

Device harus CONNECTED. Template mendukung placeholder dan spintax.

JSON body

{"name":"Promo Oktober","template":"Halo {{name}}!","audience":{"tags":["vip"]},"deviceIds":["cm_device"],"throttlePerMinute":30}

Response

{"data":{"id":"cm_campaign","status":"DRAFT"}}
GET/campaigns/:idDetail campaigncampaigns:read

Termasuk metrics per status recipient.

Response

{"data":{"id":"cm_campaign","status":"RUNNING","metrics":{"sent":10,"delivered":8},"total":20}}
POST/campaigns/:id/startMulai campaigncampaigns:write

Juga tersedia /pause, /resume, /cancel.

Response

{"data":{"id":"cm_campaign","status":"RUNNING"}}
GET/campaigns/:id/recipientsDaftar penerima campaigncampaigns:read

Status per penerima + pesan terkait.

Response

{"data":[{"id":"cm_recipient","phone":"62812...","status":"SENT"}]}
GET/webhooksDaftar webhook endpointwebhooks:read

Semua endpoint webhook tenant. Filter per device dengan ?deviceId=<id>.

Response

{"data":[{"id":"cm_webhook","name":"CRM Hook","url":"https://crm.example.com/hook","events":["message.inbound"],"enabled":true,"deviceId":null}]}
POST/webhooksBuat webhook endpointwebhooks:write

Secret hanya ditampilkan sekali. Simpan untuk verifikasi X-Hub-Signature-256. URL privat/loopback ditolak. deviceId opsional: isi untuk webhook khusus satu device, kosongkan/null untuk semua device.

JSON body

{"name":"CRM Hook","url":"https://crm.example.com/hook","events":["message.inbound","message.sent","message.delivered"],"deviceId":"cm_device"}

Response

{"data":{"endpoint":{"id":"cm_webhook","name":"CRM Hook"},"secret":"whsec_..."}}
PATCH/webhooks/:idUpdate / rotate secretwebhooks:write

Kirim rotateSecret:true untuk secret baru (sekali tampil). deviceId: string untuk scope per device, null untuk tenant-wide.

JSON body

{"enabled":false,"deviceId":null}

Response

{"data":{"id":"cm_webhook","enabled":false}}
DELETE/webhooks/:idHapus webhook endpointwebhooks:write

Respons 204 tanpa body.

Response

(204 No Content)
GET/webhook-deliveriesDaftar deliverywebhooks:read

100 delivery terbaru + attempt terakhir.

Response

{"data":[{"id":"cm_delivery","eventType":"message.inbound","status":"DELIVERED"}]}
GET/webhook-deliveries/:idDetail deliverywebhooks:read

Payload + seluruh attempt history.

Response

{"data":{"id":"cm_delivery","status":"FAILED","attempts":[{"attemptNumber":1,"responseStatus":500}]}}
POST/webhook-deliveries/:id/resendKirim ulang deliverywebhooks:write

Membuat delivery baru dan antrekan ke worker.

Response

{"data":{"id":"cm_delivery_new","status":"PENDING"}}

04

Status dan error

StatusMaknaCode
200Request berhasil—
202Pesan dipersist dan masuk antrean—
400Payload tidak validVALIDATION_ERROR
401Key salah, expired, atau revokedINVALID_API_KEY
403Scope, IP, atau device ditolakINSUFFICIENT_SCOPE
429Rate limit terlampauiRATE_LIMITED
{"error":{"code":"INSUFFICIENT_SCOPE"}}

HTTP 202 bukan delivery success. Status bergerak dari QUEUED/PROCESSING menuju SENT, DELIVERED, READ, atau FAILED.

05

Customer webhooks

Delivery memakai worker terpisah, retry, attempt history, timeout, manual resend, dan perlindungan SSRF.

message.inboundmessage.outboundmessage.sentmessage.deliveredmessage.readmessage.faileddevice.connecteddevice.disconnectedcampaign.startedcampaign.completedqueue.updated

Signature verification

const expected = createHmac("sha256", webhookSecret)
  .update(rawBody)
  .digest("hex");

const valid = timingSafeEqual(
  Buffer.from(receivedSignature),
  Buffer.from(expected)
);

Hitung signature dari raw body. Secret hanya terlihat sekali saat dibuat atau dirotasi.

Kelola webhook

06

Realtime SSE

GET /api/v1/events memakai session, tenant scoped, heartbeat, dan cleanup saat disconnect.

const source = new EventSource("/api/v1/events");
source.addEventListener("message.created", event => {
  const payload = JSON.parse(event.data);
  refreshConversation(payload.conversationId);
});

SSE V1 tidak menjamin replay. Client wajib re-fetch API setelah reconnect.

07

Dashboard/session API catalog

Route ini membutuhkan session cookie dan permission RBAC. Jangan digunakan sebagai public server-to-server API.

Device

GET, POST /api/v1/devicesGET, PATCH, DELETE /api/v1/devices/:idPOST /api/v1/devices/:id/connectPOST /api/v1/devices/:id/disconnectPOST /api/v1/devices/:id/reconnectPOST /api/v1/devices/:id/logoutGET /api/v1/devices/:id/statusGET /api/v1/devices/:id/qrPOST /api/v1/devices/:id/pairing-codeGET /api/v1/devices/:id/eventsGET /api/v1/devices/stream

Messaging & media

GET /api/v1/messagesGET, DELETE /api/v1/messages/:idPOST /api/v1/messages/:id/retryPOST /api/v1/messages/textPOST /api/v1/messages/imagePOST /api/v1/messages/documentPOST /api/v1/messages/videoPOST /api/v1/messages/audioPOST /api/v1/messages/voicePOST /api/v1/messages/stickerPOST /api/v1/messages/locationPOST /api/v1/messages/contact

Inbox

GET /api/v1/inbox/conversationsGET /api/v1/inbox/conversations/:idGET /api/v1/inbox/conversations/:id/messagesPOST /api/v1/inbox/conversations/:id/:actionGET, POST /api/v1/inbox/conversations/:id/notesPOST, DELETE /api/v1/inbox/conversations/:id/tags/:tagIdGET, POST /api/v1/inbox/tagsGET, POST /api/v1/inbox/canned-repliesGET, PATCH, DELETE /api/v1/inbox/canned-replies/:idPOST /api/v1/inbox/history-syncGET /api/v1/events (SSE)

Contacts & groups

GET, POST /api/v1/contactsGET, PATCH, DELETE /api/v1/contacts/:idGET /api/v1/contacts/exportPOST /api/v1/contacts/sync-whatsappGET, POST /api/v1/contact-tagsGET, POST /api/v1/contact-groupsPOST, DELETE /api/v1/contact-groups/:id/membersGET, POST /api/v1/contact-importsGET /api/v1/contact-imports/:idPOST /api/v1/contact-imports/:id/confirmGET, POST /api/v1/whatsapp-groupsGET /api/v1/whatsapp-groups/:idPOST /api/v1/whatsapp-groups/:id/import-participants

Campaign

GET, POST /api/v1/campaignsGET, PATCH /api/v1/campaigns/:idPOST /api/v1/campaigns/:id/previewPOST /api/v1/campaigns/:id/testPOST /api/v1/campaigns/:id/startPOST /api/v1/campaigns/:id/pausePOST /api/v1/campaigns/:id/resumePOST /api/v1/campaigns/:id/cancelGET /api/v1/campaigns/:id/recipientsGET /api/v1/campaigns/:id/events

Automation

GET, POST /api/v1/automation/rulesGET, PATCH, DELETE /api/v1/automation/rules/:idPOST /api/v1/automation/dry-runGET /api/v1/automation/executionsGET, PUT /api/v1/automation/business-hours

Webhooks

GET, POST /api/v1/webhooksGET, PATCH, DELETE /api/v1/webhooks/:idGET /api/v1/webhook-deliveriesGET /api/v1/webhook-deliveries/:idPOST /api/v1/webhook-deliveries/:id/resend

Billing & API keys

GET /api/v1/billingGET /api/v1/billing/plansPOST /api/v1/billing/change-planPOST /api/v1/billing/checkoutGET, POST /api/v1/api-keysDELETE /api/v1/api-keys/:idPOST /api/v1/api-keys/:id/rotate

08

Security rules

  • Tenant selalu ditentukan server-side dari API key atau session.
  • Gunakan nomor canonical, contoh 628123456789.
  • Kirim Idempotency-Key unik untuk mencegah pengiriman ganda.
  • Jangan simpan API key di browser, source control, screenshot, atau log.
  • Batasi scope, IP, device, expiry, dan rate ke minimum.
  • Gunakan webhook untuk hasil asynchronous.
  • Media binary tidak pernah masuk Redis; queue hanya membawa identifier.