Blog/Guides & Know-how

WhatsApp Cloud API webhooks explained: verification, events, signatures and retries

How WhatsApp Cloud API webhooks work: the verify token handshake, message and status events, returning 200 fast, X-Hub-Signature-256 checks and retries.

LinkModus team · · 6 min read

Short answer

A WhatsApp Cloud API webhook is an HTTPS endpoint on your server that Meta calls whenever a customer messages your number or a message you sent changes status (sent, delivered, read, failed). You set it up once with a verify token handshake, then Meta POSTs JSON events to it. Your server should check the X-Hub-Signature-256 header, return HTTP 200 within a few seconds, and process the event afterwards. If you do not return 200, Meta retries, so you must also ignore duplicates by message id.

Every WhatsApp tool built on the official API, from a simple auto-reply to a full WhatsApp CRM, depends on one thing working reliably: the webhook. If it is slow, misconfigured or down, customer messages simply do not reach your system. Your team sees an empty inbox while customers in Pune or Chennai wait for a reply.

This guide is for owners who want to understand what their developer or vendor is doing, and for in-house developers setting it up for the first time. The first half is plain English; the second half has the technical detail.

What is a webhook, in plain words?

A webhook is a phone number for software: instead of your system calling Meta every few seconds to ask “any new messages?”, Meta calls your system the moment something happens.

