Webhooks
Events sent to your URL as they happen: signed, retried for 24 hours, and logged.
Making a webhook
A webhook belongs to a collector, a store or the admins, like an API key, and gets only that owner’s events:
- Personal: Settings → Webhooks, or Make a webhook. Your collection, wishlist matches, your holds and questions, your exports.
- Store: the store’s Webhooks tab (its owners and admins), or Make a store webhook. The store’s holds, questions and listing sales. It works as the manager who made it, and turns off if they leave the store or become staff.
- Admin: Admin → Webhooks, or Make an admin webhook. The moderation queues and editorial catalog changes, while its maker is on staff.
Give it a URL and the events to send. The answer shows its signing secret (whsec_…) once: store it with your receiver. Lost it? Rotate the secret. With graceHours: 24 deliveries are signed with the old secret too for a day, so you can switch over without dropping any.
Through the API, managing webhooks takes a key with webhooks:write (store:webhooks:write, admin:webhooks:write), and subscribing to an event also takes the scope that reads it: a key without collection:read can’t have collection changes sent anywhere. See Scopes and the Webhooks reference.
Events
18 event types. Webhook events lists them too, and the OpenAPI document has each body under webhooks (WebhookEvent is all of them).
| Event | Sent when | Webhooks and key scope |
|---|---|---|
collection.item.created | A copy was added to the collection (one at a time, in bulk, by an import, or a wish was bought). | Personal: collection:read |
collection.item.updated | A copy changed: its grade, notes, place, price paid, sale... (not the value estimates the nightly job refreshes). | Personal: collection:read |
collection.item.deleted | A copy was removed from the collection. | Personal: collection:read |
wishlist.match | A store listed a book on the wishlist, at or under its target price and grade. | Personal: wishlist:read |
hold.requested | A collector asked a store to hold a book. | Personal: holds:readStore: store:holds:read |
hold.accepted | The store accepted a hold: the copies are set aside until it expires. | Personal: holds:readStore: store:holds:read |
hold.declined | The store declined a hold request. | Personal: holds:readStore: store:holds:read |
hold.expired | A request nobody answered in 48 hours, or an accepted hold nobody collected, lapsed. | Personal: holds:readStore: store:holds:read |
hold.cancelled | The collector withdrew a hold, or the store released it (status no_sale when the store cancels an accepted hold). | Personal: holds:readStore: store:holds:read |
hold.completed | The store recorded the sale. | Personal: holds:readStore: store:holds:read |
question.asked | A collector asked a store about a listing, or followed up in the thread. | Personal: questions:readStore: store:questions:read |
question.answered | The store replied in a question’s thread. | Personal: questions:readStore: store:questions:read |
listing.sold | A sale was recorded against a listing (a completed hold). | Store: store:inventory:read |
listing.out_of_stock | A listing’s last copy went: sold, held or counted out, it’s now sold out. | Store: store:inventory:read |
moderation.item.created | Something joined a moderation queue: a correction, variant, cover, barcode or abuse report. | Admin: admin:moderation:write |
moderation.item.resolved | A moderation item was approved, rejected, dismissed or actioned, or its submitter withdrew it. | Admin: admin:moderation:write |
catalog.record.changed | An editorial change to a catalog record: an edit, verification, merge, move, slug change or lock. Provider refreshes aren’t sent: sync those with filter[updatedSince]. | Admin: admin:catalog:read |
export.ready | A full data export finished: download its parts with GET /me/exports/{id}. | Personal: exports:read |
Every event, as delivered:
The body each delivery POSTs
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "collection.item.created",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": false,
"owner": {
"kind": "personal",
"id": "0e6b1c52-8f43-4b8e-9d0c-5a7e2f1b3c4d"
},
"data": {
"item": {
"id": "2a3b4c5d-6e7f-4809-9a1b-2c3d4e5f6a7b",
"issueId": "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d",
"editionId": "3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a",
"status": "owned"
}
}
}The body each delivery POSTs
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "hold.requested",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": false,
"owner": {
"kind": "personal",
"id": "0e6b1c52-8f43-4b8e-9d0c-5a7e2f1b3c4d"
},
"data": {
"hold": {
"id": "7f6e5d4c-3b2a-4190-8f7e-6d5c4b3a2918",
"status": "requested",
"listingId": "5d3a2b1c-7e8f-4a9b-8c0d-1e2f3a4b5c6d",
"storeId": "0b4f3b1e-6c1a-4f5e-9f0e-1f2a3b4c5d6e",
"issueId": "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d",
"quantity": 1,
"listedPrice": {
"amountCents": 4500,
"currency": "USD"
},
"finalPrice": null,
"expiresAt": "2026-10-14T15:04:05.123Z",
"createdAt": "2026-10-12T15:04:05.123Z",
"closedAt": null
}
}
}The body each delivery POSTs
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "question.asked",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": false,
"owner": {
"kind": "personal",
"id": "0e6b1c52-8f43-4b8e-9d0c-5a7e2f1b3c4d"
},
"data": {
"question": {
"id": "6c7d8e9f-0a1b-4c2d-9e3f-4a5b6c7d8e9f",
"status": "open",
"listingId": "5d3a2b1c-7e8f-4a9b-8c0d-1e2f3a4b5c6d",
"storeId": "0b4f3b1e-6c1a-4f5e-9f0e-1f2a3b4c5d6e"
},
"message": {
"id": "8e9f0a1b-2c3d-4e4f-8a5b-6c7d8e9f0a1b",
"fromStore": false,
"createdAt": "2026-10-12T15:04:05.123Z"
}
}
}The body each delivery POSTs
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "listing.sold",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": false,
"owner": {
"kind": "store",
"id": "0b4f3b1e-6c1a-4f5e-9f0e-1f2a3b4c5d6e"
},
"data": {
"listing": {
"id": "5d3a2b1c-7e8f-4a9b-8c0d-1e2f3a4b5c6d",
"storeId": "0b4f3b1e-6c1a-4f5e-9f0e-1f2a3b4c5d6e",
"issueId": "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d",
"editionId": "3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a",
"quantity": 1,
"status": "active",
"price": {
"amountCents": 4500,
"currency": "USD"
}
},
"sale": {
"holdId": "7f6e5d4c-3b2a-4190-8f7e-6d5c4b3a2918",
"quantity": 1,
"price": {
"amountCents": 4000,
"currency": "USD"
}
}
}
}The body each delivery POSTs
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "moderation.item.created",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": false,
"owner": {
"kind": "admin",
"id": null
},
"data": {
"item": {
"id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"queue": "cover_contribution",
"status": "pending",
"createdAt": "2026-10-12T15:04:05.123Z",
"resolvedAt": null,
"resolvedBy": null
}
}
}The body each delivery POSTs
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "catalog.record.changed",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": false,
"owner": {
"kind": "admin",
"id": null
},
"data": {
"record": {
"entity": "issue",
"id": "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d"
},
"change": {
"action": "edit",
"fields": [
"cover_date",
"cover_price_cents"
],
"actorId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e"
}
}
}The body each delivery POSTs
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "export.ready",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": false,
"owner": {
"kind": "personal",
"id": "0e6b1c52-8f43-4b8e-9d0c-5a7e2f1b3c4d"
},
"data": {
"export": {
"id": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f",
"status": "ready",
"fileCount": 412,
"totalBytes": 183402113,
"readyAt": "2026-10-12T15:04:05.123Z",
"expiresAt": "2026-10-19T15:04:05.123Z"
}
}
}Hold and question events go to both sides: the collector’s personal webhooks and the store’s. A store cancelling an accepted hold is hold.cancelled with status no_sale.
What a delivery holds
Every delivery POSTs one event as JSON:
id: the event’s id, the same on every retry and resend. Skip an id you’ve already handled: delivery is at least once.type, andversion, the version of that type’sdata(all 1 today). Fields may be added to a version; renaming or removing one makes a new version.createdAt: when it happened.test: true only for test events.owner: whose webhook it was sent for ({ "kind": "store", "id": "<storeId>" }; the collector’s id for personal events, null for admin ones).data: the records it’s about. Events are thin on purpose: ids, statuses and amounts, never what people wrote or who they are. Fetch the record with the API for the rest.
With these headers:
Collector-Signature: the signature (below).Collector-Event-IdandCollector-Event-Type: as in the body, to route before parsing.Collector-Delivery-Id: this delivery (a resend is a new delivery of the same event), andCollector-Delivery-Attempt: 1, then 2, 3...User-Agent: TheCollector-Webhooks/1.0 (+https://collection.id/developers/guides/webhooks). No cookies or credentials, ever.
POST /collector/webhooks HTTP/1.1
Host: pos.example.com
Content-Type: application/json; charset=utf-8
User-Agent: TheCollector-Webhooks/1.0 (+https://collection.id/developers/guides/webhooks)
Collector-Signature: t=1791817445,v1=b96c762041a982ac8d9170aca33328c765d8d0eb1ff431121aef70fd1770a631
Collector-Event-Id: d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6
Collector-Event-Type: hold.requested
Collector-Delivery-Id: 2d0f9c8b-7e6a-4f5d-8c3b-2a1f0e9d8c7b
Collector-Delivery-Attempt: 1
{"id":"d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6","type":"hold.requested","version":1,"createdAt":"2026-10-12T15:04:05.123Z","test":false,"owner":{"kind":"store","id":"0b4f3b1e-6c1a-4f5e-9f0e-1f2a3b4c5d6e"},"data":{"hold":{"id":"7f6e5d4c-3b2a-4190-8f7e-6d5c4b3a2918","status":"requested","listingId":"5d3a2b1c-7e8f-4a9b-8c0d-1e2f3a4b5c6d","storeId":"0b4f3b1e-6c1a-4f5e-9f0e-1f2a3b4c5d6e","issueId":"9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d","quantity":1,"listedPrice":{"amountCents":4500,"currency":"USD"},"finalPrice":null,"expiresAt":"2026-10-14T15:04:05.123Z","createdAt":"2026-10-12T15:04:05.123Z","closedAt":null}}}Verifying signatures
Check every delivery before you trust it: anyone can POST to your URL. The header is t=<unix seconds>,v1=<signature>, where the signature is the hex HMAC-SHA256 of <t>.<raw body> keyed with your whole secret (whsec_ included, as UTF-8). To verify:
- Use the raw body, exactly as received. Parsing and re-serializing it changes the bytes and the signature won’t match.
- Refuse a
tmore than 5 minutes from your clock: a captured delivery can’t be replayed later. - Compute the signature and compare it in constant time with each
v1. While a rotated secret is still honoured the header has two; either may match. - Then parse the body, and skip an event id you’ve already handled.
The SDK’s verifyWebhook() does all of it (Web Crypto: Node 20+, Workers, Deno, Bun) and returns the typed event; it throws WebhookVerificationError with a code otherwise:
import { verifyWebhook, WebhookVerificationError, type WebhookEvent } from '@collector/sdk';
const secret = process.env.COLLECTOR_WEBHOOK_SECRET ?? '';
// Event ids you've handled. Keep them in your database: delivery is at least once.
const handled = new Set<string>();
// A fetch-style handler: a Next.js route, a Cloudflare Worker, Bun or Deno.
export async function POST(request: Request): Promise<Response> {
// The raw body, exactly as sent: it's what the signature covers.
const payload = await request.text();
let event: WebhookEvent;
try {
event = await verifyWebhook({ payload, signature: request.headers.get('Collector-Signature'), secret });
} catch (error) {
if (error instanceof WebhookVerificationError) return new Response(error.code, { status: 400 });
throw error;
}
if (handled.has(event.id)) return new Response(null, { status: 204 });
handled.add(event.id);
switch (event.type) {
case 'hold.requested':
console.log(`Hold ${event.data.hold.id} asked for listing ${event.data.hold.listingId}`);
break;
case 'listing.sold': {
const { price, quantity } = event.data.sale;
console.log(`Sold ${quantity} for ${price.amountCents / 100} ${price.currency}`);
break;
}
case 'webhook.test':
console.log(event.data.message);
break;
default:
// New event types can be added: ignore the ones you don't handle.
break;
}
// Answer within 10 seconds; queue slow work instead of doing it here.
return new Response(null, { status: 204 });
}Without the SDK, in Node:
import { createHmac, timingSafeEqual } from 'node:crypto';
/** Whether a delivery's Collector-Signature matches its raw body. */
export function verifyCollectorSignature(
rawBody: string,
header: string,
secret: string,
toleranceSeconds = 300,
): boolean {
const pairs = header.split(',').map((part) => part.trim().split('=') as [string, string]);
const t = Number(pairs.find(([key]) => key === 't')?.[1]);
// Refuse old (replayed) and far-future deliveries.
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`, 'utf8').digest();
// While a secret rotates there are two v1 values: either may match.
return pairs
.filter(([key]) => key === 'v1')
.some(([, hex]) => {
const given = Buffer.from(hex, 'hex');
return given.length === expected.length && timingSafeEqual(given, expected);
});
}Check your code against the example
The delivery above is signed with whsec_ExampleOnlyNeverUseThisSecretForReal0000000. Its timestamp is long past, so turn the clock check off (the SDK’s toleranceSeconds: 0) and it should pass; change one byte of the body and it shouldn’t.
Answering a delivery
- Answer any 2xx within 10 seconds. Do slow work after answering, or queue it: a slower answer is a failed attempt, and the event comes again.
- Anything else is a failure: another status, a timeout, a refused connection, a TLS error. Answer
400to a delivery that fails verification. - Redirects aren’t followed: a 3xx is a failure. Point the webhook at the final URL.
- Only the first 64 KB of your answer is read, and its first 1 KB kept in the log. Its body is otherwise ignored.
- Events can arrive more than once, and out of order: use
createdAt, and fetch the record when the order matters.
Retries and turning off
- A failed delivery is tried again after about 30 seconds, then 1, 2, 4, 8... minutes, at most 2 hours apart, each wait a random point between half the step and the whole step, so retries spread out.
- A
429or503withRetry-Afteris waited for at least that long (up to 2 hours). - After 24 hours a delivery is given up and marked failed. You can still resend it from the log.
- A webhook whose every delivery has failed for 3 days (20 or more attempts in a row) is turned off, and its owners are emailed. Nothing is queued for it while it’s off. Fix the endpoint, then turn it back on (
PATCH { "active": true }): its failures are cleared.
The delivery log, resends and tests
- Every delivery is kept for 30 days, with each attempt’s status code, latency, error and the start of the answer: A webhook’s deliveries (filter by status or event type) and One delivery, which also has the exact body it posts. The same log is on each webhook’s page in the app.
- Resend a delivery: the same event (the same id), as a new delivery with its own 24 hours of retries, sent right away. The webhook must be on.
- Send a test event: a
webhook.testevent to that webhook only, on or off, whatever it subscribes to. It’s sent once, answered with what happened, never retried and never counted against the webhook.
{
"id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"type": "webhook.test",
"version": 1,
"createdAt": "2026-10-12T15:04:05.123Z",
"test": true,
"owner": {
"kind": "personal",
"id": "0e6b1c52-8f43-4b8e-9d0c-5a7e2f1b3c4d"
},
"data": {
"webhookId": "1c9e8b7a-6d5f-4e3c-9b2a-1f0e9d8c7b6a",
"message": "A test event from The Collector. If you can read this, your endpoint works."
}
}Where webhooks can go
Deliveries come from our servers, so a webhook’s URL is checked when it’s saved and again at every delivery:
https://only, on port 443 or 1024 and up, with a valid certificate.- No user name or password in the URL (verify the signature instead), and no #fragment.
- Public hosts only. A host that resolves to a private, loopback, link-local (including cloud metadata), carrier-grade NAT, multicast or reserved address, in IPv4 or IPv6, is refused, and so are names like
localhostor*.internal. The address is checked when each delivery connects, so a DNS change can’t point a webhook inside a network later. - To develop against your own machine, expose your receiver through a tunnel (ngrok, Cloudflare Tunnel...) and use its https URL.
http://localhostworks only on a development server of The Collector itself.
A URL that breaks these rules is 400 invalid_webhook_url, with the reason.