Hira Documentation
FR EN
Free trial

Webhooks

Receive events and verify the signature.

A webhook is an address on your server that we call on every event: a message status, a customer reply, a template change.

answers 2xx fastnot answering10 s1 min5 min15 minGives upWithout a 2xx answer, retry after:Metaevent receivedPlatformsigns and sendsYour server

Hover or click a step to see what it does.

Every delivery is signed. Without a 2xx answer, it is attempted five times in total.

Register an address#

POST /webhook-endpoints with:

  • url: an HTTPS address;
  • scope: account (the whole account), company or connection;
  • events: optional, to receive only some types.

The whsec_... secret is returned only once.

To change the URL or the events filter without recreating the secret: PATCH /webhook-endpoints/{id}.

What you receive#

JSON
{
  "account_id": "acc_...", "company_id": "cmp_...", "connection_id": "con_...",
  "waba_id": "...", "phone_number_id": "...",
  "event_type": "messages",
  "payload": { "object": "whatsapp_business_account", "entry": [ ... ] }
}

The payload is the event exactly as Meta sends it. The X-Wa-Signature and X-Wa-Delivery headers come with every delivery.

Verify the signature#

The header looks like X-Wa-Signature: t=<timestamp>,v1=<signature>, with v1 = HMAC-SHA256("{t}.{raw body}", whsec_...). Verify on the raw body, before any JSON decoding, and reject any request whose timestamp is more than 300 seconds off.

PHP
$header = $_SERVER['HTTP_X_WA_SIGNATURE'] ?? '';
parse_str(str_replace(',', '&', $header), $parts);
$raw = file_get_contents('php://input');
$expected = hash_hmac('sha256', $parts['t'].'.'.$raw, $secret);
$valid = hash_equals($expected, $parts['v1'] ?? '') && abs(time() - (int) $parts['t']) <= 300;

Answer fast#

Answer 2xx quickly, then process the event on your side. Without a 2xx answer, the delivery is attempted 5 times in total: the first one, then four retries after 10 seconds, 1 minute, 5 minutes and 15 minutes.

Handle events idempotently: X-Wa-Delivery identifies each delivery, and the same event can arrive twice.