Think of a courier who rings your doorbell instead of you walking to the depot every hour. You give Meta an address (a URL like https://api.yourbusiness.in/whatsapp/webhook), and Meta delivers a small JSON parcel there for each event. Your software opens the parcel, saves the message, and decides what to do next: show it in the inbox, send an AI reply, alert a salesperson.

Two kinds of parcel arrive most often:

  • Messages: a customer sent text, an image, a voice note, a location, or tapped a button.
  • Statuses: a message you sent was sent, delivered, read or failed (with an error code explaining why).

How does the verify token handshake work?

Before Meta sends any real events, it checks that you control the URL by sending a one-time GET request that your server must echo back.

In the Meta app dashboard, under WhatsApp configuration, you enter two things: the callback URL and a verify token. The verify token is any secret string you invent. When you click save, Meta calls your URL with three query parameters:

  1. hub.mode, which is subscribe
  2. hub.verify_token, the string you typed
  3. hub.challenge, a random value

If the mode is subscribe and the token matches what your server expects, respond with status 200 and the challenge value as the plain body. Otherwise respond 403. Then subscribe to the messages field so Meta actually sends message and status events. A minimal handler in Node.js looks like this:

app.get('/whatsapp/webhook', (req, res) => {
  const mode = req.query['hub.mode'];
  const token = req.query['hub.verify_token'];
  const challenge = req.query['hub.challenge'];
  if (mode === 'subscribe' && token === process.env.WA_VERIFY_TOKEN) {
    return res.status(200).send(challenge);
  }
  return res.sendStatus(403);
});
The verify token is not the same as your access token or app secret. It only proves you own the URL during setup. Keep it in an environment variable anyway.

What do message and status events look like?

Every event arrives as a POST with a nested JSON body: an entry array, each with changes, each with a value that holds either messages or statuses.

The value also includes metadata.phone_number_id, which tells you which of your numbers the event belongs to. If you run several numbers, or several businesses on one app, that id is how you route the event. A trimmed inbound message looks roughly like this:

{
  "object": "whatsapp_business_account",
  "entry": [{
    "changes": [{
      "field": "messages",
      "value": {
        "metadata": { "phone_number_id": "1234567890" },
        "contacts": [{ "profile": { "name": "Priya" }, "wa_id": "919876543210" }],
        "messages": [{
          "from": "919876543210",
          "id": "wamid.HBgM...",
          "timestamp": "1764300000",
          "type": "text",
          "text": { "body": "Is the 2BHK in Wakad still available?" }
        }]
      }
    }]
  }]
}

Status events carry the same envelope with a statuses array instead: the message id you sent, the status, the recipient, and for failures an errors array. Failure codes matter. Some mean the user is not on WhatsApp, some mean you are outside the 24-hour window and need a template, and some point to a problem with your number’s quality or limits.

EventWhat it tells youWhat to do
messages (text, image, audio, button)A customer wrote or tapped somethingStore it, reply inside the 24h window
statuses: sent / deliveredYour message reached WhatsApp / the phoneUpdate the tick in your inbox
statuses: readThe customer opened it (if read receipts are on)Useful for follow-up timing
statuses: failedDelivery failed, with an error codeLog the code, fix the cause, do not blindly resend

Why must your webhook return 200 fast?

Meta treats anything other than a quick 200 response as a failed delivery and will try again, so a slow handler creates duplicates and delays.

The common mistake is doing all the work inside the request: calling an AI model, writing to the CRM, sending the reply, then returning 200. That can take several seconds, and under load it gets worse. The safe pattern is:

  1. Check the signature.
  2. Save the raw event (or push it to a queue).
  3. Return 200 immediately.
  4. Process the event in a background worker.

Also return 200 for events you do not care about, such as a number you have since disconnected. Returning an error for those only makes Meta keep retrying them.

How do you check the X-Hub-Signature-256 header?

Meta signs every POST with your app secret, and you verify it by computing the same HMAC-SHA256 over the raw body and comparing.

The header looks like sha256= followed by a hex string. Two details trip people up. First, you must hash the raw bytes of the body, not JSON you have parsed and re-serialised, because even a changed space breaks the match. Second, compare with a constant-time function so the check does not leak timing information.

const crypto = require('crypto');

function isFromMeta(rawBody, header, appSecret) {
  const expected = 'sha256=' + crypto
    .createHmac('sha256', appSecret)
    .update(rawBody)
    .digest('hex');
  const a = Buffer.from(expected);
  const b = Buffer.from(header || '');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Without this check, anyone who discovers your webhook URL can post fake “customer messages” into your system. For a business that triggers payment links or lead alerts from incoming messages, that is a real risk.

How do retries and duplicates work?

When a delivery fails, Meta retries it with increasing gaps between attempts, and the same event can arrive more than once even when nothing failed.

Meta’s documentation describes retries continuing for an extended period, up to several days, for undelivered webhooks. That is useful after a short outage, because messages are not lost, but it means your code must be idempotent. The rule is simple: every inbound message has a unique id (the wamid). Keep a unique index on it in your database, and if an insert fails because the id already exists, skip the event. Do the same for statuses by storing the latest status per outbound message id, and never let a late “delivered” overwrite a “read”.

Events can arrive out of order. Use the timestamp inside the event, not the time your server received it, when you sort a conversation.

What usually goes wrong in Indian setups?

Most webhook problems we see come from configuration, not code.

  • The app is not subscribed to the WhatsApp Business Account. The URL verifies, but no events arrive.
  • The messages field is not ticked in the webhook fields list.
  • An expired or self-signed SSL certificate on the server. Meta needs valid HTTPS.
  • A firewall or WAF blocking Meta’s requests, often on shared hosting.
  • Body parsers that drop the raw body, so every signature check fails.
  • Ads traffic pointed at the wrong number, so events arrive for a phone number id your system does not recognise and are silently ignored.

If customers say they messaged you and your inbox is empty, check these in order before blaming WhatsApp.

How LinkModus helps

If you use LinkModus on the official WhatsApp Business API, you do not build any of this. The webhook, signature checks, duplicate handling and status tracking are already running, and every message lands in a shared team inbox where the AI agent replies in seconds. If your own systems need the same events, LinkModus has a public REST API and outgoing webhooks for events such as a new lead or a recorded sale, so your developer subscribes once instead of parsing Meta’s payloads. For broader setup, see WhatsApp integrations.

Frequently asked questions

What is a WhatsApp Cloud API webhook?+

It is a URL on your server that Meta calls with an HTTPS POST whenever something happens on your WhatsApp Business number: a customer sends a message, or a message you sent is delivered, read or fails.

What is the verify token in WhatsApp webhooks?+

A secret string you choose and type into the Meta app dashboard. When you save the callback URL, Meta sends a GET request with hub.mode, hub.verify_token and hub.challenge. If the token matches yours, you reply with the hub.challenge value and the webhook is verified.

Why must a webhook return 200 quickly?+

If Meta does not get a 200 response in time, it treats the delivery as failed and retries it. Slow handlers cause duplicate deliveries and, if failures continue, delays. Acknowledge first, then do the slow work such as AI replies or CRM updates.

How do I verify that a webhook really came from Meta?+

Compute an HMAC-SHA256 of the raw request body using your Meta app secret and compare it with the X-Hub-Signature-256 header, which looks like sha256= followed by the hex digest. Use a constant-time comparison and reject mismatches.

Can the same WhatsApp message arrive twice on my webhook?+

Yes. Retries and network issues can deliver the same event more than once. Store each message id (the wamid) and skip any id you have already processed.

Answer every enquiry, see which ad paid for it

LinkModus replies on WhatsApp in seconds, qualifies the lead and traces each sale back to its ad. First week free.