Start Free — No Credit Card Required · IntelliReply AI now replies in Arabic and EnglishSee plans →

Webhooks

Get incoming WhatsApp messages, delivery and read updates, and contact, group and auto-reply changes posted to your own system as they happen.

A webhook is a URL on your server that ZAPGEN calls whenever something happens: a customer messages you, a message is delivered or read, a contact changes. Use webhooks to log conversations in your CRM, trigger your own automations or keep another system in sync without polling the API.

Webhooks add-on

Webhooks need the Webhooks add-on on your plan. If Developers › Webhooks shows a "page not found" error, your plan doesn't include it: contact us to add it.

Owner only

Only the organization owner can add and change webhooks.

Add a webhook#

  1. Open Developers › Webhooks and click Add Webhook.
  2. Enter your URL. It must start with https:// and be reachable from the internet.
  3. Tick the Events you want to receive.
  4. Click Save.
  5. Open the webhook's menu, choose View/edit and copy the Signing secret. You need it to check the signature.
Developers › Webhooks, the Add Webhook form with a URL and the message events ticked
Developers › Webhooks, the Add Webhook form with a URL and the message events ticked

You can add several webhooks, for example one per system, each with its own events and its own secret. The same URL can only be added once.

How delivery works#

For each event, ZAPGEN sends a POST request with a JSON body to every webhook that has ticked that event:

POST /zapgen/webhook HTTP/1.1
Content-Type: application/json
X-Zapgen-Signature: sha256=5f8d2c0e9b7a…

{"event":"message.received","data":{…}}

The body always has two keys: event, the event name, and data, which depends on the event (see Events).

Answer fast. There are no retries.
  • ZAPGEN waits at most 10 seconds for your answer. Reply with any 2xx status straight away, and do the real work (database writes, calls to other services) afterwards, for example from a queue.
  • If your server is down, slow or returns an error, that event is not sent again. Use the API to catch up after downtime, for example by listing contacts.
  • Redirects aren't followed. Use the final URL.
  • Events are sent as they happen, one request each. They can arrive out of order, so use the timestamps inside the payload rather than the arrival order.

Check the signature#

Every request is signed with the webhook's signing secret so you can make sure it came from ZAPGEN. The X-Zapgen-Signature header holds sha256= followed by the hex HMAC-SHA256 of the raw request body, keyed with the secret.

To check it, compute the same HMAC over the body exactly as received, before parsing the JSON, and compare it in constant time. Don't re-encode the parsed JSON: escaped characters such as \/ and é would change and the signature wouldn't match.

import express from 'express';
import crypto from 'node:crypto';

const app = express();
const SECRET = process.env.ZAPGEN_WEBHOOK_SECRET;

// express.raw keeps the body as bytes, exactly as ZAPGEN sent it
app.post('/zapgen/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const expected = 'sha256=' + crypto.createHmac('sha256', SECRET).update(req.body).digest('hex');
  const received = req.get('X-Zapgen-Signature') || '';

  const valid = received.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected));
  if (!valid) return res.sendStatus(401);

  res.sendStatus(200); // answer first…
  const { event, data } = JSON.parse(req.body.toString('utf8'));
  setImmediate(() => handleEvent(event, data)); // …then do the work
});

Keep the secret on your server, like an API key. If it leaks, delete the webhook and add it again to get a new secret.

Test a webhook#

Click Test next to a webhook. The window lists the events it receives, each with its own Test button that sends a sample payload, signed like a real one, to your URL. The sample data (a contact called John Doe, a "Hi" message) is made up, so don't treat test events as real customers.

The Test Webhook Notifications window, with a Test button next to each event
The Test Webhook Notifications window, with a Test button next to each event

ZAPGEN doesn't show whether your server accepted the request. Check your own server logs, or point the webhook at a request inspector while you build.

Events#

EventWhen it's sent
message.receivedA customer sends you a WhatsApp message.
message.status.updateA message you sent is sent, delivered, read or failed.
message.sentZAPGEN sends a message, from the inbox, a campaign, an automation or the API.
contact.createdA contact is added in the app or through the API.
contact.updatedA contact is edited in the app or through the API.
contact.deletedContacts are deleted.
group.createdA contact group is created.
group.updatedA contact group is renamed.
group.deletedContact groups are deleted.
autoreply.createdA basic auto-reply is created.
autoreply.updatedA basic auto-reply is changed.
autoreply.deletedA basic auto-reply is deleted.

message.received#

data.data is the notification exactly as Meta sent it to ZAPGEN, in Meta's webhook format. The customer's number is in messages[].from, their WhatsApp profile name in contacts[].profile.name, and the message type in messages[].type (text, image, interactive, button, …).

message.received
{
  "event": "message.received",
  "data": {
    "data": {
      "field": "messages",
      "value": {
        "messaging_product": "whatsapp",
        "metadata": {
          "display_phone_number": "971529028088",
          "phone_number_id": "363351553535621"
        },
        "contacts": [
          { "profile": { "name": "Sara Ahmed" }, "wa_id": "971501234567" }
        ],
        "messages": [
          {
            "from": "971501234567",
            "id": "wamid.HBgMOTcxNTAxMjM0NTY3FQIAEhggNjI4NDQ5NjhBQUUzQTU5OTg5NEEzRkM0RjkyNzNGNzQA",
            "timestamp": "1763112061",
            "type": "text",
            "text": { "body": "Hi, is the 2BR in Dubai Marina still available?" }
          }
        ]
      }
    }
  }
}

