Developers
Webhooks
A webhook tells your server when one of your orders changes status. We send a small, signed request to an address on your server. If your server does not answer, we keep trying for about 3 days.
Add an endpoint
- An owner or a manager adds one on the Webhooks page of the portal, under Developers, or with Add a webhook endpoint. Give the address, the mode (test or live) and the events to send to it.
- The address must use
httpson the standard port, with a public name and no user name or password. It cannot be an IP address, a private network address or a Snapshot address. We do not follow redirects, so give the final address. - Each endpoint has its own signing secret, starting
whsec_. We show it once, when you add the endpoint. Keep it in your server’s secret settings. If you lose it, remove the endpoint and add it again. - An account can have up to 10 endpoints switched on. You cannot edit an endpoint. To change one, add the new one, then remove the old one.
The events
| Type | Sent when |
|---|---|
order.accepted | The order was paid for and accepted for production (a test order: when it is placed). |
order.payment_failed | A charge of the saved card failed. It is tried again automatically while attempts are left. |
order.in_production | The order is being made. |
order.shipped | The order shipped, or its tracking number changed. |
order.delivered | The carrier delivered the order. |
order.cancelled | The order was cancelled. |
order.refunded | The order's charge was refunded in full. |
Events come from every order of the account, whether it was placed in the portal or through the API. A live endpoint gets events for live orders. A test endpoint gets events for test orders (Test mode). List events returns the same events.
What is sent
We send a POST with a JSON body, the Snapshot-Signature header, the Snapshot-Event-Id header and the user agent Snapshot-Webhooks/1. The body is small on purpose. It says what happened, and to which order. To read the whole order, use Retrieve an order.
{
"id": "6f1c2d3e-4b5a-4c6d-8e7f-9a0b1c2d3e4f",
"object": "event",
"type": "order.shipped",
"mode": "live",
"created": 1764083045,
"data": {
"object": {
"object": "order",
"id": "0a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
"number": "PO-1001",
"partner_reference": "SHOP-5521",
"status": "shipped"
}
}
}Each event is sent at least once. The same event can arrive twice, so keep the ids you have handled and skip any you have already seen. Events can arrive out of order. created says when each one happened.
Checking the signature
The header is t=<timestamp>,v1=<signature>. The signature is the HMAC-SHA256, in hex, of the timestamp, a period and the body exactly as sent, keyed with the endpoint’s signing secret. Check it against the raw body before you parse it. Refuse a timestamp more than 5 minutes from your own clock, so an old request cannot be replayed to you. In Node:
import { createHmac, timingSafeEqual } from 'node:crypto'
// rawBody: the request body exactly as it arrived, as text, before any JSON parsing.
// header: the Snapshot-Signature header. secret: the endpoint's whsec_ secret.
export function verifySnapshotSignature(rawBody, header, secret, toleranceSeconds = 300) {
let timestamp = null
const signatures = []
for (const part of String(header || '').split(',')) {
const [name, value] = part.split('=')
if (name === 't') timestamp = Number(value)
if (name === 'v1') signatures.push(value)
}
if (!Number.isInteger(timestamp) || signatures.length === 0) return false
if (Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds) return false
const expected = createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest()
return signatures.some((s) => {
const given = Buffer.from(s, 'hex')
return given.length === expected.length && timingSafeEqual(given, expected)
})
}
Answering, and retries
- Answer with any
2xxwithin 8 seconds, before you do any slow work. Any other answer, including a redirect, or no answer in time, counts as a failed attempt. We read only the status code, not the body of your answer. - We retry a failed delivery after 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours, 12 hours, 12 hours, 12 hours, 12 hours, 6 hours. That is 12 attempts in all, the last about 72 hours after the first. After that, the delivery is marked as given up.
When an endpoint is switched off
We switch an endpoint off when 12 attempts in a row have failed and the first of them is at least 24 hours old. A short outage does not switch it off. Any 2xx answer starts the count again.
When an endpoint is switched off:
- the deliveries waiting for it are stopped;
- nothing more is sent to it;
- the account’s owners get an email.
It stays off until you switch it back on. Once your server answers again, an owner or a manager clicks Re-enable beside the endpoint on the Webhooks page. It keeps the same signing secret, and new events are sent to it again. It counts toward the 10 endpoints an account can have switched on. You can also remove it and add it again, with a new secret.
Deliveries and resending
The Webhooks page shows the latest deliveries: the event, the endpoint, the attempts, the status your server last answered with, and when the next try is due. If a delivery is waiting or was given up, an owner or a manager can click Resend to send it now, as long as its endpoint is switched on. Send test sends a signed webhook_endpoint.test event now. A test send does not count toward switching the endpoint off.