Webhooks
Webhooks tell your system when something happens, instead of polling. You need Manage webhooks.
Events
| Event | When | data |
|---|---|---|
shipment.extracted |
a document was read | shipment_id, lines |
shipment.needs_review |
read lines wait for a review | shipment_id |
shipment.failed |
reading failed | shipment_id, error |
plan.completed |
a plan was computed | shipment_id, plan_id, strategy, metrics, livemode |
plan.failed |
the computation failed | shipment_id, error |
catalog_import.ready |
an import is ready to review | import_id, stats |
catalog_import.failed |
an import failed | import_id, error |
Create an endpoint
- Developers → New webhook endpoint.
- Enter an https URL reachable from the internet (private and internal addresses are refused), tick the events, Create the endpoint.
- Copy the signing secret (
whsec_…): it is shown only once.
Or with the API: POST /v1/webhook-endpoints with url and events.
What we send
A POST with a JSON body:
{
"id": "6f3c…",
"type": "plan.completed",
"created_at": "2026-11-28T09:12:44.120Z",
"data": { "shipment_id": "…", "plan_id": "…", "strategy": "balanced", "metrics": { "finalCount": 1 } }
}
and the headers:
webhook-id: the delivery id (use it to ignore duplicates);webhook-signature:t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with your secret>.
Answer with any 2xx within 10 seconds. Otherwise the delivery is retried, up to 6 attempts with growing delays. Deliveries and their status are listed on the Developers page. Pause an endpoint to stop deliveries without deleting it.
Verify the signature
Always verify before trusting the body: recompute the signature on the raw body, compare in constant time, and reject timestamps older than 5 minutes.
Node.js
import { createHmac, timingSafeEqual } from "node:crypto";
export function verify(secret, rawBody, header, toleranceSeconds = 300) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
const given = Buffer.from(parts.v1 ?? "", "hex");
return given.length === expected.length && timingSafeEqual(given, expected);
}
Python
import hmac, hashlib, time
def verify(secret: str, raw_body: bytes, header: str, tolerance: int = 300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
t = int(parts.get("t", "0"))
if abs(time.time() - t) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))
Good practices
- Answer quickly (2xx) and do the work afterwards.
- Make your handler idempotent: the same
webhook-idmay arrive twice. - Read the full result with
GET /v1/shipments/{id}when you need the placements.