When the customer taps one of your reply buttons or list rows, the message has "type": "interactive" and the id you gave the button in interactive.button_reply.id (or interactive.list_reply.id for a list). The timestamp is a Unix time in seconds.

Photos, voice notes and documents arrive with Meta's own media ID, which can't be downloaded through ZAPGEN's API. The files are in the chat in your inbox.

message.status.update#

Sent when WhatsApp reports progress on a message you sent. Match statuses[].id with the wamid from the send response. status is sent, delivered, read or failed. Failed messages include Meta's reason in errors.

message.status.update
{
  "event": "message.status.update",
  "data": {
    "data": {
      "field": "messages",
      "value": {
        "messaging_product": "whatsapp",
        "metadata": {
          "display_phone_number": "971529028088",
          "phone_number_id": "363351553535621"
        },
        "statuses": [
          {
            "id": "wamid.HBgMOTcxNTAxMjM0NTY3FQIAERgSQjM0RkE2QTk0RTg4MkQ0NzhBAA==",
            "status": "read",
            "timestamp": "1763112095",
            "recipient_id": "971501234567"
          }
        ]
      }
    }
  }
}

Only updates for messages sent from your organization are forwarded. Customers can turn off read receipts, so not every message reaches read.

message.sent#

Sent every time ZAPGEN sends a message: replies from the inbox, campaign messages, auto-replies, flows and API sends. data.data has the same shape as the data of an API send response.

message.sent
{
  "event": "message.sent",
  "data": {
    "data": {
      "success": true,
      "data": {
        "messaging_product": "whatsapp",
        "contacts": [{ "input": "+971501234567", "wa_id": "971501234567" }],
        "messages": [{ "id": "wamid.HBgMOTcxNTAxMjM0NTY3FQIAERgSNkVFMjJENDY4RkZGOTUwRjFGAA==" }],
        "chat": {
          "uuid": "64968a32-fdd9-4c1d-8941-b8e538036616",
          "type": "outbound",
          "media_id": null,
          "created_at": "2026-11-14 09:21:35"
        }
      }
    }
  }
}
Failed sends are included

message.sent is also sent when Meta refuses a message. Check data.data.success before treating it as sent, the same way as for API sends.

Contact events#

contact.created and contact.updated send the full contact. address and metadata (your custom fields) are JSON strings.

contact.created
{
  "event": "contact.created",
  "data": {
    "uuid": "81a2d165-41e2-43f2-847e-d69e08cba0e0",
    "first_name": "Sara",
    "last_name": "Ahmed",
    "full_name": "Sara Ahmed",
    "phone": "+971501234567",
    "formatted_phone_number": "+971 50 123 4567",
    "email": "[email protected]",
    "address": "{\"street\":null,\"city\":\"Dubai\",\"state\":null,\"zip\":null,\"country\":null}",
    "metadata": "{\"Membership\":\"Gold\"}",
    "is_subscribed": 1,
    "created_at": "2026-11-14 09:20:11",
    "updated_at": "2026-11-14 09:20:11"
  }
}

contact.deleted lists the deleted contacts. Deleting several at once sends one event:

contact.deleted
{
  "event": "contact.deleted",
  "data": {
    "list": [
      { "uuid": "81a2d165-41e2-43f2-847e-d69e08cba0e0", "deleted_at": "2026-11-14T09:30:02.000000Z" }
    ]
  }
}

Contact events cover changes made in the app and through the API. Contacts created by an Excel import, by a customer messaging you for the first time, or by sending to a new number don't send contact.created.

Group events#

group.created
{
  "event": "group.created",
  "data": {
    "uuid": "d746e4c5-db24-4fb2-be03-590421344d69",
    "name": "Weekend regulars",
    "created_at": "2026-11-14T09:20:11.000000Z",
    "updated_at": "2026-11-14T09:20:11.000000Z"
  }
}

group.updated sends the same fields after a rename. group.deleted sends a list, like contact.deleted:

group.deleted
{
  "event": "group.deleted",
  "data": {
    "list": [
      { "uuid": "d746e4c5-db24-4fb2-be03-590421344d69", "deleted_at": "2026-11-14T09:40:27.000000Z" }
    ]
  }
}

Adding contacts to a group or removing them doesn't send a group event.

Auto-reply events#

autoreply.created
{
  "event": "autoreply.created",
  "data": {
    "uuid": "de6fe115-4c30-4c8d-9245-6ae31c1c820f",
    "name": "Opening hours",
    "trigger": "hours,timing,open",
    "match_criteria": "contains",
    "metadata": "{\"type\":\"text\",\"data\":{\"text\":\"We are open every day from 7am to 10pm.\"}}",
    "created_at": "2026-11-14T09:31:18.192271Z",
    "updated_at": "2026-11-14T09:31:18.192226Z"
  }
}

autoreply.updated sends the same fields after a change. autoreply.deleted sends a list:

autoreply.deleted
{
  "event": "autoreply.deleted",
  "data": {
    "list": [
      { "uuid": "de6fe115-4c30-4c8d-9245-6ae31c1c820f", "deleted_at": "2026-11-14T09:32:26.673081Z" }
    ]
  }
}

Good to know#

  • Payloads can contain more fields than shown here. Ignore fields you don't know: new ones may be added.
  • Timestamps in contact payloads can be in your organization's time zone when the change was made in the app, and in UTC when it came through the API. Group and auto-reply times are ISO 8601 in UTC.
  • If your subscription ends, incoming messages can stop being processed, and message.received stops with them.
Still stuck?Our team answers on WhatsApp and at [email protected].
Ask us on WhatsApp