WhatsApp API & Webhooks documentation
Connect your store, website or CRM to WhatsApp Business through ChatLike: send WhatsApp templates automatically on every order, or control messages, templates and flows from your code and receive events on your server.
Overview: two ways to integrate
Webhook Automation
A private inbound URL. Your store POSTs JSON to it, and ChatLike sends an approved WhatsApp template to the customer using rules you set in the dashboard, without code.
Start with the webhookCRM API
A REST API for developers with API keys: send text, template, media and interactive messages, start flows, manage templates, and receive message events on your server.
Start with the API| Webhook Automation | CRM API | |
|---|---|---|
| For | Store owners and no-code tools | Developers and CRM systems |
| Direction | Your system POSTs JSON to one URL | Your code calls specific endpoints |
| Authentication | A secret per webhook | Scoped API keys |
| Message types | Approved templates only | Text, template, media, interactive |
| Events to your server | No; results appear in Webhook Logs | message.received, message.sent, message.status, message.failed |
| Best for | Order confirmations, shipping updates, reminders | Custom apps needing full control and delivery status |
Before you start
- Create a ChatLike account and subscribe to a plan that includes WhatsApp. The CRM API requires an active WhatsApp subscription; otherwise it returns
403 subscription_required. - Connect your WhatsApp Business number from the Connect page in the dashboard.
- Create the message templates you will use and wait for Meta approval. Templates are the only way to message a customer who has not messaged you in the last 24 hours.
- Write phone numbers in full international format with the country code, such as
201001234567. Spaces and symbols are removed automatically, but the country code is not added for you.
Webhook Automation
In the dashboard, go to WhatsApp → Webhook Automation → Manage Webhooks and create a webhook with a descriptive name. You get a unique URL and a secret. Then link it to an approved template under Automation rules.
The request
https://app.chatlike.net/whatsapp_cloud/incoming_webhook/{webhook_token}- Body: raw JSON with the header
Content-Type: application/json. - Authentication: send the secret in the
X-Webhook-Secretheader (recommended), or inAuthorization: Bearer. - The JSON can contain any fields; your rule decides which fields are used.
How the request is processed
- The server checks the secret, then that the body is valid JSON.
- Every active rule linked to the webhook runs, oldest first. There are no conditions between rules, so three rules mean three messages. Use a separate webhook for each event type (new order, shipped…).
- Each rule reads the customer phone from the phone path you set; if missing, it tries
phone, thencustomer.phone. - Template variables
{{1}},{{2}}… are filled from JSON paths in order. Use dot paths such asorder.id, and[0]for list items, such asorder.items[0].name. - The template is sent, and every run is recorded on the Webhook Logs page with the received payload and the Meta response.
Connecting platforms
- Zapier / Make / n8n: use an HTTP or “Webhooks: POST” action with JSON, and add the
X-Webhook-Secretheader. - WooCommerce and Shopify: their built-in webhooks cannot add a custom header; route the order through Zapier, Make, n8n or a small relay server that adds the header. The phone is usually at
billing.phonein WooCommerce, andcustomer.phoneorshipping_address.phonein Shopify. - Custom backend: send the request from your server as in the examples below.
Full example: order confirmation
1 The JSON your store sends
{
"event": "order.created",
"customer": {
"name": "Ahmed",
"phone": "+20 100 123 4567"
},
"order": {
"id": "1042",
"total": "79.90 EGP",
"items": [ { "name": "Blue T-shirt", "qty": 2 } ]
}
}2 The approved template
A Utility template named order_confirmation in en_US:
Hi {{1}}, your order #{{2}} ({{3}}) is confirmed. Thank you!3 The automation rule
| Phone path | customer.phone |
| Template | order_confirmation · en_US |
{{1}} | customer.name |
{{2}} | order.id |
{{3}} | order.total |
4 Send the request
curl -X POST "https://app.chatlike.net/whatsapp_cloud/incoming_webhook/{webhook_token}" \
-H "Content-Type: application/json" \
-H "X-Webhook-Secret: YOUR_WEBHOOK_SECRET" \
-d '{"event":"order.created","customer":{"name":"Ahmed","phone":"+20 100 123 4567"},"order":{"id":"1042","total":"79.90 EGP"}}'await fetch("https://app.chatlike.net/whatsapp_cloud/incoming_webhook/{webhook_token}", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Webhook-Secret": process.env.WEBHOOK_SECRET
},
body: JSON.stringify(order)
});$ch = curl_init('https://app.chatlike.net/whatsapp_cloud/incoming_webhook/{webhook_token}');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Webhook-Secret: ' . getenv('WEBHOOK_SECRET'),
],
CURLOPT_POSTFIELDS => json_encode($order),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
]);
$response = curl_exec($ch);import os, requests
requests.post(
"https://app.chatlike.net/whatsapp_cloud/incoming_webhook/{webhook_token}",
json=order,
headers={"X-Webhook-Secret": os.environ["WEBHOOK_SECRET"]},
timeout=15,
)5 The result
The phone becomes 201001234567 and the customer receives:
The URL replies with 200:
{
"success": true,
"message": "Processed webhook.",
"sent": 1,
"failed": 0,
"errors": []
}Responses & errors
sent is the number of messages Meta accepted, failed the number of failed rules, and errors their details. Full details of every attempt are on the Webhook Logs page.
| Code | Meaning | Fix |
|---|---|---|
200 | Processed. If no rule is active, the request is logged as “Skipped” and nothing is sent. | Check sent and errors. |
400 | Invalid JSON, or the URL token is missing. | Send raw JSON with Content-Type: application/json. |
403 | The secret is missing, wrong, or was regenerated. | Copy the current secret from Manage Webhooks. |
404 | Wrong URL, or the webhook is inactive or deleted. | Copy the URL again and make sure it is active. |
503 | The WhatsApp number linked to the webhook is not connected. | Reconnect the number in the dashboard. |
Per-rule errors appear in errors with a 200 response. Common ones: phone not found in the payload, a template that is not approved or uses a different language, a variable count that does not match the template, or a recipient not allowed on a Meta test number.
CRM API
Create an API key in the dashboard under WhatsApp → CRM API. The key is shown only once when created, so copy it and store it securely. When you create it, you choose:
- Scopes:
read,send,templates,flows,contacts,webhooks. Give each system only what it needs. - Allowed IPs (optional): exact addresses or CIDR ranges.
- WhatsApp account (optional): to bind the key to one number; you can then omit
account_idfrom requests.
Base URL and headers
https://app.chatlike.net/crm_api/v1Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Idempotency-Key: order-1042-confirmationAuthorization: Beareris required on every request.Idempotency-Key: send a stable, unique value with every POST. Retrying with the same value returns the original response without a duplicate send; reusing it with a different body returns409 idempotency_conflict.- Every response is JSON:
{"success", "status", "data"}on success, or{"success": false, "status", "error": {"code", "message"}}on error.
Endpoints
| Scope | Request | Purpose |
|---|---|---|
| read | GET /accounts | Your WhatsApp numbers and their IDs |
| read | GET /conversations | List conversations |
| read | GET /conversations/{contact_id}/messages | Messages in a conversation |
| read | GET /events | Poll new events instead of receiving them |
| read | GET /media/{media_id} | Download inbound message media |
| send | POST /messages/text | Text message (inside the 24-hour window) |
| send | POST /messages/template | Approved template (any time) |
| send | POST /messages/media | Image, video, document or audio |
| send | POST /messages/interactive | Message with buttons |
| templates | GET /templates · POST /templates | List templates or submit a new one for approval |
| templates | GET|PUT /templates/{name}/actions | What each quick-reply button does: plain reply, start a flow, or stop marketing messages |
| flows | GET /flows · GET /flows/{id} | List and read flows |
| flows | POST /flows/import · POST /flows/{id}/update | Import or update a flow |
| flows | POST /flows/{id}/start | Start a flow for a customer |
| contacts | POST /contacts/{contact_id}/pause_bot · resume_bot | Pause or resume the bot for a contact |
| webhooks | GET|POST /webhooks · DELETE /webhooks/{id} · POST /webhooks/{id}/test | Manage outbound events to your server |
Sending messages
409 session_closed; send an approved template instead.Text message
curl -X POST "https://app.chatlike.net/crm_api/v1/messages/text" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: reply-7781" \
-d '{"account_id": 1, "to": "201001234567", "message": "Hello Ahmed, how can we help?"}'Approved template
body_variables fill {{1}}, {{2}}… in order.
POST https://app.chatlike.net/crm_api/v1/messages/template
{
"account_id": 1,
"to": "201001234567",
"template_name": "order_confirmation",
"language": "en_US",
"body_variables": ["Ahmed", "1042", "79.90 EGP"]
}Media
media_type: image, video, document, audio or sticker. Use a public https link; add filename for documents.
POST https://app.chatlike.net/crm_api/v1/messages/media
{
"account_id": 1,
"to": "201001234567",
"media_type": "image",
"media_url": "https://example.com/invoice-1042.jpg",
"caption": "Your invoice"
}Interactive buttons
POST https://app.chatlike.net/crm_api/v1/messages/interactive
{
"account_id": 1,
"to": "201001234567",
"body": "How would you like to continue?",
"buttons": [
{"id": "track", "title": "Track order"},
{"id": "support", "title": "Talk to support"}
]
}Start a flow
POST https://app.chatlike.net/crm_api/v1/flows/{flow_id}/start
{
"account_id": 1,
"to": "201001234567",
"text": "start"
}Response format
HTTP/1.1 201 Created
{
"success": true,
"status": 201,
"data": {
"account_id": 1,
"message_id": "wamid.HBgM...",
"local_message_id": 5521,
"to": "201001234567",
"type": "text"
}
}API errors
HTTP/1.1 409 Conflict
{
"success": false,
"status": 409,
"error": {
"code": "session_closed",
"message": "24-hour customer service window is closed. Send a template instead."
}
}| Status | error.code | Meaning |
|---|---|---|
401 | unauthorized | Missing, invalid or revoked API key. |
403 | forbidden | The key lacks the required scope. |
403 | ip_not_allowed | Your IP is not allowed for this key. |
403 | subscription_required | No active WhatsApp subscription. |
403 | forbidden_account | The key is bound to a different WhatsApp account. |
404 | account_not_found | Wrong account_id. |
409 | session_closed | 24-hour window closed; send a template. |
409 | not_connected · account_paused | The number is disconnected or paused. |
409 | idempotency_conflict | Idempotency-Key reused with a different request. |
422 | invalid_request | Required fields are missing or invalid. |
502 | meta_api_error | Meta rejected the send (template not approved, invalid number…). The original Meta message is in error.message. |
Outbound events to your server
Add your server URL on the CRM API page or with POST /webhooks, and choose the events you want. The signing secret is shown only once when created.
| Event | When it is sent |
|---|---|
message.received | A new message from a customer. Includes Click-to-WhatsApp ad data in referral when available. |
message.sent | A message was sent from your account. |
message.status | A message status changed (delivered, read…). Sent only if you select it explicitly. |
message.failed | A message failed to deliver. |
flow.started | A flow started for a customer. |
webhook.test | A test event from the Test action. |
POST https://your-server.example/whatsapp-events
Content-Type: application/json
X-CRM-API-Event: message.received
X-CRM-API-Signature: sha256=5f2b9c...
{
"event": "message.received",
"created_at": "2026-11-27T10:15:00+02:00",
"account_id": 1,
"data": {
"message": {
"wa_id": "201001234567",
"direction": "in",
"type": "text",
"body": "Where is my order?"
}
}
}Verifying the signature
Every request carries X-CRM-API-Signature: sha256=<HMAC-SHA256> computed over the raw body with your secret. Compute it over the bytes exactly as received, compare in constant time, and reject the request if it differs.
import crypto from "node:crypto";
// rawBody must be the exact bytes received (not re-serialized JSON)
function isValid(rawBody, signatureHeader, secret) {
const expected = "sha256=" +
crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
const a = Buffer.from(expected), b = Buffer.from(signatureHeader || "");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}$raw = file_get_contents('php://input');
$expected = 'sha256=' . hash_hmac('sha256', $raw, getenv('CRM_WEBHOOK_SECRET'));
$given = $_SERVER['HTTP_X_CRM_API_SIGNATURE'] ?? '';
if (!hash_equals($expected, $given)) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
// ... handle $event['event'] and $event['data']
http_response_code(200);- Return a
2xxwithin 8 seconds, then process the event in the background if it takes longer. - Failed attempts and your server responses appear under Webhook Deliveries on the CRM API page.
- If you have no public URL, poll events with
GET /events.
FAQ
Do I need a subscription to use the API?
Yes. You need a ChatLike account and a connected WhatsApp number, and the CRM API requires an active WhatsApp subscription. Meta message fees are separate from the subscription. Estimate message fees
Which should I choose: Webhook Automation or the CRM API?
If you only need to send a fixed template when something happens in your store, the webhook is faster and needs no code. If you need free text, media, reading conversations or delivery status, use the CRM API.
Can I message a customer who never messaged me?
Yes, with an approved template only, and only after the customer has agreed to receive your WhatsApp messages under Meta policies.
What happens if I regenerate the webhook secret?
The old secret stops working immediately, and every integration that uses it gets 403 until it is updated with the new one.
Where can I see request logs?
Webhook requests are on Webhook Logs; CRM API requests and outbound event deliveries are on the CRM API page in the dashboard.
Ready to integrate?
Create your account, connect a WhatsApp number, and get your webhook URL or API key from the dashboard.