API documentation
A small REST API over HTTPS. JSON in, JSON out. The base URL is https://your-domain.com/api/v1.
Quickstart
Three steps, about two minutes:
- Connect a number. In the dashboard open Numbers, name it, and scan the QR code with WhatsApp (Settings → Linked devices).
- Create an API key under API keys. Copy it — it is shown once.
- Send.
curl -X POST https://your-domain.com/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "254712345678",
"text": "Hello from the API 👋"
}'You get the message back with an id and a status:
{
"id": "665f1c2ab7e4a1d3c9f0e812",
"instance": "665f1b90b7e4a1d3c9f0e7aa",
"direction": "out",
"to": "254712345678",
"chat": "254712345678",
"type": "text",
"text": "Your order has shipped 🎉",
"status": "sent",
"source": "api",
"sentAt": "2026-03-02T09:14:07.412Z",
"createdAt": "2026-03-02T09:14:06.950Z"
}Authentication
Send your key in the Authorization header on every request. Keys start with wl_live_ and work for every number in your account.
Authorization: Bearer wl_live_3f9a…An X-API-Key header is accepted too, for systems that cannot set a bearer token. Keep keys on your server — never in a mobile app or web page. Revoke a leaked key in the dashboard and it stops working immediately.
Phone number formats
Use the full international number. Spaces, dashes and a leading + are all fine — +254 712 345 678, 254712345678 and 254-712-345-678 are the same number.
To send to local numbers such as 0712345678, set a default country code in Settings. To message a group, use its ID (it ends in @g.us) from GET /instances/:id/groups.
Send a message
One endpoint sends every kind of message. Only to and some content are required.
| to | string | Recipient phone number or group ID. Required. |
| text | string | The message. Supports WhatsApp formatting (*bold*, _italic_) and {{variables}}. |
| mediaUrl | string | Public URL of an image, video, audio file or document. |
| caption | string | Text shown under an image, video or document. |
| type | string | Usually detected for you. One of text, image, video, document, audio, sticker, location, contact, poll, reaction. |
| instance | string | The 5-digit code of the number to send from (shown under each number in Dashboard → Numbers, e.g. "48213"). Its name or ID also work. Defaults to your default number. |
| template | string | Name of a saved template to use instead of text. |
| variables | object | Values for {{placeholders}} in the text or template. |
| scheduleAt | ISO date | Send at this time instead of now. |
| replyTo | string | ID of a message to quote. |
| linkPreview | boolean | Show a preview for links. Default true. |
The call returns once WhatsApp has accepted the message (status: "sent"). Delivery and read receipts follow as webhooks, or you can poll the message.
Message types
Image, video, audio or document — pass a URL; the type is picked from the file extension. Add filename to control the name the recipient sees.
{
"to": "254712345678",
"mediaUrl": "https://example.com/files/menu.pdf",
"caption": "Our new menu",
"filename": "Menu.pdf"
}No public URL? Send the file itself as mediaBase64 together with a type and filename.
Location
{
"to": "254712345678",
"latitude": -1.2921,
"longitude": 36.8219,
"name": "Our office",
"address": "Kimathi St, Nairobi"
}Contact card
{
"to": "254712345678",
"contact": {
"name": "Support desk",
"phone": "254700000000"
}
}Poll — set multiple: true to allow several answers.
{
"to": "254712345678",
"poll": {
"question": "Was your issue resolved?",
"options": [
"Yes",
"No"
]
}
}Reaction — react to any message by its ID. Send an empty emoji to remove it.
{
"to": "254712345678",
"reaction": {
"messageId": "665f1c2ab7e4a1d3c9f0e812",
"emoji": "👍"
}
}Scheduling
Add scheduleAt with an ISO 8601 time. The message is stored with status: "scheduled" and sent at that moment. Cancel it any time before with DELETE /messages/:id.
{
"to": "254712345678",
"text": "Reminder: your appointment is tomorrow at 10am.",
"scheduleAt": "2026-03-05T06:00:00Z"
}Templates
Save a message once under Templates — for example order_update: “Hi {{name}}, your order {{order}} is on its way.” — then send it by name:
{
"to": "254712345678",
"template": "order_update",
"variables": {
"name": "Jane",
"order": "#1042"
}
}Non-developers can now edit the wording in the dashboard without touching your code.
Bulk sending
Send the same message to up to 10,000 recipients in one call. Every option of a single message works here. Give each recipient their own variables to personalise.
curl -X POST https://your-domain.com/api/v1/messages/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"campaignName": "March update",
"text": "Hi {{name}}, your table for {{guests}} is confirmed for Friday.",
"recipients": [
{
"to": "254712345678",
"variables": {
"name": "Jane",
"guests": "4"
}
},
{
"to": "254722000111",
"variables": {
"name": "John",
"guests": "2"
}
}
]
}'The call returns a campaign immediately. Messages are then sent one at a time, with a short randomised pause between them — this is what keeps WhatsApp from flagging your number. Duplicates, invalid numbers and people who replied STOP are skipped. Follow progress with GET /campaigns/:id or the campaign.completed webhook.
Status & history
A message moves through these statuses:
| scheduled | Waiting for its scheduleAt time. | |
| queued | Part of a bulk send, waiting for its turn. | |
| sent | Accepted by WhatsApp (one tick). | |
| delivered | Reached the recipient’s phone (two ticks). | |
| read | Opened by the recipient (blue ticks). | |
| failed | Could not be sent — see the error field. | |
| cancelled | Cancelled by you before sending. | |
| received | An incoming message from a customer. |
Lists newest first. Filter with status, direction (in/out), chat (a phone number), instance, campaign, q (text search) and since. Page with page and limit (max 100). Every list has the same shape:
{
"data": [
"…"
],
"total": 248,
"page": 1,
"limit": 25,
"has_more": true
}Numbers
A “number” (called an instance in the API) is one linked WhatsApp account. Most people set these up in the dashboard, but everything is available over the API — useful if you connect numbers on behalf of your own customers.
{
"name": "Support line"
}The new number comes back with its code, e.g. "code": "48213".
The response includes a qr field: a ready-to-display image as a data URL. Show it to your user, then poll:
Every few seconds until status becomes connected. QR codes expire quickly; this endpoint always returns a current one. Add ?phone=254712345678 to get an 8-character pairingCode instead of a QR.
{
"status": "connecting",
"qr": "data:image/png;base64,iVBORw0KGgo…",
"pairingCode": null
}Every number gets a 5-digit code that never changes. Pass it as instance when sending to choose which number the message goes out from. :id can be the code, the instance ID or its name.
Check numbers
Find out which numbers are on WhatsApp before you message them — up to 100 per call.
{
"numbers": [
"254712345678",
"254700000001"
]
}{
"data": [
{
"number": "254712345678",
"exists": true
},
{
"number": "254700000001",
"exists": false
}
]
}Contacts
{
"name": "Jane Wanjiru",
"phone": "254712345678",
"tags": [
"customers",
"nairobi"
]
}Use POST /contacts/import with { "contacts": [...], "tags": [...] } to create or update up to 20,000 at once — existing numbers are updated, never duplicated. Anyone who messages you is added automatically. When a contact replies STOP they are marked optedOut and skipped by campaigns; START opts them back in.
Campaigns
Like bulk sending, but aimed at your saved contacts. {{name}} and {{firstName}} are filled from each contact.
{
"campaignName": "Weekend sale",
"tags": [
"customers"
],
"text": "Hi {{firstName}}, our sale starts on Friday.",
"scheduleAt": "2026-03-05T06:00:00Z"
}Use allContacts: true instead of tags to reach everyone. DELETE /campaigns/:id stops a campaign; messages not yet sent are cancelled.
One-time codes (OTP)
Send a login or sign-up code over WhatsApp. We generate the code, send it, and keep only a hash of it, so your system never has to store codes.
{
"to": "254712345678",
"appName": "Duka App",
"length": 6,
"expiresIn": 300
}| to | string | The number to send the code to. |
| length | number | Digits in the code, 4–8. Default 6. |
| expiresIn | number | Seconds the code stays valid, 60–1800. Default 300. |
| maxAttempts | number | Wrong guesses allowed before the code is burned, 1–10. Default 5. |
| appName | string | Shown in bold above the code. |
| message | string | Your own wording. Must contain {{code}}. |
| instance | string | Which of your numbers sends it. Defaults to your default number. |
| idempotencyKey | string | Send the same key again and you get the first code back instead of a new one. |
{
"id": "6661b0c4b7e4a1d3c9f0f210",
"to": "254712345678",
"status": "pending",
"expiresAt": "2026-03-02T09:25:11.000Z",
"attemptsLeft": 5
}Pass the id you got back (or the number in to, which checks the latest code sent to it) and the code the person typed. The answer is always 200; read valid.
{
"id": "6661b0c4b7e4a1d3c9f0f210",
"code": "482913"
}{
"valid": false,
"reason": "wrong_code",
"otp": {
"id": "6661b0c4b7e4a1d3c9f0f210",
"status": "pending",
"attemptsLeft": 4
}
}reason is one of wrong_code, expired, too_many_attempts, already_used or not_delivered. A number can get one code every 30 seconds and five per hour; more returns 429 with retry_after. The code is masked in your message log, and an otp.verified webhook fires when a code is confirmed.
M-Pesa payment requests
Ask a customer to pay without leaving the chat. They get a WhatsApp message and an M-Pesa prompt on their phone; once they enter their PIN, they get a receipt in the chat and you get a payment.completed webhook. Add your M-Pesa till, paybill or bank account under Payments first: the money goes straight to it.
{
"to": "254712345678",
"amount": 1500,
"description": "order #1042",
"metadata": {
"orderId": "1042"
}
}| to | string | The WhatsApp chat to message. |
| amount | number | Whole Kenyan shillings, 1–250,000. |
| description | string | What it is for, e.g. order #1042. Shown in both messages. |
| phone | string | The Safaricom number to prompt, if not the WhatsApp number in to. |
| message | string | Your own wording for the request. Placeholders: {{amount}}, {{description}}, {{phone}}, {{name}}. |
| confirmation | string | Your own thank-you message. Also takes {{receipt}}. |
| metadata | object | Anything you want back in the webhooks, like your order ID. |
The request starts as pending and ends as success, failed, cancelled or expired (no answer within 10 minutes). Each outcome fires payment.completed or payment.failed. If a payment fails, the customer can reply PAY to get a fresh prompt, up to three times.
Chatbot flows
A flow starts when a message matches its keyword and then walks the person through steps: message, question (saves the answer in a field), menu (numbered options that branch), payment (an M-Pesa request) and handoff (passes the chat to a person). Build them in the dashboard, or with POST /flows:
{
"name": "Main menu",
"keyword": "menu",
"match": "exact",
"steps": [
{
"id": "start",
"type": "menu",
"text": "How can we help?",
"options": [
{
"label": "Prices",
"next": "prices"
},
{
"label": "Talk to a person",
"next": "human"
}
]
},
{
"id": "prices",
"type": "message",
"text": "Our prices: https://example.com/prices"
},
{
"id": "human",
"type": "handoff",
"text": "Someone will reply shortly."
}
]
}Answers are saved on the contact under fields. When someone finishes or is handed over, a flow.completed webhook carries everything they answered. Flows answer before keyword auto-replies and the AI assistant.
AI replies
Drafts the next reply in a chat from the conversation and the business information you gave the AI assistant. Nothing is sent, so an agent can check it first.
{
"chat": "254712345678"
}{
"suggestion": "Hi Jane! Delivery to Kilimani is free for orders over KES 1,000. 🚚",
"handoff": false
}handoff: true means the AI thinks a person should handle the chat. Turn on automatic answers in the dashboard to let the assistant reply on its own. Each AI reply uses AI tokens from your balance (an AI plan or a top-up, bought under AI assistant); with none left this endpoint returns 402 ai_no_tokens.
Receiving events
Add an endpoint under Webhooks (or POST /webhooks with url and events). We send a JSON POST for each event:
| message.received | A customer sent you a message. | |
| message.sent | Your message was accepted by WhatsApp. | |
| message.delivered | It reached the recipient’s phone. | |
| message.read | The recipient opened it. | |
| message.failed | It could not be sent. | |
| instance.connected | A number was linked. | |
| instance.disconnected | A number lost its link — re-scan the QR. | |
| campaign.completed | A bulk send finished. | |
| payment.pending | An M-Pesa prompt was sent. | |
| payment.completed | A payment request was paid. | |
| payment.failed | A payment request failed, was cancelled or expired. | |
| otp.verified | A one-time code was confirmed. | |
| flow.completed | Someone finished a chatbot flow or was handed over. |
An incoming message looks like this:
{
"id": "6660a1f2b7e4a1d3c9f0f001",
"event": "message.received",
"createdAt": "2026-03-02T09:20:11.031Z",
"data": {
"id": "6660a1f2b7e4a1d3c9f0effe",
"instance": "665f1b90b7e4a1d3c9f0e7aa",
"direction": "in",
"from": "254712345678",
"contactName": "Jane",
"type": "text",
"text": "Thanks, received!",
"status": "received",
"createdAt": "2026-03-02T09:20:10.000Z"
}
}Answer with any 2xx status within 10 seconds. Otherwise we retry after 30 seconds, 2 minutes, 10 minutes and 1 hour. Each event carries a unique id (also in the X-Wavelink-Delivery header) so you can ignore repeats. Every attempt is visible in the dashboard for 14 days.
Verifying signatures
Each request is signed so you know it came from us. The X-Wavelink-Signature header is sha256= followed by the HMAC-SHA256 of the raw request body, keyed with your endpoint’s signing secret (starts with whsec_, shown next to the endpoint).
import crypto from "crypto";
import express from "express";
const app = express();
// Keep the raw body — the signature is computed over the exact bytes we sent.
app.post("/webhooks/whatsapp", express.raw({ type: "application/json" }), (req, res) => {
const expected = "sha256=" + crypto
.createHmac("sha256", process.env.WEBHOOK_SECRET)
.update(req.body)
.digest("hex");
const given = req.get("X-Wavelink-Signature") || "";
if (given.length !== expected.length ||
!crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected))) {
return res.sendStatus(401);
}
const { event, data } = JSON.parse(req.body);
if (event === "message.received") {
console.log(`${data.from} says: ${data.text}`);
}
res.sendStatus(200);
});Errors
Errors use normal HTTP status codes and always have the same shape, with a message written for humans:
{
"error": {
"code": "instance_not_connected",
"message": "\"Support line\" is not connected to WhatsApp. Scan the QR code in the dashboard, then try again."
}
}| 400 invalid_json | The body is not valid JSON. | |
| 401 unauthorized | No API key was sent. | |
| 401 invalid_api_key | The key is wrong or was revoked. | |
| 402 plan_expired | The account’s trial or plan has ended. Renew it in the dashboard. | |
| 403 limit_reached | The plan’s number allowance is used up. | |
| 404 not_found | No such resource in your account. | |
| 409 no_instance | You have not connected a number yet. | |
| 409 instance_not_connected | The number needs to be re-linked. | |
| 422 validation_error | A field is missing or wrong. fields lists each problem. | |
| 429 rate_limited | Slow down. See Retry-After. | |
| 502 gateway_error | The WhatsApp gateway could not be reached. Safe to retry. |
Note: when WhatsApp itself rejects a message (for example the number is not on WhatsApp), the request still succeeds with 200 and the message has status: "failed" and an error explaining why.
Rate limits & idempotency
Each key may make 120 requests per minute. Responses include X-RateLimit-Limit and X-RateLimit-Remaining. For large sends, use one bulk call rather than many single ones.
To make retries safe, send an Idempotency-Key header (any unique string, such as your order number). If the same key arrives twice, the message is sent once and the original is returned.
curl https://your-domain.com/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: order-1042-shipped" \
-H "Content-Type: application/json" \
-d '{ "to": "254712345678", "text": "Order 1042 has shipped." }'All endpoints
| POST | /messages | Send or schedule a message |
| GET | /messages | List messages (filters: status, direction, chat, instance, campaign, q, since) |
| GET | /messages/:id | Get one message and its status |
| DELETE | /messages/:id | Cancel a scheduled or queued message |
| POST | /messages/bulk | Queue one message to many recipients |
| GET | /instances | List your numbers |
| POST | /instances | Add a number (returns a QR code) |
| GET | /instances/:id | Get a number and refresh its status |
| PATCH | /instances/:id | Rename, set as default, change pacing |
| DELETE | /instances/:id | Remove a number |
| GET | /instances/:id/qr | Current QR / pairing code / connection status |
| POST | /instances/:id/logout | Unlink from WhatsApp |
| POST | /instances/:id/restart | Restart the connection |
| GET | /instances/:id/groups | List the groups this number is in |
| POST | /numbers/check | Check which numbers are on WhatsApp |
| GET | /contacts | List contacts (filters: q, tag, optedOut) |
| POST | /contacts | Create a contact |
| PATCH | /contacts/:id | Update a contact |
| DELETE | /contacts/:id | Delete a contact |
| POST | /contacts/import | Create or update many contacts at once |
| GET | /templates | List templates |
| POST | /templates | Create a template |
| PATCH | /templates/:id | Update a template |
| DELETE | /templates/:id | Delete a template |
| GET | /campaigns | List campaigns with live stats |
| POST | /campaigns | Start a campaign to tags, all contacts or a list |
| GET | /campaigns/:id | Get a campaign and its stats |
| DELETE | /campaigns/:id | Stop a campaign |
| GET | /webhooks | List webhook endpoints |
| POST | /webhooks | Add a webhook endpoint |
| PATCH | /webhooks/:id | Update or pause an endpoint |
| DELETE | /webhooks/:id | Delete an endpoint |
| POST | /webhooks/:id/test | Send a test event |
| GET | /webhooks/deliveries | Recent delivery attempts |
| GET | /auto-replies | List auto-reply rules |
| POST | /auto-replies | Create an auto-reply rule |
| POST | /otp/send | Send a one-time code over WhatsApp |
| POST | /otp/verify | Check a one-time code |
| GET | /otp/:id | Get the status of a code |
| POST | /payment-requests | Send an M-Pesa prompt and a WhatsApp message |
| GET | /payment-requests | List payment requests (filters: status, to) |
| GET | /payment-requests/:id | Get one request and refresh its status |
| GET | /flows | List chatbot flows |
| POST | /flows | Create a chatbot flow |
| PATCH | /flows/:id | Update or pause a flow |
| DELETE | /flows/:id | Delete a flow |
| POST | /ai/suggest | Draft the next reply in a chat with AI (nothing is sent) |
| GET | /stats | Totals and a per-day series |
| GET | /me | The account the key belongs to |