Developers
Let your own systems know the moment something changes in a Hand-Off store: an order is placed or paid, a customer signs up, a product or its stock changes.
A webhook endpoint is an address on your server. When an event it subscribes to happens in the store, Hand-Off sends it an HTTPS POST with a JSON body describing the change, signed so you can check it came from Hand-Off. Your server answers 2xx to say it got it.
Use them to update a warehouse, an accounting tool, a CRM or a chat channel without polling the API.
whsec_) and keep it on your server. It is shown once; if you lose it, rotate it.store:webhook:manage) add, change, pause, delete and test endpoints and rotate secrets. Members who can only read webhooks (store:webhook:read) see the endpoints and their delivery log.https:// on port 443, with a public host name: not an IP address, not a private or internal name, no user name or password in it. Hand-Off checks it when you save it and again before every delivery.Webhooks are rolling out. If Settings doesn’t show Webhooks for your store yet, they aren’t switched on for it.
The list of event types isn’t available right now. It is read from the running Hand-Off API and will appear here when the API can be reached. The guides on the other pages don’t depend on it.
webhook.test is what Send test event sends. Nobody subscribes to it, it holds no store data, and it goes to a paused endpoint too.2xx to a type you don’t handle.Every delivery is one JSON object, the envelope:
{
"id": "evt_3kQx7cV0bN2mRt9yLp4wZa1s",
"type": "webhook.test",
"api_version": "v1",
"created": 1796292000,
"store_id": "6740f1c2a9e4b3d2c1a0f9e8",
"data": {
"object": {
"object": "test",
"message": "This is a test delivery from Hand-Off."
}
}
}| Field | What it is |
|---|---|
id | The event’s id (evt_…). The same as the webhook-id header, and the same on every try. |
type | The event type, such as order.paid. |
api_version | The payload version, "v1". |
created | When the event happened, in Unix seconds. |
store_id | The store it happened in. |
data.object | The order, customer, product or stock record. Its object field says which. |
data.object is the record as it is when the delivery is sent, not when the event happened. A retry, or a resend from the delivery log, carries the latest state. Use the record’s own updatedAt to tell which of two deliveries is newer.{ object, id, deleted: true }.currency on every record that holds money.v1. Ignore fields you don’t know.Deliveries are signed the Standard Webhooks way, so any Standard Webhooks library can verify them. Every delivery carries three headers:
POST /hooks/hand-off HTTP/1.1
Content-Type: application/json
User-Agent: Hand-Off-Webhooks/1.0
webhook-id: evt_3kQx7cV0bN2mRt9yLp4wZa1s
webhook-timestamp: 1796292004
webhook-signature: v1,<base64 HMAC-SHA256>webhook-id: the event id.webhook-timestamp: when this try was sent, in Unix seconds.webhook-signature: v1, and the base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{body}. While a secret is being rotated it holds two signatures separated by a space; accept the delivery when either matches.To check one:
whsec_, base64-decoded.id.timestamp.body with HMAC-SHA256, using the raw body exactly as received. Parsing the JSON and serialising it again changes the bytes.v1, signature in constant time (timingSafeEqual, hmac.compare_digest), never with ==.import { createHmac, timingSafeEqual } from "node:crypto"
import express from "express"
const SECRET = process.env.HAND_OFF_WEBHOOK_SECRET // whsec_…
const TOLERANCE_SECONDS = 5 * 60
/** True when one of the signatures matches. rawBody: the request body exactly as received. */
export function verifyHandOffWebhook(rawBody, headers, secret = SECRET) {
const id = headers["webhook-id"]
const timestamp = headers["webhook-timestamp"]
const signatures = headers["webhook-signature"]
if (!id || !timestamp || !signatures || !/^\d+$/.test(timestamp)) return false
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > TOLERANCE_SECONDS) return false
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64")
const expected = createHmac("sha256", key)
.update(Buffer.concat([Buffer.from(`${id}.${timestamp}.`), rawBody]))
.digest()
return signatures.split(" ").some((entry) => {
const [version, value] = entry.split(",")
if (version !== "v1" || !value) return false
const given = Buffer.from(value, "base64")
return given.length === expected.length && timingSafeEqual(given, expected)
})
}
const app = express()
// Keep the raw bytes: parsing and re-serialising the JSON changes them and breaks the signature.
app.post("/hooks/hand-off", express.raw({ type: "application/json" }), async (req, res) => {
if (!verifyHandOffWebhook(req.body, req.headers)) return res.sendStatus(400)
const event = JSON.parse(req.body.toString("utf8"))
if (await alreadyHandled(req.headers["webhook-id"])) return res.sendStatus(200)
await queueForProcessing(event) // do the slow work after answering
res.sendStatus(200)
})import base64
import hashlib
import hmac
import time
TOLERANCE_SECONDS = 5 * 60
def verify_hand_off_webhook(raw_body: bytes, headers, secret: str) -> bool:
"""True when one of the signatures matches. raw_body: the request body exactly as received."""
msg_id = headers.get("webhook-id")
timestamp = headers.get("webhook-timestamp")
signatures = headers.get("webhook-signature")
if not msg_id or not timestamp or not signatures or not timestamp.isdigit():
return False
if abs(time.time() - int(timestamp)) > TOLERANCE_SECONDS:
return False
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{timestamp}.".encode() + raw_body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
for entry in signatures.split(" "):
version, _, value = entry.partition(",")
if version == "v1" and hmac.compare_digest(value, expected):
return True
return False
# Flask: verify_hand_off_webhook(request.get_data(), request.headers, SECRET)2xx status within 10 seconds. Anything else is a failed try: another status, a timeout, a refused connection or a TLS error.3xx is a failure. Give the final address.A failed delivery is tried again, 8 tries in all over about a day. Each wait gets up to 10% added at random.
| Try | When |
|---|---|
| 1 | Right after the event |
| 2 | 1 minute after try 1 |
| 3 | 5 minutes after try 2 |
| 4 | 30 minutes after try 3 |
| 5 | 2 hours after try 4 |
| 6 | 5 hours after try 5 |
| 7 | 8 hours after try 6 |
| 8 | 8 hours after try 7 (the last) |
Retry-After header asking for a longer wait, Hand-Off waits that long, up to 1 hour.The same event can reach you more than once: a try that timed out after your server handled it, a resend, or a delivery Hand-Off queued again after a fault. Store each webhook-id you have handled and skip one you have already seen. Events can also arrive out of order, so don’t rely on the order they come in.
An endpoint whose deliveries have all failed for 3 days is disabled: Hand-Off stops sending to it and Settings shows it as disabled. Fix your server, then turn the endpoint back on; it starts again with a clean count. Any successful delivery (other than a test) resets the count.
Rotate when the secret may have leaked, when someone who knew it leaves, or on a schedule. In Settings → Webhooks, open the endpoint and choose Rotate secret. The new secret is shown once.
Something not arriving? Check the endpoint’s delivery log first: it shows each try’s status code or a short reason. Still stuck? Write to support@hand-off.net.