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

  1. Change

    A listing, an order, a livestream or a seller changes in District.

  2. Delivery

    District sends a signed POST request with the event to your HTTPS endpoint.

  3. Check

    Your server checks the signature and answers with a 2xx status within 10 seconds.

  4. Read

    Your server reads the current object from the Admin API with node(id: data.id).

    Read the recipe

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.

EventSent when
listing.createdA listing is created, or a removed listing is restored.
listing.updatedA field of the listing changes, such as a variant, a photo, the shipping settings or its auction.
listing.removedA listing is deleted.

Orders

The order.* events need the admin:orders:read scope.

EventSent when
order.createdThe 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.updatedA field of the order changes, such as a refund, a dispute or a shipment, and no other order event applies.
order.paidThe order status moves to PAID for a new sale. A move back to PAID, for example after a label void, sends order.updated.
order.shippedThe order status moves to SHIPPED.
order.deliveredThe order status moves to DELIVERED.
order.cancelledThe order status moves to CANCELLED.
order.refundedThe order status moves to REFUNDED. A partial refund sends order.updated.

Livestreams

The livestream.* events need the admin:livestreams:read scope.

EventSent when
livestream.createdA livestream is created, or a removed livestream is restored.
livestream.updatedA field of the livestream changes, and no other livestream event applies.
livestream.removedA livestream is deleted.
livestream.startedA scheduled livestream goes live.
livestream.pausedThe livestream is paused.
livestream.resumedA paused livestream goes live again.
livestream.endedThe livestream ends.
livestream.cancelledThe livestream is cancelled.

Sellers

The seller.* events need the admin:products:read scope.

EventSent when
seller.updatedThe 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"]
  }
}
FieldValue
idThe delivery ID. It is the same on each retry, and it equals the webhook-id header.
typeThe event type.
occurred_atThe time of the change, in ISO 8601.
marketplace_idThe marketplace of the resource.
user_idThe 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.idThe Admin API ID of the resource: product_…, order_…, live_… or user_….
data.owner_idThe 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.statusOrder and livestream events only. The status after the change. A livestream status is SCHEDULED, LIVE, PAUSED, ENDED or CANCELLED.
data.previous_statusOnly when the change moves the status. The status before the change.
data.changed_fieldsThe 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.

HeaderValue
webhook-idThe delivery ID. It equals id in the body, and it is the same on each retry.
webhook-timestampThe time of the send, in Unix seconds.
webhook-signaturev1, and the base64 signature. The header can hold more than one signature, separated by spaces.
content-typeapplication/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-timestamp is 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 429 or 503 answer with a Retry-After header 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 Gone answer 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:read
  • order.*: admin:orders:read
  • livestream.*: admin:livestreams:read
  • seller.*: admin:products:read

A member gets events only after the member authorizes your app. Sync service keys do not get webhooks yet: see Authentication.