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
POST /whatsapp/api/v1/accountswithcountry, the ISO code of the number's country (its IP is placed there; required unless aniplocates it). The answer is201with a checkpoint of typeQRCODE, the QR's text incheckpoint.qrcode: render it as a QR image for the person to scan. It changes about every 20 seconds: read the current one fromGET /whatsapp/api/v1/accounts/{id}(gateway.checkpoint).- Or send
pairing_phone_number(international format) and get aPAIRING_CODEcheckpoint whosecodethe person types on the phone (Linked devices → Link with phone number). - When the phone accepts, the account becomes
OKand the eventsCREATION_SUCCESSthenOKarrive;SYNC_SUCCESSfollows 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.DELETEalso unlinks the device on the phone, unlessprovider_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.
| Area | Start with |
|---|---|
| Chats | List chats, start a chat, send a message |
| Messages | All messages, forward, react |
| People | Attendees, is this number on WhatsApp? |
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.