API overview
The HTTP API lets your apps send messages, manage sessions and read chat history. It is compatible with WA Gateway v4.
Base URL
The API is served by your gateway, on the same port as the dashboard:
http://YOUR_SERVER:5001Authentication
Every request needs an API key in the key header:
curl http://YOUR_SERVER:5001/session -H "key: wag_your_key"The x-api-key header and the ?key= query parameter are accepted too.
Interactive docs
Your gateway serves interactive API docs at /docs, with every field, example requests in many languages and a built-in client to try requests. The OpenAPI 3.1 document is at /openapi.json: import it into Postman, Insomnia or a code generator.

Requests and responses
Send JSON bodies with content-type: application/json. Successful responses are JSON, usually wrapped in data.
Errors use HTTP status codes and a message:
{ "message": "Session is not connected" }| Status | When |
|---|---|
400 | Invalid input ("Invalid input: expected string, received undefined field 'to' on json"), the session doesn't exist or isn't connected, or the number isn't on WhatsApp ("6281234567890 is not registered on WhatsApp"). |
401 | Missing or invalid API key. |
404 | Unknown session or route. |
500 | Something went wrong while talking to WhatsApp. |
Phone numbers and chats
- Phone numbers are written with the country code and digits only:
6281234567890,14155550100.+, spaces and dashes are removed for you. - Groups are addressed by their id (
120363012345678901) with"is_group": true, or by the full JID (120363012345678901@g.us). - A full JID (
…@s.whatsapp.net,…@g.us) is accepted anywhere a number is.
You find group ids in webhook payloads (chat), in the History API or in the inbox URL.
Endpoints
| Sessions | List, start, inspect and delete sessions. |
| Messages | Send text, images, videos, documents, audio, stickers and polls. |
| History | Read chats and messages stored by the gateway. |
| Profile | Profile picture and about text of a contact. |
To receive messages, use webhooks.