API and webhooks
Sendlane gives each account its own WhatsApp number on an isolated session. Your app sends messages with a REST API and receives replies on signed webhooks.
Base URL: https://sendlane.amm-labs.com/api/v1
Machine-readable versions of this page: Markdown, OpenAPI 3.1, llms.txt and llms-full.txt.
Quickstart for AI agents
Follow this order. Every step names the exact request and the field to check.
- Get an API token from a human. They create it under API keys in the dashboard. Send it as
Authorization: Bearer <token>on every request. Never put it in a URL. GET /session. Readstatus.ready: go to step 4.- anything else: go to step 3.
POST /session/start. If the response has aqrfield, a human must scan that data URI with the phone. PollGET /sessionevery 3 to 5 seconds untilstatusisready. Refresh the code withGET /session/qrif it expires. Do not callPOST /session/startmore than 6 times a minute.POST /messageswith{ "to": "<chat id>", "text": "<message>" }. A200means the message was handed to the WhatsApp session.- Replies arrive on the webhook URL the human set in the dashboard. Verify
X-Webhook-Signaturebefore you trust a payload.
Rules to follow:
- A token is bound to one account and one session. You cannot choose another session.
- Treat
409as "pairing is not finished". Do not retry in a tight loop. Ask a human or pollGET /session. - Treat
429as "slow down". Wait, then retry with a longer delay. - Treat
503as "the WhatsApp sidecar is down". Retry later and tell a human if it persists. - Only message people who have opted in. WhatsApp can ban numbers that look like spam.
Authentication
Create a personal access token under API keys in the dashboard and send it with every request.
Authorization: Bearer <token>
Accept: application/json
A token belongs to one account and always uses that account's WhatsApp session (u{userId}). You cannot name another session.
Session
GET /session
The current pairing state.
{
"session_id": "u42",
"status": "ready",
"phone_number": "966512345678",
"push_name": "My Shop",
"ready_at": "2026-11-28T10:00:00+00:00"
}
POST /session/start
Boots the session and returns a QR code data URI when pairing is needed. Limited to 6 requests per minute.
{ "session_id": "u42", "status": "qr", "qr": "data:image/png;base64,..." }
GET /session/qr
Refreshes the QR code while pairing. Limited to 12 requests per minute.
Messages
POST /messages
Sends a text message from the paired number. Limited to 60 requests per minute.
{
"to": "966512345678@c.us",
"text": "Hello from my app"
}
to can be a chat ID (...@c.us) or a number the sidecar accepts. You get a 409 if the session is not ready, and a 200 with the send result under result on success.
curl -X POST https://sendlane.amm-labs.com/api/v1/messages \
-H "Authorization: Bearer $SENDLANE_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"to":"966512345678@c.us","text":"Hello from my app"}'
Health
GET /health
An authenticated, shallow check of the database and the WhatsApp stack. Returns 503 when something is unhealthy.
Errors
| Code | Meaning | What to do |
|---|---|---|
| 401 | Missing or invalid token | Stop. Ask a human for a valid token |
| 409 | Session not connected | Finish pairing, then retry |
| 429 | Rate limited | Wait, then retry with backoff |
| 503 | The WhatsApp sidecar is unreachable | Retry later |
Webhooks
When someone messages a paired number, Sendlane queues a POST to the webhook URL you set in the dashboard. Set a signing secret of at least 16 characters and store the same value in your app.
POST https://your-app.example.com/webhooks/sendlane
Content-Type: application/json
X-Webhook-Signature: sha256=<hex>
{
"event": "message.received",
"data": {
"session_id": "u42",
"from": "966512345678@c.us",
"body": "Hello",
"type": "chat"
}
}
| Event | When |
|---|---|
message.received |
Someone messaged your number |
session.ready |
The phone paired successfully |
session.disconnected |
The session dropped. Includes a reason |
Messages with fromMe: true are not forwarded.
Verify a signature
The signature is an HMAC-SHA256 of the raw request body. Compare it in constant time before you trust the payload.
$payload = $request->getContent();
$expected = 'sha256='.hash_hmac('sha256', $payload, $secret);
if (! hash_equals($expected, $request->header('X-Webhook-Signature', ''))) {
abort(401);
}
const crypto = require('crypto');
const expected = 'sha256=' +
crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
Retries and local testing
Delivery runs on a queue with 5 attempts and exponential backoff. Return a 2xx quickly and do the heavy work asynchronously.
Sendlane cannot reach localhost on your laptop. Expose your endpoint with a tunnel or use a staging URL while you test.