REST API for managing WhatsApp sessions, sending statuses, and reading viewer analytics. Version 2.0.0.
Every /api request must include your API key, set as API_KEY in the server's .env.
x-api-key: YOUR_API_KEY
# or
Authorization: Bearer YOUR_API_KEY
Requests are rate-limited per IP (default 300 requests / 15 min). Responses are JSON:
{ "success": true, "data": ... } or { "success": false, "error": "..." }.
Create and start a session.
| Field | Required | Notes |
|---|---|---|
| sessionId | yes | letters, numbers, _, - (≤64) |
| sessionName | yes | display name |
| authMethod | no | pairing (default) or qrcode |
| phoneNumber | if pairing | 10–15 digits incl. country code |
curl -X POST http://localhost:3000/api/sessions \
-H "x-api-key: $KEY" -H "Content-Type: application/json" \
-d '{"sessionId":"acc1","sessionName":"My Account","authMethod":"pairing","phoneNumber":"919812345678"}'
List all sessions with connection state.
Delete a session, its auth, statuses and viewers.
Tear down and reconnect a session.
Update the pairing phone number. Body: { "phoneNumber": "..." }
Returns connected, authMethod, current pairingCode/qrCode (data URL), phoneNumber, ownNumber.
Read or request a fresh 8-digit pairing code (only valid before the session is connected).
| Field | Notes |
|---|---|
| type | text | image | video | url |
| content | text body, uploaded filename, or media URL |
| caption | optional (media only) |
| targetNumbers | optional, comma-separated; empty = your own number |
# text
curl -X POST .../sessions/acc1/send-status \
-H "x-api-key: $KEY" -H "Content-Type: application/json" \
-d '{"type":"text","content":"Hello from the API"}'
# image (upload first, then send the returned filename)
curl -X POST .../upload-image -H "x-api-key: $KEY" -F "image=@./pic.jpg"
# -> { "data": { "filename": "1730000000-ab12.jpg" } }
curl -X POST .../sessions/acc1/send-status \
-H "x-api-key: $KEY" -H "Content-Type: application/json" \
-d '{"type":"image","content":"1730000000-ab12.jpg","caption":"hi"}'
List statuses from the last 24 hours.
List who has viewed a status, with timestamps.
Multipart form upload (field image or video). Returns a stored filename to pass as content. Max size set by MAX_UPLOAD_MB.
Health check, aggregate stats, and per-session DB storage usage.
Connect via Socket.IO at the server root. Events emitted:
connection-status { sessionId, connected, ownNumber?, status? }
pairing-code { sessionId, pairingCode, phoneNumber }
qr-code { sessionId, qrCode }
status-sent { sessionId, id, type, ... }
status-viewers-update { sessionId, statusId, viewers[] }
status-deleted { sessionId, statusId }
statuses-updated { sessionId }
session-created { sessionId, ... }
session-deleted { sessionId }