Receive events with webhooks
A webhook endpoint is a URL Officely sends events to as they happen. Each request is a POST with one event as its JSON body, signed with a secret only you and Officely know.
Add an endpoint
Create a webhook endpoint with an HTTPS URL and the events you want. List exact names such as booking.created, every event for one object with booking.*, or everything with *. A wildcard also covers events added to webhooks later. Webhooks send every event except an account's own account.created, account.archived and account.restored, a webhook endpoint's own changes, and favourite coworkers.
curl -X POST https://api.officely.app/webhook-endpoints \ -H "Authorization: Bearer $OFFICELY_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com/officely/webhooks", "events": ["booking.*"]}'
The response includes secret, which starts with whsec_. Store it now. Officely shows it only when you create an endpoint or rotate its secret.
Verify each request
Every request carries three headers from the Standard Webhooks specification:
webhook-idis the event'sid. Use it to ignore a request you've already handled.webhook-timestampis when the request was signed, in Unix seconds.webhook-signatureholds one or morev1,signatures, separated by spaces.
Check the signature against the raw request body before you parse it. The standardwebhooks package does this for you and rejects requests more than five minutes old.
import { Webhook } from "standardwebhooks";
const webhook = new Webhook(process.env.OFFICELY_WEBHOOK_SECRET);
app.post("/officely/webhooks", express.raw({ type: "application/json" }), (req, res) => {
let event;
try {
event = webhook.verify(req.body, req.headers);
} catch {
return res.status(400).send("Invalid signature");
}
// Handle the event, then answer quickly.
res.sendStatus(204);
});Answer with any 2xx status within 10 seconds. Do slow work after you respond. Officely doesn't follow redirects, so a 3xx counts as a failure.
Retries
When a request fails, Officely tries again after 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and then every 12 hours, up to 12 tries over about three days. If you answer 429 or 503 with a Retry-After header, in seconds or as an HTTP date, Officely waits at least that long before that try, up to 12 hours. Each try is recorded on the event's webhook delivery, with its status code, duration and the start of your response.
Requests can arrive more than once and out of order. Use webhook-id to skip repeats, and read the subject's event history when order matters.
If an endpoint keeps failing for three days, Officely turns it off and records webhook_endpoint.disabled in the endpoint's event history. Webhooks don't send it. Only automatic tries count, so a test or resend getting through doesn't reset the three days. Fix the receiver, then enable the endpoint again.
While an endpoint is off, Officely doesn't send it anything. Events that happen while it's off are never sent, and a retry that comes due while it's off fails for good. Catch up from event history, or resend the deliveries you need once the endpoint is back on.
Test and resend
Send a test to check your receiver. Officely sends a webhook_endpoint.tested event to that endpoint only, once, even while the endpoint is off.
To send a delivery again, resend it. Officely sends the same event with the same webhook-id once more, straight away, even while the endpoint is off. A resend isn't retried and doesn't count toward the 12 tries or the three days. If the delivery is still being retried, its next automatic try stays when it was.
Rotate the secret
Rotating the secret returns a new whsec_ value. For the next 24 hours Officely signs every request with both the old and the new secret, so you can deploy the new one without dropping requests.
See the Webhook Endpoint reference and Webhook Delivery reference.

