Webhooks
Receive signed event notifications for conversations, handoffs, knowledge jobs, usage and your endpoints.
Register an HTTPS endpoint and choose the event types you want. Heyllo sends a POST with a JSON body for each event. Respond with any 2xx status within 10 seconds and do slow work asynchronously.
Register an endpoint
curl https://api.heyllo.co/v1/webhook_endpoints \
-H "Authorization: Bearer $HEYLLO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://hooks.example.com/heyllo",
"events": ["handoff.requested", "message.created", "knowledge.job.completed", "knowledge.job.failed"],
"description": "Production handler"
}'The response includes the endpoint's signing secret (whsec_...). It is only returned here and when you rotate it, so store it now.
eventslists event types, or["*"]for all of them.- Set
workspaceto receive only that workspace's events. Without it, the endpoint receives events from every workspace plus organisation-level events such asusage.threshold_reached. Endpoints created with a workspace-bound key are limited to that workspace. - The URL must use
https, point to a public host, have no credentials, and use port 443 or a port from 1024 to 65535. Private, loopback and link-local addresses are refused, and DNS is re-checked on every delivery. - Endpoints belong to the environment of the key that created them. Each environment can have up to 20 endpoints.
Send a signed test event with POST /v1/webhook_endpoints/{id}/test. It delivers a ping event right away and returns ok, status_code, error and duration_ms from your endpoint's answer. ping is only sent by this call and cannot be subscribed to.
Event catalog
| Type | When | Object |
|---|---|---|
conversation.created | A conversation is created with POST /v1/conversations. | conversation |
message.created | A message is stored in a conversation run through the API: the end user's message, the assistant's reply, or a human-agent reply sent with POST /v1/conversations/{id}/human_messages. | message |
handoff.requested | The agent, the end user or your team asks for a human, on any channel. | handoff |
handoff.accepted | A human agent takes over the conversation. | handoff |
handoff.resolved | The human agent hands the conversation back to the assistant. | handoff |
lead.captured | The agent captured contact details during an API conversation. | lead |
knowledge.job.completed | A knowledge job finished successfully. | knowledge_job |
knowledge.job.failed | A knowledge job failed or timed out. | knowledge_job |
usage.threshold_reached | Your organisation crossed 50, 80 or 100 percent of a monthly limit for messages, model spend or ingested words. Sent once per threshold per month, for live usage only. | usage_threshold |
bot.updated | A bot's configuration was changed with PATCH /v1/bots/{id}. | bot |
webhook_endpoint.disabled | An endpoint was disabled automatically after failing for 5 days. Delivered to your other endpoints. | webhook_endpoint |
New event types can be added at any time. Ignore types you do not recognise.
Payload
Every event has the same envelope. data.object holds the object the event is about.
{
"id": "evt_0b7Kq2Xp9Lm4Vn8Rt1Wc6Yz3",
"object": "event",
"type": "handoff.requested",
"api_version": "2026-12-01",
"created": "2026-11-18T09:14:03.000Z",
"livemode": true,
"workspace": "ws_4hT8kQ2mZx7LpR1vN9cW3yBd",
"data": {
"object": {
"object": "handoff",
"conversation": "conv_8LpR3tY6nW1qK9xM2vB5cZ7d",
"status": "requested",
"reason": "Customer wants to change a delivered order",
"summary": "Order 10442 arrived in the wrong size. Customer asks for an exchange.",
"urgency": "normal",
"source": "agent"
}
}
}| Field | Description |
|---|---|
id | Event ID. Same value as the webhook-id header. |
type | One of the event types above. |
api_version | The API version the payload is shaped for. |
created | When the event happened (ISO 8601, UTC). |
livemode | true for live events, false for test events. |
workspace | The workspace ID, or null for organisation-level events. |
data.object | The object the event is about. |
Delivery and retries
- At least once. An event can arrive more than once. Deduplicate on the
webhook-idheader. - No ordering. Events can arrive out of order. Use
created, and fetch the current object from the API when order matters. - Failures. A delivery fails when your endpoint does not answer with
2xxwithin 10 seconds, including redirects, which are not followed. - Retries. A failed delivery is retried after roughly 5 seconds, 30 seconds, 2 minutes, 10 minutes, 30 minutes, 1 hour, 3 hours, 6 hours, 12 hours and 24 hours, each with up to 20 percent jitter. After 11 attempts in total (about 47 hours) the delivery is marked dead.
- Auto-disable. An endpoint whose deliveries keep failing for more than 5 days is disabled and stops receiving events. A
webhook_endpoint.disabledevent goes to your other endpoints.
Re-enable an endpoint with PATCH /v1/webhook_endpoints/{id} and {"status": "enabled"}. List past events and their delivery status with GET /v1/webhook_events (filter with ?type=), and send one again to every subscribed, enabled endpoint with POST /v1/webhook_events/{id}/redeliver.
Verifying signatures
Deliveries follow the Standard Webhooks specification, so its libraries work too. Each request carries three headers:
| Header | Value |
|---|---|
webhook-id | The event ID (evt_...). |
webhook-timestamp | Unix time in seconds when the attempt was sent. |
webhook-signature | One or more space-separated signatures of the form v1,<base64>. |
The signature is the base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{raw body}. The HMAC key is the base64-decoded part of your secret after whsec_. Compute it over the raw request body exactly as received, before any JSON parsing, compare in constant time, and reject timestamps more than 5 minutes from your clock.
import crypto from 'node:crypto'
// raw: the request body as a string, exactly as received
// headers: the request headers with lower-case names
export function verifyWebhook(raw, headers, secret) {
const id = headers['webhook-id']
const timestamp = headers['webhook-timestamp']
const signatures = headers['webhook-signature']
if (!id || !timestamp || !signatures) return false
const ts = Number(timestamp)
if (!Number.isInteger(ts) || Math.abs(Date.now() / 1000 - ts) > 300) return false
const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64')
const expected = crypto.createHmac('sha256', key).update(`${id}.${ts}.${raw}`).digest()
return signatures.split(' ').some((part) => {
const [version, sig] = part.split(',')
if (version !== 'v1' || !sig) return false
const got = Buffer.from(sig, 'base64')
return got.length === expected.length && crypto.timingSafeEqual(got, expected)
})
}import express from 'express'
import { verifyWebhook } from './verify-webhook.js'
const app = express()
app.post('/heyllo', express.raw({ type: 'application/json' }), (req, res) => {
const raw = req.body.toString('utf8')
if (!verifyWebhook(raw, req.headers, process.env.HEYLLO_WEBHOOK_SECRET)) {
return res.status(400).end()
}
const event = JSON.parse(raw)
// Deduplicate on event.id, queue the work, then answer quickly
console.log('received', event.type, event.id)
res.status(204).end()
})
app.listen(3000)import base64
import hashlib
import hmac
import time
def verify_webhook(raw: bytes, headers, secret: str) -> bool:
"""raw: the request body bytes exactly as received; headers: a case-insensitive mapping."""
msg_id = headers.get("webhook-id")
timestamp = headers.get("webhook-timestamp")
signatures = headers.get("webhook-signature")
if not msg_id or not timestamp or not signatures:
return False
try:
ts = int(timestamp)
except ValueError:
return False
if abs(time.time() - ts) > 300:
return False
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{ts}.".encode() + raw
expected = hmac.new(key, signed, hashlib.sha256).digest()
for part in signatures.split(" "):
version, _, sig = part.partition(",")
if version != "v1" or not sig:
continue
try:
got = base64.b64decode(sig)
except ValueError:
continue
if hmac.compare_digest(got, expected):
return True
return FalseSecret rotation
POST /v1/webhook_endpoints/{id}/rotate_secret returns a new secret and previous_secret_expires_at. For the next 24 hours every delivery is signed with both the new and the previous secret, so webhook-signature carries two signatures. Deploy the new secret within that window. The verification code above accepts a request when any signature matches.