# Tasks webhooks

Look up how to register a Tasks webhook, verify each delivery and handle retries.

Tasks sends signed HTTPS POST requests to the URL you register for a root
order. Verify the raw request body before parsing it and use the delivery ID
to prevent duplicate processing.

## Register a webhook URL

The Tasks HTTP API mounts on the market, network and full launch surfaces.
As the poster of a root order, send `POST /v1/work-orders/:id/webhook` with
`{"url":"https://receiver.example/tasks"}`, using your own public HTTPS URL
without embedded credentials. All resolved addresses must be public.
Use an OAuth access token with `tasks:write`, or a browser session with a
same-origin Origin header. An own-wallet account may require wallet proof. The
acting wallet must match the poster. For a child order, register on its parent.

Save the returned `secret` with the `webhookUrl`. Each registration with a URL
rotates the secret, even when the URL is unchanged. Read the current URL,
`hasWebhookSecret` and up to 50 recent delivery log entries with
`GET /v1/work-orders/:id/webhooks` using the poster's session or an OAuth access
token with `tasks:read` or `tasks:write`. The log is best-effort and the GET
response omits the secret.
Send `{"url":null}` to disable delivery.

If a URL was previously unset, registering it queues `task.posted` when the
order has a sequence-1 creation event. Other past events are not backfilled.
A pending delivery is sent to the URL and signed with the secret that are
stored when the sender processes it. The sender reads the URL before the
secret, so a delivery in progress while you change the registration can arrive
at the earlier URL signed with the new secret. A retry reads the URL again.

## Read the delivery headers and body

| Header             | Value                                         |
| ------------------ | --------------------------------------------- |
| `Content-Type`     | `application/json`                            |
| `User-Agent`       | `vAPI-Webhooks/1`                             |
| `X-Vapi-Event`     | Event type, such as `task.released`           |
| `X-Vapi-Delivery`  | Delivery ID, stable across retries            |
| `X-Vapi-Signature` | `sha256=` followed by 64 lowercase hex digits |

The JSON body contains `id`, `type`, `orderId`, `sequence`, `at` and `data`.
`id` matches `X-Vapi-Delivery` and `type` matches `X-Vapi-Event`. The
`orderId` identifies the root order. A related child order is identified by
`childOrderId` when present. The `sequence` belongs to the source order.
`at` is the event's ISO timestamp.

For order events, `data` contains `sequence`, the source event's `type`,
`at`, `actor` and a sanitized `payload`. Public `task.question` and
`task.answer` events carry `{questionId, body}` in `data.payload`.
`task.reply` carries `{replyId, questionId, parentId, body}`. For
`task.message`, `sequence` is null and `data` contains only
`{threadId, messageSeq, senderRole}`. Route each delivery by its `type`.

- Order events include `task.posted`, `task.proposal`, `task.submission`,
  `task.claimed`, `task.judging`, `task.awarded`, `task.funded`,
  `task.delivered`, `task.released`, `task.refunded`, `task.disputed`,
  `task.resolved`, `task.checkin`, `task.stalled` and `task.milestone`.
- Communication events include `task.question`, `task.answer`, `task.reply`
  and `task.message`. The sender omits message bodies and attachments.
- Pool events include `pool.claim` and `pool.claim.checked`.

When poster pings are enabled, `task.claimed` carries
`{taskId, submissionCount}` in `data.payload`. For `task.judging`, the
payload also contains `choiceDeadline`.

## Verify the signature

Capture the request body bytes before parsing JSON. Compute HMAC-SHA256 over
those bytes alone, using the returned secret string as the UTF-8 key. Decode
the signature's hex digest for comparison and keep the secret as the literal
string. Compare the digests in constant time before parsing the body. The
signature covers the body only. The event's `at` field has no role as a
send-time timestamp.

In Node.js, pass the raw body buffer, the `X-Vapi-Signature` header and your
stored secret to `parseWebhook`. The sample signs one local fixture so you can
run it without a registered order.

```javascript
import { createHmac, timingSafeEqual } from "node:crypto";

function parseWebhook(rawBody, signature, secret) {
  const hex = signature?.match(/^sha256=([0-9a-f]{64})$/)?.[1];
  if (!hex) throw new Error("Invalid webhook signature");

  const expected = createHmac("sha256", secret).update(rawBody).digest();
  if (!timingSafeEqual(expected, Buffer.from(hex, "hex"))) {
    throw new Error("Invalid webhook signature");
  }
  return JSON.parse(rawBody.toString("utf8"));
}

const secret = "ab".repeat(32);
const rawBody = Buffer.from(
  '{"id":"delivery-1","type":"task.message","orderId":"order-1","sequence":null,"at":"2026-10-08T12:00:00.000Z","data":{"threadId":"thread-1","messageSeq":2,"senderRole":"provider"}}',
  "utf8"
);
const signature = `sha256=${createHmac("sha256", secret).update(rawBody).digest("hex")}`;
console.log(parseWebhook(rawBody, signature, secret).id);
```

The example prints `delivery-1`.

## Acknowledge deliveries and handle retries

Delivery is at least once. After signature verification, check that
`X-Vapi-Delivery` matches the signed body's `id`. Record that ID atomically
with your receiver's effects, skip effects for IDs you have already processed,
and return a 2xx once the delivery is durably accepted. A persisted delivery
with the same ID can be sent again when the sender fails to record the outcome.

The sender accepts any 2xx. Other HTTP responses, DNS and network failures, and
timeouts are retryable. The sender follows no redirects and allows five
seconds per request. The first four recorded failures make a delivery eligible
for retry after 1, 5, 25 and 125 seconds, respectively. A retry waits for an
eligible delivery run. The regular job runs once a minute, so the scheduled
delays are minimums. The fifth recorded retryable failure dead-letters the
delivery.

An unsafe URL, missing secret, invalid payload or missing source event
dead-letters the delivery immediately. A disabled URL marks pending deliveries
as removed when processed, and so does a registration whose stored
configuration is missing or unreadable as data. If the configuration store
itself fails, or the sender cannot sign the body, the sender defers the
delivery for 60 seconds without counting a failed send.
