Webbai API reference
The Webbai API lets your own software send WhatsApp messages from your business number, receive every incoming message (including voice notes, photos and files) as a signed webhook, add leads and start automations. It uses the official WhatsApp Business API; Webbai handles the Meta side.
Base URL: https://webbai.nl
Authentication
Every request needs your API key as a Bearer token:
Authorization: Bearer <your API key>
Find the key in the dashboard under Settings → API Key. If the field is empty, click Regenerate key once: from then on the dashboard can show and copy it. Regenerating invalidates the previous key immediately.
The key gives full access to your Webbai account. Keep it on your server; never put it in a browser, mobile app or public repository. A missing or wrong key returns 401 with {"error": "Not authenticated"}.
Conventions
- JSON in, JSON out. Send
Content-Type: application/json. - Always check for an
errorfield. Validation and business-rule errors (outside the 24-hour window, contact opted out, send limit reached) usually come back as HTTP200with anerrorfield. Authentication errors are401, and some newer endpoints also use400/404. - Phone numbers are international format. Spaces,
+and dashes are stripped, so+31 6 12345678and31612345678are the same number. contact_ididentifies a customer in Webbai. You get it from webhook events,GET /api/conversationsand the send/lead endpoints.- Rate limit: 100 requests per minute per IP address. Above that you get
429.
The 24-hour window
WhatsApp only allows free-form messages within 24 hours after the customer's last message to you. Outside that window you must send an approved template. Webbai checks this for you:
POST /api/conversations/{contact_id}/sendrefuses outside the window with"require_template": true.- Every
message.receivedwebhook event carrieswindow_open_until, so your code knows the deadline. - Templates can be sent at any time.
Customers who replied STOP are marked as opted out. Webbai won't send them messages from the inbox, automations or /api/conversations/.../send and .../send-template.
Send a message
Reply with free text
POST /api/conversations/{contact_id}/send
Sends immediately, within the 24-hour window.
curl -X POST https://webbai.nl/api/conversations/CONTACT_ID/send \
-H "Authorization: Bearer $WEBBAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Thanks! We will call you back today."}'
| Field | Type | Required | |
|---|---|---|---|
message | string | yes | The text to send |
Response:
{ "success": true, "message_id": "wamid.HBgL..." }
Errors (HTTP 200 with error): message is required, Contact not found, contact opted out, daily send limit reached, or Outside 24h messaging window. Use a template instead. with "require_template": true.
Send a template to a contact
POST /api/conversations/{contact_id}/send-template
| Field | Type | Required | |
|---|---|---|---|
template_name | string | yes | Name of an approved template |
language_code | string | no | Template language, e.g. nl or en. Default en |
variables | string[] | no | Values for {{1}}, {{2}}, … in order |
header_media_url | string | no | Public URL for templates with an image, video or document header |
Response: { "success": true, "message_id": "wamid..." }. If the variables don't fit the template you get { "success": false, "code": "template_components_incomplete", "error": "..." }.
Send a template to a phone number
POST /api/send-template
For people who aren't a contact yet, e.g. the first message after a form on your website. The contact is created after a successful send.
curl -X POST https://webbai.nl/api/send-template \
-H "Authorization: Bearer $WEBBAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "+31612345678",
"template_name": "order_ready",
"language_code": "nl",
"variables": ["Sanne", "A-1042"],
"contact_name": "Sanne de Vries"
}'
| Field | Type | Required | |
|---|---|---|---|
phone | string | yes | Recipient |
template_name | string | yes | Approved template |
language_code | string | no | Default en |
variables | string[] | no | Template variables in order |
contact_name | string | no | Name for the new contact |
header_media_url | string | no | Media header URL |
Response: { "success": true, "message_id": "wamid...", "contact_id": "..." }
Only message people who gave you permission. Check your own opt-out list before using this endpoint.
Conversations and contacts
List conversations
GET /api/conversations
Returns the 50 most recently active contacts, newest first.
{
"conversations": [{
"id": "c1f0…", "name": "Sanne", "phone": "31612345678", "email": null,
"source": "whatsapp", "status": "contacted", "type": "conversation",
"last_message": "🎤 Spraakbericht", "last_activity": "2026-11-17 09:41:02",
"unread_count": 1, "tags": [], "opted_out_at": null
}]
}
Conversation history
GET /api/conversations/{contact_id}/timeline
{
"contact": { "id": "c1f0…", "name": "Sanne", "phone": "31612345678", "opted_out_at": null },
"can_send_freeform": true,
"timeline": [
{ "type": "message", "direction": "in", "text": "Are you open on Saturday?", "time": "2026-11-17 09:40:11" },
{ "type": "message", "direction": "in", "text": "🎤 Spraakbericht", "time": "2026-11-17 09:41:02",
"media": { "type": "audio", "media_id": "1234567890", "mime_type": "audio/ogg; codecs=opus", "voice": true } },
{ "type": "message", "direction": "out", "text": "Yes, 8:00 to 16:00!", "status": "read", "time": "2026-11-17 09:42:30" }
]
}
can_send_freeform tells you whether the 24-hour window is open. Reading the timeline marks the incoming messages as read in the dashboard. Download media with GET /media/{media_id}.
Opt a contact out or back in
POST /api/conversations/{contact_id}/unsubscribe stops all messages to this contact and cancels their pending automation steps. Response: { "success": true, "opted_out": true, "flows_cancelled": 2 }.
POST /api/conversations/{contact_id}/resubscribe undoes it (cancelled steps are not restarted). Both return 404 for an unknown contact.
Leads and automations
Add a lead
POST /webhook/inbound/generic
Use this from forms, landing pages, Zapier/Make/n8n or your CRM. The contact is created or updated by phone number, and every automation for new leads starts, such as a welcome template.
curl -X POST https://webbai.nl/webhook/inbound/generic \
-H "Authorization: Bearer $WEBBAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "+31612345678",
"name": "Sanne de Vries",
"email": "sanne@example.com",
"source": "website",
"metadata": { "form": "offerte", "product": "kitchen" }
}'
| Field | Type | Required | |
|---|---|---|---|
phone | string | yes | |
name, email, company | string | no | Filled in on the contact if empty |
source | string | no | Default generic. Automations can filter on it |
event_type | string | no | Default new_lead |
metadata | object | no | Stored on the contact |
Response: { "success": true, "contact_id": "...", "lead_id": "..." }. Errors: 400 without phone, 401 for an invalid key.
POST /api/leads/manual does the same with phone, name, email, company, source, notes and fire_automations (default true), and returns automations_fired.
List leads
GET /api/leads returns the 100 newest leads plus stats. Filter with ?tags=vip,hot (any of the tags).
Start an automation for a contact
POST /api/flows/{flow_id}/trigger
Starts a flow whose trigger is Manual in the dashboard. flow_id is the id from GET /api/flows.
curl -X POST https://webbai.nl/api/flows/Offerte%20opvolging/trigger \
-H "Authorization: Bearer $WEBBAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone": "+31612345678", "name": "Sanne", "metadata": {"quote_id": "Q-88"}}'
Response: { "success": true, "contact_id": "...", "steps_queued": 3, "steps": [...] }. Steps are queued with their delays; opt-outs and send limits are checked when each step is sent. Errors: 404 flow not found or inactive, 400 flow not set to manual.
Templates
| Method | Path | |
|---|---|---|
GET | /api/templates | Your templates and their Meta status (APPROVED, PENDING, REJECTED) |
POST | /api/templates | Create a template and submit it to Meta |
PATCH | /api/templates/{name} | Edit and resubmit |
DELETE | /api/templates/{name} | Delete (all languages) |
Create:
{
"name": "order_ready",
"category": "UTILITY",
"language": "nl",
"body_text": "Hoi {{1}}, je bestelling {{2}} ligt klaar!",
"body_examples": ["Sanne", "A-1042"],
"footer_text": "Bar Company",
"buttons": ["Thanks!", { "type": "URL", "text": "Track", "url": "https://example.com/track" }]
}
Rules: name uses lowercase letters, digits and _. Every {{n}} needs an example. At most 3 buttons of 25 characters. Footer up to 60 characters, without variables. Meta usually reviews within minutes to a few hours. With an event webhook you get a template.status event when it's decided.
Event webhooks
Webbai POSTs every WhatsApp event to your URL as JSON: incoming messages (including voice notes, photos and files), delivery status, messages you send from the WhatsApp Business app, and template decisions.
Set up
In the dashboard under Settings → Event webhook, or with the API:
curl -X PUT https://webbai.nl/api/webhooks \
-H "Authorization: Bearer $WEBBAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://your-app.com/webbai", "events": ["message.received", "message.status"]}'
The response contains secret (starts with whsec_) only when the webhook is created. Store it; you need it to verify requests.
| Method | Path | |
|---|---|---|
GET | /api/webhooks | Configuration and the 50 most recent deliveries |
PUT | /api/webhooks | Create or update: url (https), events, active |
DELETE | /api/webhooks | Stop forwarding |
POST | /api/webhooks/test | Send a webhook.test event now and return your server's answer |
POST | /api/webhooks/reveal-secret | Show the signing secret |
POST | /api/webhooks/rotate-secret | New secret; the old one stops working |
GET | /api/webhooks/deliveries | Delivery log |
GET | /api/webhooks/deliveries/{id} | One delivery, with the full payload |
POST | /api/webhooks/deliveries/{id}/replay | Send a delivery again |
Events
| Event | When |
|---|---|
message.received | A customer sent you something: text, voice note, photo, video, document, sticker, location, contact card, reaction, button or list reply |
message.status | A message you sent was sent, delivered, read or failed |
message.echo | You sent a message from the WhatsApp Business app on your phone |
template.status | Meta approved or rejected a template |
webhook.test | You pressed "Send test event" |
Payload
Each request is one event:
{
"id": "evt_8c2f…",
"type": "message.received",
"created_at": "2026-11-17T09:41:03.120Z",
"number": "+31612344821",
"contact_id": "c1f0…",
"from": { "phone": "+31687654321", "name": "Sanne" },
"message": {
"id": "wamid.HBgL…",
"type": "audio",
"timestamp": "2026-11-17T09:41:02.000Z",
"text": null,
"media": {
"id": "1234567890",
"mime_type": "audio/ogg; codecs=opus",
"voice": true,
"url": "https://webbai.nl/media/1234567890?c=…&exp=…&sig=…",
"url_expires_at": "2026-11-24T09:41:03.000Z"
},
"raw": { }
},
"window_open_until": "2026-11-18T09:41:02.000Z"
}
message.textholds the text, a button/list title, or a media caption.message.mediais present foraudio,image,video,documentandsticker.voice: truemarks a voice note.message.location,message.reaction,message.contactsandmessage.interactiveappear for those types.message.reply_tois the id of the message the customer replied to.message.rawis the original WhatsApp message object, for anything not covered above.
A message.status event:
{
"id": "evt_…", "type": "message.status", "number": "+31612344821",
"message": { "id": "wamid…", "status": "delivered", "to": "+31687654321", "timestamp": "…", "errors": null }
}
Verify the signature
Every request has these headers:
X-Webbai-Event: message.received
X-Webbai-Delivery: evt_8c2f…
X-Webbai-Timestamp: 1794908463
X-Webbai-Signature: sha256=5b0e…
The signature is an HMAC-SHA256, with your webhook secret, of the timestamp, a dot and the raw request body. Compare in constant time and reject old timestamps:
import crypto from 'node:crypto';
function verifyWebbai(rawBody, headers, secret) {
const ts = headers['x-webbai-timestamp'];
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(`${ts}.${rawBody}`).digest('hex');
const got = headers['x-webbai-signature'] || '';
return got.length === expected.length && crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected));
}
import hmac, hashlib, time
def verify_webbai(raw_body: bytes, headers, secret: str) -> bool:
ts = headers["X-Webbai-Timestamp"]
if abs(time.time() - int(ts)) > 300:
return False
expected = "sha256=" + hmac.new(secret.encode(), f"{ts}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, headers.get("X-Webbai-Signature", ""))
Delivery and retries
- Answer with any
2xxwithin 10 seconds. Do slow work (AI, CRM updates) after responding. - Anything else is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours. After that the delivery is marked
failedand can be replayed from the dashboard or the API. - Redirects are not followed.
- The same WhatsApp message is delivered once. On a retry
X-Webbai-Deliverystays the same, so you can use it to deduplicate. - Deliveries are kept for 30 days.
Media
GET /media/{media_id}
Downloads a voice note, photo, video or document a customer sent you. Two ways to authenticate:
- Use the
media.urlfrom the webhook event as is. It is signed and works without a header for 7 days. - Use
Authorization: Bearer <your API key>with themedia_idfrom the timeline.
The response is the file itself with its Content-Type, e.g. audio/ogg for voice notes. WhatsApp keeps media for about 30 days; after that you get 404, so store files you need.
MCP for AI agents
The same account is available as an MCP server for Claude, ChatGPT, Cursor and other agents:
https://webbai.nl/mcp
It uses streamable HTTP and OAuth sign-in in the browser. Claude Code can also authenticate with the API key:
claude mcp add --transport http webbai https://webbai.nl/mcp --header "Authorization: Bearer $WEBBAI_API_KEY"
Main tools: get_inbound_messages, send_whatsapp_message, send_whatsapp_template, list_whatsapp_templates, create_whatsapp_template, get_send_logs, search_contacts, get_leads, send_bulk_template and list_automations. Step-by-step instructions for agents: /agents.md.
Limits
| API requests | 100 per minute per IP |
| Free-form messages per day | Depends on your plan, see Settings |
| Messages per hour | 80 |
| Webhook timeout | 10 seconds |
| Signed media URL | 7 days |
Meta charges separately for templates outside the 24-hour window. You pay those costs directly to Meta.
Support
Questions or something not working? Email support from the dashboard (Settings → Contact), and include the X-Webbai-Delivery id or the message_id you're asking about.