Webhooks
Register a URL and Adeli POSTs a signed JSON event to it when someone comments on a connected Instagram or TikTok account's post, sends a direct message to a connected Instagram account, Facebook Page or WhatsApp number, or taps a postback button you sent with Send Instagram message. Together they are everything a comment-to-DM automation or a chat bot needs.
Webhooks belong to one profile, and cover its Instagram, TikTok, Facebook and
WhatsApp accounts.
Pass platform when you create one to
receive a single platform's events; without it, a webhook receives every
supported platform. A webhook created before platform existed receives every
platform. An
Instagram account connected through a Facebook Page (facebook_login) lacks
the comments permission, and a TikTok account connected without comment access
lacks it too; neither sends events until it is connected with that access.
Endpoints
/api/v1/webhooksA profile's webhooks, without their secrets.POSTCreate webhook/api/v1/webhooksRegister a URL for events and get its signing secret, once.DELETEDelete webhook/api/v1/webhooks/{webhookId}Delete a webhook.POSTSend a test event/api/v1/webhooks/{webhookId}/testSend one signed sample event now and see what your receiver answered.Events
Every event has the same envelope:
{
"id": "evt_3f1c2b9a8d7e6f5a4b3c2d1e0f9a8b7c",
"type": "comment.created",
"createdAt": "2026-10-27T21:08:59.000Z",
"profileId": "00000000-0000-4000-8000-000000000001",
"platform": "instagram",
"accountId": "00000000-0000-0000-0000-000000000000",
"data": {}
}platform is instagram, tiktok, facebook or whatsapp. An event sent by
Send a test event also has "test": true.
type | When | data |
|---|---|---|
comment.created | Someone comments on, or replies under, one of the account's posts. | commentId, mediaId, parentId (null for a top-level comment), text, from: { id, username }, and isSelf, true when the account commented itself. from.id is the commenter's Instagram-scoped id: send it a private reply with recipient: { commentId }. |
message.postback | Someone taps a postback button the account sent. Instagram only. | senderId (their Instagram-scoped id, for recipient: { id }), payload (the button's payload), title (the button's title), messageId. |
message.created | Someone sends a direct message to the account. Instagram, Facebook and WhatsApp. | messageId, conversationKey, from: { id, username }, text (null for an attachment-only message), attachments: [{ type, url }], replyTo: { messageId } or null, story (an Instagram story reply or mention) or null, and isEcho, always false. See Direct messages. |
Each platform sends only some events:
platform | Events |
|---|---|
instagram | comment.created, message.postback, message.created |
tiktok | comment.created |
facebook | message.created |
whatsapp | message.created |
Events arrive for every new comment, whether or not anyone has opened the post in Adeli.
TikTok comments
A TikTok comment.created is sent once TikTok has made the comment public.
TikTok moderates every new comment within a few seconds of it being written, and
a comment it hides is never sent. Adeli fetches each comment before sending it,
so expect events within about a minute of the comment; TikTok itself allows up to
five minutes to notify Adeli.
{
"id": "evt_9b2e4c1d0a8f7e6d5c4b3a2f1e0d9c8b",
"type": "comment.created",
"createdAt": "2026-11-02T17:29:08.000Z",
"profileId": "00000000-0000-4000-8000-000000000001",
"platform": "tiktok",
"accountId": "00000000-0000-0000-0000-000000000000",
"data": {
"commentId": "7703627334771688223",
"mediaId": "7692110307367423245",
"parentId": null,
"text": "they sound awesome!",
"from": { "id": "+ZMA647RQ04dWKwheRsYq", "username": "a.commenter", "displayName": "A Commenter" },
"isSelf": false
}
}mediaId is the TikTok video id. from.id is TikTok's id for the commenter, and
from.displayName appears only on TikTok events. username and displayName
are null in the rare case that TikTok would not return the comment to Adeli but
had already made it public. Reply with
Create comment using parentId.
Direct messages
A message.created is sent for each message someone sends to a connected
Instagram account, Facebook Page or WhatsApp number. Messages the account sends
itself, including replies you send through Adeli or from the Instagram, Facebook
or WhatsApp apps, are never sent, so a bot that answers every message.created
does not answer itself. Unsent and deleted messages, WhatsApp delivery and read
receipts, and WhatsApp reactions and orders are not sent either.
The message is stored before its event is sent, so you can read the
conversation back with
List messages and conversationKey as
soon as the event arrives. The one exception is a first Instagram or Facebook
message from someone new while Meta is rate-limiting the account: it appears
in the list shortly after.
{
"id": "evt_7c1d9e2f3a4b5c6d7e8f9a0b1c2d3e4f",
"type": "message.created",
"createdAt": "2026-11-06T15:04:05.000Z",
"profileId": "00000000-0000-4000-8000-000000000001",
"platform": "instagram",
"accountId": "00000000-0000-0000-0000-000000000000",
"data": {
"messageId": "aWdfZAG1faXRlbToxOklHTWVzc2FnZAWQ",
"conversationKey": "instagram:1784000000000001",
"from": { "id": "1784000000000001", "username": null },
"text": "Hi, is this still available?",
"attachments": [{ "type": "image", "url": "https://lookaside.fbsbx.com/…" }],
"replyTo": null,
"story": null,
"isEcho": false
}
}messageIdis the platform's own message id: the Instagram or Facebookmid, or the WhatsAppwamid.from.idis the sender: their Instagram-scoped id, Page-scoped id, or WhatsApp number as digits with no+. Reply to it with Send message.from.usernameis null.conversationKeyis<platform>:<from.id>, and together withaccountIdidentifies the conversation. Every message in a thread has the same key.attachments[].typeisimage,video,audioorfile; a shared post or anything else is afile.urlmay be null. WhatsApp sends media without a link, so a WhatsApp attachment'surlis always null, and a media caption is thetext. A WhatsApp location arrives as text such as[location] Central Park, New York, NY 40.7812,-73.9665, and a contact card as[contact] <name> <phone>.replyTo.messageIdis the message the sender replied to, when they used Reply.storyis set when an Instagram message is about one of the account's stories, and null otherwise (always null on Facebook and WhatsApp).{ "type": "reply", "id", "url" }is a reply to the account's story;{ "type": "mention", "id", "url" }is a mention of the account in someone else's story, which also arrives as afileattachment.idandurlmay be null, and the story'surlexpires. To check whether the sender follows the account, use Get Instagram user.
Instagram sends message events only for accounts connected with Instagram's
Unified Login or Instagram Login, like comments. Each message is sent once per
connected account; Meta's redeliveries keep the same event id.
Verifying signatures
Each request carries three headers:
| Header | Value |
|---|---|
Adeli-Signature | t=<unix seconds>,v1=<hex HMAC-SHA256> |
Adeli-Event-Id | The event's id |
Adeli-Event-Type | The event's type |
v1 is the HMAC-SHA256 of <t>.<raw request body>, keyed with the webhook's
signing secret, which Create webhook returns
once. Compute it over the raw body before parsing JSON, compare in constant
time, and reject a t more than five minutes from your clock, so a captured
request cannot be replayed:
import { createHmac, timingSafeEqual } from "node:crypto";
export function verify(rawBody: string, header: string | null, secret: string) {
const parts = new Map((header ?? "").split(",").map((part) => part.split("=", 2) as [string, string]));
const t = Number(parts.get("t"));
const v1 = parts.get("v1") ?? "";
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > 300 || !/^[0-9a-f]{64}$/.test(v1)) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
return timingSafeEqual(expected, Buffer.from(v1, "hex"));
}Delivery and retries
Answer with any 2xx within 10 seconds; do slow work afterwards. Any other
status, a timeout or a network error is retried after 1 minute, 5 minutes,
30 minutes, 2 hours and 6 hours, six attempts in all. Redirects are not followed.
A 410 Gone disables the webhook; create it again to resume.
Delivery is at least once, and Meta itself sometimes sends the same
comment or message twice. The same event always has the same id, so record the ids you
have handled and ignore repeats.
To rotate a secret, delete the webhook and create it again.
Setting up a webhook
A webhook is a URL on your server that accepts Adeli's POST requests. To set
one up:
- Write a receiver. An HTTPS endpoint that reads the raw request body,
verifies the signature, handles the event, and
answers
2xxwithin 10 seconds. The example below is a complete receiver. - Make it reachable. Adeli sends from its own servers, so the URL must be
public
https.http://localhostis refused with422 url_not_reachable. For a receiver on your laptop, use an HTTPS tunnel such asngrok http 4242and register the tunnel's URL. - Register it. In the dashboard, open Webhooks, click Add webhook, choose the platform, enter the URL and tick the events you want. Or call Create webhook. A webhook belongs to one profile.
- Store the signing secret. It is shown once, when the webhook is created.
Keep it in your server's environment, for example
ADELI_WEBHOOK_SECRET. To change it, delete the webhook and create it again.
Testing a webhook
You don't have to wait for a real comment. Adeli can send a signed sample event,
marked "test": true, to any webhook on demand.
1. Run a receiver
Save this as receiver.mjs. It needs Node.js 18 or later and no packages. It
verifies each request's signature, prints the event, and answers 204, or
401 when the signature is wrong:
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";
const secret = process.env.ADELI_WEBHOOK_SECRET;
if (!secret) throw new Error("Set ADELI_WEBHOOK_SECRET to the webhook's signing secret");
function verify(rawBody, header) {
const parts = new Map((header ?? "").split(",").map((part) => part.split("=", 2)));
const t = Number(parts.get("t"));
const v1 = parts.get("v1") ?? "";
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > 300 || !/^[0-9a-f]{64}$/.test(v1)) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
return timingSafeEqual(expected, Buffer.from(v1, "hex"));
}
createServer((request, response) => {
let body = "";
request.on("data", (chunk) => (body += chunk));
request.on("end", () => {
if (!verify(body, request.headers["adeli-signature"])) {
console.log("Rejected: bad signature");
return response.writeHead(401).end();
}
const event = JSON.parse(body);
console.log(`${event.test ? "Test " : ""}${event.type} from ${event.platform}:`, event.data);
response.writeHead(204).end();
});
}).listen(4242, () => console.log("Listening on http://localhost:4242"));2. Expose it
In a second terminal, give it a public HTTPS URL:
ngrok http 4242Copy the https://….ngrok-free.app URL that ngrok prints.
3. Register the URL and start the receiver
Add a webhook for the ngrok URL (Setting up a webhook), then start the receiver with the secret Adeli shows you:
ADELI_WEBHOOK_SECRET=whsec_... node receiver.mjs4. Send a test event
In the dashboard, click Send test event on the webhook's row. A webhook with more than one event or platform lets you choose which sample to send. Or call Send a test event:
curl -s -X POST https://app.tryadeli.com/api/v1/webhooks/<webhookId>/test \
-H "Authorization: Bearer $ADELI_API_KEY" \
-H "content-type: application/json" \
-d '{"type":"comment.created","platform":"tiktok"}'The receiver prints Test comment.created from tiktok: and the sample data. The
dashboard row turns green and reads Reachable with HTTP 204, and the API
answers {"delivered":true,"statusCode":204,...}.
If it fails
| You see | It means |
|---|---|
HTTP 401 | The receiver rejected the signature. Start it with this webhook's signing secret, and verify the raw body before parsing it. |
timed out or request failed | Adeli could not reach the URL in 10 seconds. Check that the receiver and the tunnel are running and the URL matches. |
Another status, such as 404 or 500 | The receiver answered with an error. Check the path and its logs. |
429 rate_limited | One test per webhook every five seconds. Wait and send again. |
The dashboard keeps the last result, so the status stays after you reload. It shows the last attempt, test or real, not continuous monitoring. Editing a webhook's URL, platform or events resets it to Not checked.