Guides
WhatsApp webhook events and payloads: every event type, with a receiver
HelloHop sends four kinds of WhatsApp webhook event: message, message.status, group.participants and session.status. Calling the test route adds webhook.test. Every delivery is a signed POST with the same envelope, so one route can verify the signature, skip an event id it already handled and pick a handler by type.
Facts (as of October 2026, API v1)
- The envelope of every delivery is id, type, session, timestamp and payload. X-HelloHop-Event and X-HelloHop-Delivery repeat the type and the id but are not signed.
- A new receiver with no events list gets message, group.participants and session.status. message.status is not in that set: list it.
- The test route sends one signed webhook.test event to a URL you already set and sends nothing to WhatsApp.
- Your endpoint has 10 seconds by default to answer any 2xx. A timeout, a network error, a 5xx, 408, 425 or 429 is retried with a growing wait for about a day and a half. Any other 4xx is a refusal and stops after three tries over about five minutes, and the webhook.test event gets one attempt.
- Changes within /v1 are additive: new event types and new optional fields can appear, so ignore what you do not know.
Steps
- Subscribe. PUT your HTTPS URL, the events you handle and a secret of at least 24 characters to
/v1/sessions/{channel}/webhooks. List message.status if you want receipts. - Verify. Check X-HelloHop-Signature against the raw body before you parse anything, and answer 401 on a mismatch.
- Route by type. Read type from the body, skip an id you already handled, and call the handler for that type. Answer 200 for a type you do not know.
- Test. POST to the webhooks/test route with your URL and watch a signed webhook.test arrive.
The event types
| type | Fires when | Default | What a handler usually does |
|---|---|---|---|
| message | A message arrives, or your own number sends from the paired phone | Yes | Store it. Skip from_me if you only want what customers send. |
| message.status | WhatsApp reports delivered, read, played or undecryptable for a message you sent | No, list it | Match payload.ids to the id your send returned. Only move a status forward. |
| group.participants | Someone joins, leaves, is promoted or is demoted in a group | Yes | Update your member list from action and participants. |
| session.status | The channel connection state changes | Yes | Alert yourself when state is not CONNECTED. |
| webhook.test | You call the test route | Sent to the URL you name | Answer 200 and do nothing. |
This page covers what a receiver needs in one place. The full field list of every payload, including polls, reactions and deleted messages, is in the webhook events reference, and the delivery and retry rules are in the webhooks reference.
Subscribe to the events you handle
The events list is how you choose. A receiver gets only the types it lists. A name that is not an event type is accepted and matches nothing, so check the spelling. PUT replaces the whole receiver list for the channel, so include every receiver you keep. Save the script as subscribe.mjs and run it with Node.js 22 or later, with CHANNEL_ID, CHANNEL_TOKEN, WEBHOOK_SECRET and WEBHOOK_URL set. Start the receiver below first, because the test event goes to that URL. WEBHOOK_URL must be a public address: a localhost or private address is refused.
const API = 'https://api.hellohop.app/v1';
const { CHANNEL_ID, CHANNEL_TOKEN, WEBHOOK_SECRET, WEBHOOK_URL } = process.env;
const headers = { Authorization: `Bearer ${CHANNEL_TOKEN}`, 'Content-Type': 'application/json' };
const base = `${API}/sessions/${CHANNEL_ID}/webhooks`;
// PUT replaces the whole receiver list: include every receiver you keep.
const put = await fetch(base, {
method: 'PUT',
headers,
body: JSON.stringify({
receivers: [
{
url: WEBHOOK_URL,
events: ['message', 'message.status', 'group.participants', 'session.status'],
secret: WEBHOOK_SECRET, // 24 or more characters
},
],
}),
});
if (!put.ok) throw new Error(`PUT webhooks answered ${put.status}`);
console.log(await put.json());
// One signed webhook.test delivery to that URL. Nothing is sent to WhatsApp.
const test = await fetch(`${base}/test`, { method: 'POST', headers, body: JSON.stringify({ url: WEBHOOK_URL }) });
console.log('test', test.status, await test.json());One envelope, one route
Every delivery has the same envelope: id, type, session, timestamp and payload. The payload depends on the type. X-HelloHop-Event carries the type and X-HelloHop-Delivery carries the id, but only the body is signed, so read both from the body after you verify X-HelloHop-Signature. A retry keeps the same body id, so that id is what you skip repeats on.
A receiver that handles every event type
Save it as receiver.mjs, run npm install express in the same folder, and start it with WEBHOOK_SECRET set to the secret you gave the receiver. The sample needs Express and Node.js 22.13 or later for the built-in node:sqlite module, which Node 22 still marks as experimental. The inbox is the file inbox.db in the working directory unless you set INBOX_DB. The route refuses an unsigned or forged request with 401. It writes each verified event to a SQLite inbox keyed on the body id before it answers 200, and answers 500 when that write fails, so an ordinary event is delivered again (the webhook.test event gets one attempt). A repeated id inserts nothing and gets a plain 200. Handlers run from the inbox after the 200. A type the receiver does not know is logged and marked handled, because new types can be added. A handler that throws leaves its row unhandled, and the receiver tries it again every 60 seconds. A body that is signed but not valid JSON gets a 200, since a retry cannot fix it. Keep handlers quick and safe to run twice.
import express from 'express';
import { createHmac, timingSafeEqual } from 'node:crypto';
import { DatabaseSync } from 'node:sqlite';
const { WEBHOOK_SECRET: SECRET, INBOX_DB = 'inbox.db' } = process.env;
if (!SECRET || SECRET.length < 24) throw new Error('Set WEBHOOK_SECRET to the receiver secret (24 characters or more)');
// The inbox: one row per event id, written to disk before the 200.
const db = new DatabaseSync(INBOX_DB);
db.exec('CREATE TABLE IF NOT EXISTS inbox (id TEXT PRIMARY KEY, type TEXT NOT NULL, body TEXT NOT NULL, handled INTEGER NOT NULL DEFAULT 0)');
const saveEvent = db.prepare('INSERT INTO inbox (id, type, body) VALUES (?, ?, ?) ON CONFLICT (id) DO NOTHING');
const pending = db.prepare('SELECT id, type, body FROM inbox WHERE handled = 0 ORDER BY rowid LIMIT 100');
const markHandled = db.prepare('UPDATE inbox SET handled = 1 WHERE id = ?');
function validSignature(raw, header) {
if (!Buffer.isBuffer(raw) || !header) return false; // a parsed object means a JSON parser ran first
const want = Buffer.from(createHmac('sha256', SECRET).update(raw).digest('hex'));
const got = Buffer.from(header);
return got.length === want.length && timingSafeEqual(got, want);
}
// One handler per event type. Each gets event.payload and is safe to run twice.
const handlers = {
message: (p) => {
if (p.from_me) return; // your own number sent it, for example from the phone
console.log('message', p.type, p.chat_jid, p.text ?? '');
},
'message.status': (p) => {
for (const id of p.ids ?? []) console.log('receipt', id, p.status);
},
'group.participants': (p) => console.log('group', p.group_jid, p.action, p.participants),
'session.status': (p) => {
if (p.state !== 'CONNECTED') console.error('channel is not connected:', p.state, p.reason ?? '');
},
'webhook.test': () => {}, // from POST /webhooks/test: nothing to do
};
// Runs the handlers for saved events after the 200. Every 60 seconds it retries any event whose handler failed.
function drain() {
try {
for (const row of pending.all()) {
try {
const handle = Object.hasOwn(handlers, row.type) ? handlers[row.type] : null;
if (handle) handle(JSON.parse(row.body).payload ?? {});
else console.log('unknown event type', row.type); // new types can appear: log it and move on
markHandled.run(row.id);
} catch (err) {
console.error('handler failed, will retry', row.id, err.message);
}
}
} catch (err) {
console.error('could not read the inbox', err.message);
}
}
setInterval(drain, 60_000);
const app = express();
app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
if (!validSignature(req.body, req.get('X-HelloHop-Signature'))) return res.sendStatus(401);
let event;
try {
event = JSON.parse(req.body.toString('utf8'));
} catch {
return res.sendStatus(200); // signed but not JSON: a retry cannot fix it
}
if (typeof event?.id !== 'string' || typeof event.type !== 'string') return res.sendStatus(200);
try {
saveEvent.run(event.id, event.type, req.body.toString('utf8')); // a known id inserts nothing, so a retry is a no-op
} catch (err) {
console.error('could not save', event.id, err.message);
return res.sendStatus(500); // not saved: a 5xx so the event is retried
}
res.sendStatus(200);
setImmediate(drain);
});
app.listen(3000);Fields to read in each payload
| type | Fields you will use | Notes |
|---|---|---|
| message | id, chat_jid, sender_jid, type, text, from_me, is_group, timestamp | Optional fields are absent, not empty. A message that cannot be described arrives with type unknown. For polls, reactions and deletes see the events reference. |
| message.status | ids, chat_jid, recipient_jid, status, timestamp | One receipt often covers several sends. status is delivered, read, played or undecryptable. Receipts from your own other devices are not sent. |
| group.participants | group_jid, action, participants, actor_jid | action is join, leave, promote or demote, not the add and remove you send to the participants route. |
| session.status | state, jid, reason | state is NEW, PAIRING, CONNECTED, DISCONNECTED or BLOCKED. jid and reason appear when known. |
| webhook.test | note | The id starts with test-evt_. Nothing was sent and nothing changed. |
A person can arrive as a LID instead of a phone number. The payload then keeps the phone JID whenever it is known and adds the LID in a separate field, with a flag when no phone number is known. The LID guide explains how to read those fields.
Status codes your receiver should answer
- 2xx: accepted. Answer 200 for a duplicate and for a type you do not handle.
- 401: the signature did not match. A 4xx such as 401 is a refusal: HelloHop tries three times over about five minutes, then marks the delivery failed, so fix the secret quickly. An event that runs out of attempts is kept aside as failed.
- 5xx or no answer in time: not accepted. The event is retried for about a day and a half and the same body id comes back. The webhook.test event gets one attempt.
- While one delivery to your URL is pending or retrying, later events for that receiver URL and channel wait behind it. Deliveries can still repeat or arrive out of order, so make every handler safe to run twice.
Questions
- How many webhook event types does HelloHop send?
- Four: message, message.status, group.participants and session.status. The test route adds one more, webhook.test. New types can be added within /v1, so answer 200 for any type you do not know.
- Why am I not getting delivery or read receipts?
- A receiver with no events list gets message, group.participants and session.status only. List message.status in the events array of the receiver and PUT it again.
- Which id should I skip repeats on?
- The id inside the signed body. X-HelloHop-Delivery repeats it but is not signed, so verify the signature first and then use the body id.
- What should my endpoint answer for an event it does not handle?
- Answer 200. A non-2xx answer counts as a failed delivery, and while that event is retried, later events for that receiver URL and channel wait behind it.
- How do I test a receiver without sending a WhatsApp message?
- Call the webhooks/test route with a URL you already set. It delivers one signed webhook.test event to that URL and never reaches WhatsApp.
Free sandbox, forever. Upgrade when you're ready.
Start freeKeep going
HelloHop is an independent WhatsApp API for developers: send and receive messages, automate groups and communities, and get signed webhooks. Not affiliated with WhatsApp or Meta. You link your own number.