Guides
Webhooks
Set up the callback with the hub.challenge handshake, choose the subscribed fields and learn the envelope of every webhook.
Mimicr sends your callback the same webhooks as Meta: a JSON POST, signed with the app secret, for every event of every subscribed field.
Callback verification
Before saving the URL, Mimicr runs Meta's handshake:
GET https://seu-servidor.example.com/webhooks/whatsapp?hub.mode=subscribe&hub.verify_token=meu-token-de-verificacao&hub.challenge=1389737617
Your app checks hub.verify_token and answers 200 with the hub.challenge as the body, nothing else:
app.get("/webhooks/whatsapp", (req, res) => {
if (req.query["hub.mode"] === "subscribe" && req.query["hub.verify_token"] === process.env.WHATSAPP_VERIFY_TOKEN) {
return res.status(200).send(req.query["hub.challenge"]);
}
res.sendStatus(403);
});Set up the URL in one of these ways:
- In the console, under Webhooks ("Verify and save").
- With the control API:
PUT /v1/whatsapp/{slug}/webhooks/callbackwith{"url", "verify_token"}. It answers200with the handshake result, or422with what your app answered. - With the Graph API, as a tech provider would: Subscribe the app with
override_callback_uriandverify_token. If the handshake fails, it answers2200.
DELETE /v1/whatsapp/{slug}/webhooks/callback turns the callback off. Without a callback, events are recorded as skipped.
Fields
| Field | Subscribed by default | When |
|---|---|---|
messages | Yes | Incoming messages and statuses of sent ones |
message_template_status_update | Yes | Template review |
message_template_quality_update | Yes | Template quality |
template_category_update | Yes | Recategorization |
message_template_components_update | Yes | Template edit |
phone_number_quality_update | Yes | Number quality and limit |
account_update | Yes | Account events |
user_preferences | Yes | The customer stopped or resumed marketing |
phone_number_name_update, account_review_update, account_alerts, business_capability_update, flows, security, smb_message_echoes | No | Only through the test emitter |
curl --request PUT \
--url https://api.mimicr.dev/v1/whatsapp/docs/webhooks/fields \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "account_update": false, "flows": true }'Events of unsubscribed fields are recorded as skipped with the reason.
Envelope
{
"object": "whatsapp_business_account",
"entry": [{
"id": "313255174969123",
"changes": [{
"field": "messages",
"value": {
"messaging_product": "whatsapp",
"metadata": { "display_phone_number": "555532704202", "phone_number_id": "424361664134261" },
"contacts": [{ "profile": { "name": "Ana Ribeiro" }, "wa_id": "5511987654321" }],
"messages": [{ "from": "5511987654321", "id": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABEYEjY0M0JCNDQ5MzQyMEMxMjVGNQA=", "timestamp": "1793914184", "type": "text", "text": { "body": "Oi, quero saber do meu pedido" } }]
}
}]
}]
}entry[].id is the WABA of the number or template. Template webhooks carry entry[].time. Each POST carries one event.
Headers
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | facebookexternalua |
X-Hub-Signature-256 | sha256= + HMAC-SHA256 of the raw body with the app secret |
X-Hub-Signature | sha1= + HMAC-SHA1 of the raw body (legacy) |
Answer 200 quickly and process afterwards. See Verify the signature, Incoming messages and Delivery statuses.
Fire a test event
curl --request POST \
--url https://api.mimicr.dev/v1/whatsapp/docs/webhooks/emit \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "field": "account_update", "event": "DISABLED_UPDATE" }'Any field is accepted; without value, a sample payload goes out. GET /v1/whatsapp/{slug}/webhooks lists the last 50 deliveries with status, attempts and body.