Skip to content

Receive webhooks

Register a URL that wakes your agent when work is waiting, verify each delivery's signature, and handle retries and pausing.

Updated

A webhook wakes your agent when the record needs it. Handline posts to your URL; what runs behind it, such as starting an agent session, is up to you. The agent then reads the work queue through MCP.

Register a URL#

An owner or admin does this on Webhooks in the product's settings. Agents can list webhooks (webhooks_list) but can't add or change them.

  1. Add the URL. It must be HTTPS and must not point into a private network; Handline checks again before every delivery. A product can have up to 10 URLs.
  2. Choose the kinds of work item it receives, or leave all of them.
  3. Copy the signing secret. It is shown once. Keep it with your receiver, such as in HANDLINE_WEBHOOK_SECRET.
  4. Send a test delivery and check the receiver's answer in the delivery log.

What a delivery holds#

Pointers only: which product has new work items, how many, of which kinds, and their ids. A delivery never holds an instruction or any text from outside.

JSON
{  "type": "work_items",  "deliveryId": "dlv_01J…",  "workspaceId": "ws_01J…",  "productId": "prd_01J…",  "sentAt": "2026-11-22T09:14:03.000Z",  "items": [{ "id": "wi_3f…", "kind": "stop_rule", "urgency": "normal" }],  "counts": { "stop_rule": 1 },  "openItems": 4,  "next": "Read the work queue with the workItems.list tool, or call briefing.get at the start of a session."}

type is work_items, heartbeat (once a day, even when nothing is new) or test (a test delivery from Webhooks).

Batching#

Work items are gathered over a window, so a burst starts one session. Urgent kinds use a shorter window. The defaults are 120 seconds and 15 seconds; an owner or admin can set each from 10 seconds to an hour on Webhooks.

Verify a delivery#

Every delivery carries a Handline-Signature header: t=<unix seconds>,v1=<hex HMAC-SHA256>. The HMAC is computed with your URL's secret over t, a full stop, and the raw body. Reject a delivery whose signature doesn't match, or whose t is more than 5 minutes from your clock.

With the helper package:

app/webhooks/handline/route.tsTypeScript
import { verifyWebhook } from '@handline/handoff'; export async function POST(req: Request) {  const body = await req.text();  const ok = await verifyWebhook(body, req.headers.get('handline-signature'), process.env.HANDLINE_WEBHOOK_SECRET!);  if (!ok) return new Response('bad signature', { status: 401 });  const delivery = JSON.parse(body);  // Start an agent session for delivery.productId.  return new Response('ok');}

Without it, in Node:

verify.tsTypeScript
import { createHmac, timingSafeEqual } from 'node:crypto'; export function verify(body: string, header: string, secret: string): boolean {  const { t, v1 } = Object.fromEntries(header.split(',').map((kv) => kv.split('=')));  if (!t || !v1 || Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;  const expected = createHmac('sha256', secret).update(`${t}.${body}`).digest('hex');  return expected.length === v1.length && timingSafeEqual(Buffer.from(expected), Buffer.from(v1));}

Answer within 10 seconds with any 2xx status. Start the agent's work after you answer.

Retries and pausing#

A delivery that gets no 2xx answer is retried with backoff, up to 6 attempts. The delivery log on Webhooks, and webhooks_deliveries, show each attempt with your receiver's response code. A URL that fails 10 times in a row is paused, and the workspace's admins are alerted. Work items stay in the queue; resume the URL on Webhooks once it works.

Kinds of work item#

KindWhat it asks forUrgency
recipient_convertedStop a recipient's sequence: they convertedurgent
pause_in_toolPause a placement in its toolurgent
retired_in_usePull a live use of something retiredurgent
fact_changedUpdate copy that quotes a changed factnormal
stop_ruleA stop rule firednormal
fatigueA placement is tiringnormal
pacingBudget pacing is offnormal
email_healthBounce or complaint rate too highurgent
driftThe record differs from what is livenormal
conversions_rejectedConversions are being rejectedurgent
conversion_deadlineA conversion is about to pass its deadlineurgent
credential_failingA platform connection stopped workingurgent
read_failingAn ad account can't be readurgent
reads_quotaReads are near the platform's daily limitnormal
numbers_staleReported numbers are stalenormal
numbers_flaggedReported numbers look wrongnormal
traced_shareThe traced share fellurgent
reconciliationPlatform counts and Handline's disagreenormal
experiment_lookAn experiment reached a planned looknormal
experiment_checkAn experiment failed a checkurgent
experiment_flagAn experiment raised a flagnormal
experiment_endedAn experiment endednormal
learning_contradictedRe-test a contradicted learninglow
change_set_decidedA change set was approved or declinednormal
webhook_pausedA webhook was pausedurgent
lead_lostA lead couldn't be delivered and was deletedurgent
domain_failingA page domain is failingurgent

How an agent works each one: work the queue.

Was this page helpful?