Developers

What Are WhatsApp Webhooks and How Do They Work?

A developer-focused walkthrough of how WhatsApp webhooks work: the delivery flow, verification, signature checks, idempotency, fast acknowledgement, and where integrations usually break.

Oleh OgaDesk Team · · 4 mnt baca

What Are WhatsApp Webhooks and How Do They Work?

Your WhatsApp Business API number receives a message, and your server needs to know about it right away. Polling the API every few seconds is wasteful and slow. That is the problem webhooks solve.

A webhook is a simple idea. Instead of you asking Meta "any new messages?", Meta sends an HTTP POST to a URL you control the moment something happens. You give it the address, it delivers the event. Your server listens, verifies, and responds.

This post explains how that flow works on the WhatsApp side, what you need to handle, and where things usually break for developers building on the official WhatsApp Business API.

The delivery flow, step by step

Here is what actually happens between a customer tapping send and your code running.

  1. A customer sends a message to your WhatsApp Business number.
  2. Meta's servers receive it and look up the callback URL registered for your app.
  3. Meta sends an HTTP POST to that URL with a JSON payload describing the event.
  4. Your server verifies the request came from Meta.
  5. Your server returns a 200 OK quickly.
  6. Your code processes the payload and decides what to do next, such as replying, storing the message, or triggering an internal action.

Step five matters more than most people think. If your endpoint is slow or returns an error, Meta treats the delivery as failed and retries. If you do heavy work like database writes or calls to other services before responding, you create a backlog of retries that all say the same thing.

What you need to handle on your side

Webhooks are only as reliable as the endpoint receiving them. A few things will save you real pain.

Verification. When you set up the callback URL, Meta sends a GET request with a challenge. Your endpoint must compare the token and return the challenge value to prove you own the URL. Get this wrong and the subscription never activates.

Signature checks. Every POST carries a signature header computed with your app secret. Verify it. Without this, anyone who learns your URL can post fake events to your server.

Idempotency. Retries mean the same event can arrive more than once. Use the message or event ID from the payload to deduplicate before you act on it.

Fast acknowledgement. Return 200 first, queue the work second. A background worker or job queue keeps your endpoint responsive.

Status events too. The payload stream is not only incoming messages. You also get delivery and read statuses, plus account-level events. If you only parse message bodies, you will drop useful information.

Logging. Store the raw payload before you parse it. When something looks wrong later, the raw body is the only honest record of what Meta sent.

A practical checklist before you go live:

  • Verification endpoint returns the challenge correctly
  • Signature verification rejects unsigned or tampered requests
  • Duplicate events are safely ignored
  • Responses return fast under load
  • Failures are logged with the raw payload
  • Your endpoint stays up when you deploy, because retries pile up while it is down

Where developers get stuck

A few problems come up again and again.

The local development gap. Meta needs a public HTTPS URL. Localhost is not one. You either tunnel a local port or test against a staging server. Plan for this before your first integration session, not during it.

Payload shapes vary. Different event types nest data differently. Writing a parser that assumes one shape breaks on the next event type. Read the payload structure carefully and handle each event kind explicitly.

Shared numbers, shared confusion. If several people or systems need to see the same conversation, you need a single source of truth. Two webhook consumers acting on the same message independently create duplicate replies and conflicting state.

Credential management. App secrets and tokens rotate. Hard-coded values in your deployment become outages. Keep them in environment configuration and have a rotation plan.

Keeping pace with Meta. Payload fields and setup requirements change. Read the current Meta policy and changelog rather than relying on a tutorial written two years ago. That advice applies to every part of this integration.

How OgaDesk fits into a webhook setup

If you would rather spend your time on product logic than on webhook plumbing, OgaDesk is a WhatsApp CRM built on the official WhatsApp Business API. You connect through Meta Embedded Signup, with no Meta developer account needed, and the platform handles the shared team inbox, message storage and event processing for you.

For developers, OgaDesk exposes outbound webhooks so your own systems can react to events in the CRM. There is also a public API and a Claude / MCP connection, so you can drive parts of the workflow from tooling you already use. The docs at ogadesk.com/docs cover what is available and how to authenticate.

This is a sensible split for teams that want both. OgaDesk owns the messaging layer and the human inbox, while your webhook endpoint owns whatever happens next in your own systems. You stop rebuilding the same listener and start building the part only you can build.

Getting started

Webhooks are the difference between a WhatsApp number that stores messages and one that drives action in your business. Verify the request, respond fast, deduplicate, log everything, and treat retries as normal rather than exceptional.

If you want the messaging layer handled for you, you can sign up at OgaDesk and connect your number through the official setup. Free and paid plans exist with different limits, so check the pricing page to see which fits your team.

Pertanyaan yang sering diajukan

How does a WhatsApp webhook delivery work?

Meta sends an HTTP POST to the callback URL registered for your app with a JSON payload describing the event. Your server verifies the request, returns 200 OK quickly, then processes the payload to reply, store the message, or trigger an internal action.

Why should I return 200 OK so quickly?

If your endpoint is slow or returns an error, Meta treats the delivery as failed and retries. Doing heavy work before responding creates a backlog of retries that all say the same thing, so return 200 first and queue the work second.

Why do I need idempotency in my WhatsApp webhook endpoint?

Retries mean the same event can arrive more than once. Use the message or event ID from the payload to deduplicate before you act on it, so duplicate events are safely ignored.

  • #whatsapp
  • #webhooks
  • #api
  • #meta
  • #developers