Webhooks
District sends a POST request with a JSON body to your HTTPS endpoint when a listing, an order, a livestream or a seller changes.
How a webhook works
- Change
A listing, an order, a livestream or a seller changes in District.
- Delivery
District sends a signed
POSTrequest with the event to your HTTPS endpoint. - Check
Your server checks the signature and answers with a 2xx status within 10 seconds.
Events
Each event type has the form <resource>.<change>. Your app gets the events of the types that you ask for.
Listings
The listing.* events need the admin:products:read scope.
| Event | Sent when |
|---|---|
listing.created | A listing is created, or a removed listing is restored. |
listing.updated | A field of the listing changes, such as a variant, a photo, the shipping settings or its auction. |
listing.removed | A listing is deleted. |
Orders
The order.* events need the admin:orders:read scope.
| Event | Sent when |
|---|---|
order.created | The order first shows in the Admin API: at its first status after PENDING. The event of that status comes with it, for example order.paid. |
order.updated | A field of the order changes, such as a refund, a dispute or a shipment, and no other order event applies. |
order.paid | The order status moves to PAID for a new sale. A move back to PAID, for example after a label void, sends order.updated. |
order.shipped | The order status moves to SHIPPED. |
order.delivered | The order status moves to DELIVERED. |
order.cancelled | The order status moves to CANCELLED. |
order.refunded | The order status moves to REFUNDED. A partial refund sends order.updated. |
Livestreams
The livestream.* events need the admin:livestreams:read scope.
| Event | Sent when |
|---|---|
livestream.created | A livestream is created, or a removed livestream is restored. |
livestream.updated | A field of the livestream changes, and no other livestream event applies. |
livestream.removed | A livestream is deleted. |
livestream.started | A scheduled livestream goes live. |
livestream.paused | The livestream is paused. |
livestream.resumed | A paused livestream goes live again. |
livestream.ended | The livestream ends. |
livestream.cancelled | The livestream is cancelled. |
Sellers
The seller.* events need the admin:products:read scope.
| Event | Sent when |
|---|---|
seller.updated | The seller starts or ends a vacation. One event comes for each marketplace of the seller. |
When a listing or a livestream is removed, you get only listing.removed or livestream.removed, even if its status changed in the same update.
Request body
Each event has a body of the same form:
{
"id": "whdl_…",
"type": "order.paid",
"occurred_at": "2026-11-12T14:03:11.402Z",
"marketplace_id": "mp_…",
"user_id": "user_…", // null for a public livestream
"data": {
"id": "order_…",
"owner_id": "user_…", // or null
"status": "PAID", // order and livestream events only
"previous_status": "CONFIRMED", // only when the status moved
"changed_fields": ["paymentStatus"]
}
}| Field | Value |
|---|---|
id | The delivery ID. It is the same on each retry, and it equals the webhook-id header. |
type | The event type. |
occurred_at | The time of the change, in ISO 8601. |
marketplace_id | The marketplace of the resource. |
user_id | The member who authorized your app and can see the resource. One change can arrive once for each such member. null for a livestream that is public on the storefront. |
data.id | The Admin API ID of the resource: product_…, order_…, live_… or user_…. |
data.owner_id | The user who owns the resource: the seller of a listing or an order, or the host of a livestream. null when the change names no owner, or moves the resource to another owner. |
data.status | Order and livestream events only. The status after the change. A livestream status is SCHEDULED, LIVE, PAUSED, ENDED or CANCELLED. |
data.previous_status | Only when the change moves the status. The status before the change. |
data.changed_fields | The Admin API names of the fields that changed. The list can be empty. |
The body holds IDs and the names of the changed fields, not the object. Read the current object from the Admin API with data.id.
Headers
The headers follow Standard Webhooks.
| Header | Value |
|---|---|
webhook-id | The delivery ID. It equals id in the body, and it is the same on each retry. |
webhook-timestamp | The time of the send, in Unix seconds. |
webhook-signature | v1, and the base64 signature. The header can hold more than one signature, separated by spaces. |
content-type | application/json |
Verify the signature
Verify each request before you use it. The signing secret starts with whsec_: decode the base64 text after whsec_ to get the key bytes. The signature is the base64 HMAC-SHA256, with the key bytes, of <webhook-id>.<webhook-timestamp>.<raw body>.
- Use the raw bytes of the body. Do not parse and serialize the JSON before you verify it.
- Reject a request whose
webhook-timestampis more than 5 minutes from your clock. - Compare the signatures in constant time.
This TypeScript function uses Web Crypto:
const TOLERANCE_SECONDS = 5 * 60
// Returns the parsed body of a verified webhook request, or throws.
export async function verifyWebhook(request: Request, secret: string): Promise<unknown> {
const id = request.headers.get('webhook-id')
const timestamp = request.headers.get('webhook-timestamp')
const signatures = request.headers.get('webhook-signature')
if (id === null || timestamp === null || signatures === null) {
throw new Error('A webhook header is missing')
}
const sentAt = Number(timestamp)
if (!Number.isInteger(sentAt) || Math.abs(Date.now() / 1000 - sentAt) > TOLERANCE_SECONDS) {
throw new Error('The webhook timestamp is outside the tolerance')
}
// Sign the raw bytes of the body, not a parsed and serialized copy.
const body = new Uint8Array(await request.arrayBuffer())
const prefix = new TextEncoder().encode(`${id}.${timestamp}.`)
const signed = new Uint8Array(prefix.length + body.length)
signed.set(prefix)
signed.set(body, prefix.length)
const key = await crypto.subtle.importKey(
'raw',
fromBase64(secret.replace(/^whsec_/, '')),
{ name: 'HMAC', hash: 'SHA-256' },
false,
['verify'],
)
for (const entry of signatures.split(' ')) {
const [version, signature] = entry.split(',')
// crypto.subtle.verify compares the signatures in constant time.
if (version === 'v1' && signature && (await crypto.subtle.verify('HMAC', key, fromBase64(signature), signed))) {
return JSON.parse(new TextDecoder().decode(body))
}
}
throw new Error('The webhook signature is not valid')
}
function fromBase64(text: string): Uint8Array<ArrayBuffer> {
return Uint8Array.from(atob(text), (char) => char.charCodeAt(0))
}The standardwebhooks npm library also verifies the requests.
When District rotates your signing secret, your Enterprise solutions team sends you the new secret. Accept the old and the new secret until they tell you to remove the old one.
Delivery and retries
- Answer with a 2xx status within 10 seconds. District does not follow a redirect: a 3xx answer is a failure.
- District sends each event at least once, in no fixed order. Remove duplicates by
webhook-id. - After a failure, District sends the delivery again: first after 30 seconds, then with a delay that doubles up to 1 hour. It makes up to 13 attempts.
- A
429or503answer with aRetry-Afterheader delays the next attempt by at least that time, up to 12 hours. It also pauses each send to your endpoint until that time, up to 1 hour. - After 5 failed attempts in a row, District pauses the sends to your endpoint for 5 minutes.
- A
410 Goneanswer turns off your endpoint at once. An endpoint that still fails 72 hours after the first failure in a row turns off at its next failure. An endpoint that is off gets no deliveries until your Enterprise solutions team turns it on again.
Register an endpoint
No API registers an endpoint. Your Enterprise solutions team registers your endpoint. Send them the HTTPS URL and the event types you want. They send you the signing secret (whsec_…).
- Each app has one endpoint.
- The client of your app needs the read scope of each resource that you get events for:
listing.*:admin:products:readorder.*:admin:orders:readlivestream.*:admin:livestreams:readseller.*:admin:products:read
A member gets events only after the member authorizes your app. Sync service keys do not get webhooks yet: see Authentication.