WhatsApp

Link a WhatsApp number as a linked device, then read and send.

A number is linked as a linked device of the phone, like WhatsApp Web. Everything lives under /whatsapp/api/v1.

Linking a number

  1. POST /whatsapp/api/v1/accounts with country, the ISO code of the number's country (its IP is placed there; required unless an ip locates it). The answer is 201 with a checkpoint of type QRCODE, the QR's text in checkpoint.qrcode: render it as a QR image for the person to scan. It changes about every 20 seconds: read the current one from GET /whatsapp/api/v1/accounts/{id} (gateway.checkpoint).
  2. Or send pairing_phone_number (international format) and get a PAIRING_CODE checkpoint whose code the person types on the phone (Linked devices → Link with phone number).
  3. When the phone accepts, the account becomes OK and the events CREATION_SUCCESS then OK arrive; SYNC_SUCCESS follows when the first history sync is done.
curl -X POST https://console.swarmhit.com/whatsapp/api/v1/accounts \
  -H "X-API-KEY: gw_live_…" -H "Content-Type: application/json" \
  -d '{"provider":"WHATSAPP","country":"FR"}'

There is no code to send back: the checkpoint routes answer 422 for WhatsApp.

Reconnecting and removing

  • POST /whatsapp/api/v1/accounts/{id} reconnects a number that is still linked on its existing login; only a number whose link is gone gets a new QR.
  • DELETE also unlinks the device on the phone, unless provider_session_revoke=false.

Reading and sending

Reads (chats, messages, attendees) answer from Swarmhit's copy, even while a number reconnects. Anything that reaches WhatsApp needs it connected and otherwise answers 503 whatsapp-connecting: retry in a moment. Chat and attendee routes accept Swarmhit's ids, or a WhatsApp JID or phone number with account_id.

Send client_id, your own id for a send: a retry with the same id within 24 hours returns the first answer instead of sending again.

WhatsApp's own limits

WhatsApp limits new chats per number. Its answers come back as 403 whatsapp-new-chats-blocked (until ends_at; existing chats still work) and 422 whatsapp-quota-reached. Swarmhit's own caps are in Write safety.

On this page