Skip to content

Webhooks

Last verified against Graph API v26.0 on 2026-11-21.

Receiving inbound messages and delivery statuses is a two-step model:

  1. GET verification. When you configure the webhook, Meta sends a GET request with hub.mode, hub.verify_token, and hub.challenge. Echo the raw hub.challenge back with a 200 when the token matches your verify token; otherwise return 403. The challenge must be the raw response body, not JSON.
  2. POST deliveries. Meta POSTs event payloads signed with X-Hub-Signature-256. Verify the signature against the raw request body using your App Secret, return 200 quickly, then process.

Three secrets are involved, and they are not interchangeable:

  • Verify token: a string you define, used only for the GET handshake.
  • App Secret: from your Meta app settings, used to verify X-Hub-Signature-256.
  • Access token: used to send messages, never for webhooks.

createWebhookHandler is the quickest way to receive webhooks: it does both steps and calls the handlers you register. See Webhook handler. The rest of this section covers the lower-level WebhookHandler, which binds the secrets once. handler.handleVerification(query) answers the handshake, and handler.parse(rawBody, signature) verifies the signature and parses the payload, throwing WhatsAppWebhookError when the signature is missing or invalid.

Signature checking is on only when you pass appSecret. If you leave the appSecret key out, parse accepts unsigned bodies, so only do that when something else authenticates the request. If you pass appSecret or verifyToken with an undefined or empty value (for example an unset environment variable), the constructor throws a WhatsAppWebhookError instead of quietly turning verification off. verifySignature returns false, and the verify-token handshake returns 403, whenever the configured secret is empty.

handler.parse rejects bodies over 3 MiB (Meta’s documented maximum) before hashing or parsing them. Raise the limit with new WebhookHandler({ maxBodyBytes }), or pass false to turn it off.

Independent open-source project. Not affiliated with, endorsed by or sponsored by Meta or WhatsApp. Released under the MIT licence. Source on GitHub.