What is a webhook?

Definition

A webhook is an HTTP callback: instead of your code asking the API whether anything happened, the API posts the event to a URL you registered. Wapito uses webhooks for every inbound message, delivery receipt, group change, poll vote and session state change.

In more depth

Polling does not work for WhatsApp. Messages arrive whenever someone types, and a poll loop is either too slow to be useful or so frequent that it burns your request allowance for nothing. A webhook flips the direction: you register an HTTPS endpoint, choose which events you want by exact name or by prefix, and Wapito delivers each one as a JSON body with a signature header. Three rules make a receiver reliable. Verify the signature against the raw bytes of the body before parsing, because any re-serialisation changes the hash and the check will fail for the wrong reason. Answer quickly with a 2xx and do the real work in a queue, because a slow endpoint is retried and a retried delivery becomes a duplicate. And make handlers idempotent by keying on the delivery id, since at-least-once delivery means you will eventually see the same event twice. Register several endpoints if different systems need different events; each one has its own filter and its own secret.

In the Wapito API

On the wire it is the field X-Wapito-Signature:

{
  "event": "messages",
  "channel_id": "ch_123",
  "data": {
    "id": "true_441234567890@c.us_3EB0"
  }
}

On the official Cloud API

The Cloud API also delivers webhooks, verified with its own signature header, but only for the conversations and templates it manages - there are no group, community or status events to subscribe to.

Wapito is an independent product. It is not affiliated with, endorsed by, sponsored by or certified by WhatsApp or Meta Platforms, Inc. WhatsApp is a trademark of Meta Platforms, Inc.

Related terms

Related

Try it on your own number

Create a channel, link a WhatsApp number by QR or pairing code, and call the API in a couple of minutes. The Sandbox plan is free and needs no card.