Receive Events
Subscribe to Sibi events via webhooks.
Receiving Events via Webhook
Register a webhook yourself from the Sibi Developer Portal: select Register a webhook and provide
- Endpoint URL — the https endpoint Sibi will POST deliveries to.
- Topics — a comma separated list of the topics you want, for example
order.created, order.updated. Leave it empty to receive every topic. - Test webhook — a test webhook receives only events from the test environment, and a prod webhook only prod events. This cannot be changed after the webhook is registered.
Disabling a webhook
A webhook’s Status on the Webhooks page controls whether it receives
events. A Disabled webhook is skipped when an event fires.
Redrive is also unavailable on a disabled webhook, so deliveries recorded before it was disabled cannot be re-sent until it is enabled again.
Deleting a webhook
Open a webhook from the Webhooks page and select Delete.
Authentication
Your endpoint is reachable by anyone who knows its URL, so verify that every request came from Sibi before acting on it.
Sibi signs every delivery with the webhook’s signing secret: we calculate an HMAC-SHA256 of the raw request body using
the secret and set the base64 encoded result in the Signature HTTP header. Compute the same HMAC over the raw body
you received and compare it to that header. Reject the request if they don’t match.
Verify payload signature
import crypto from 'node:crypto';
import express from 'express';
const app = express();
const secret = process.env.SIBI_WEBHOOK_SECRET;
// Read the body as raw bytes. Parsing it as JSON and serializing it again can change
// the bytes, and the signature no longer matches.
app.post('/sibi/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
const received = Buffer.from(req.get('Signature') ?? '', 'base64');
const expected = crypto.createHmac('sha256', secret).update(req.body).digest();
// Compare in constant time so the check doesn't reveal how much of a forged
// signature matched. timingSafeEqual requires equal lengths, so check that first.
if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
return res.sendStatus(401);
}
const { topic, data } = JSON.parse(req.body.toString('utf8'));
// Handle the event, then respond with a 2xx status.
res.sendStatus(204);
});
Keep the signing secret out of source control, for example in an environment variable or a secrets manager.
For a version 1 webhook, read the HTTP-X-SIBI-SIGNATURE-256 header instead of Signature.
Ensuring You Receive Events
If a webhook request fails, we will retry 5 times with a backoff before permanently failing.
Status Code Retry Policy
We’ll consider a webhook delivery successful only if your server returns a status code in the range 200-299. If your server returns any status code outside this range (such as 3xx, 4xx, or 5xx), we will treat it as a failure and retry the delivery.
Monitoring Deliveries
The Sibi Developer Portal records every delivery we send you: the payload, the outcome, and the status code and response body of each attempt. You can re-send a delivery after fixing your endpoint. Delivery records are kept for 90 days. See Monitor Webhook Deliveries.
Filtering Events
The HTTP request will contain a topic header that can be used to route the request without parsing the body. The body of all webhook requests will have the following format:
{
"topic": "topic.name",
"data": <topic-dependent>
}
The format under “data” will differ by topic and will generally contain the most up to date version of whatever resource type the event is about.
It currently emits the following topics:
order.created- Order dataorder.updated- Order dataorder.exception.created- Order exception dataorder.cancellationrequest.created- Order cancellation request dataorder.cancellationrequest.updated- Order cancellation request dataorder.returnrequest.created(beta) - Order return request dataorder.returnrequest.item-approved(beta) - Order return request dataorder.returnrequest.item-denied(beta) - Order return request dataorder.returnrequest.updated(beta) - Order return request dataasset.created- Asset data (shape depends on webhook version)asset.updated- Asset data (shape depends on webhook version)invoice.created- Invoice dataoffer.created- Offer dataoffer.updated- Offer dataoffer.buyout.adjusted- Offer data
Topics marked (beta) are in beta and are delivered only to webhooks enrolled in the beta program. Contact Sibi to opt in.
Webhook Versions
Every webhook is registered at a version. The version fixes the shape of the payloads that webhook receives, so a payload never changes under an integration that is already consuming it.
- A version only changes on a breaking change to an existing payload. Adding a new topic is not a breaking change.
- A new topic is emitted only to webhooks on the latest version at the time the topic is introduced. A webhook on an
older version keeps receiving every topic that existed while its version was the latest, but not topics introduced
after a newer version was released. For example, if a
foo.createdtopic is added while2is the latest version, webhooks on version2receive it and webhooks on version1do not. A topic added while1was still the latest version continues to reach version1webhooks after2is released. - A webhook can be upgraded to a newer version. It can never be downgraded. Before upgrading, read the changelog below and update your handler for every version between the one you are on and the one you are moving to.
- Every delivery carries a
webhook-versionheader with the version of the payload it contains.
Changelog
Version 2
Three breaking changes:
Asset ids.
asset.createdandasset.updatedprefix the assetidwithas_, matching the ids the Assets REST API returns.- Order fees.
order.*events no longer includefees[].title. Readfees[].nameinstead. Signature header. The HMAC moves from
HTTP-X-SIBI-SIGNATURE-256(and the legacyHTTP_X_SIBI_SIGNATURE_256) to a singleSignatureheader. See Verify payload signature.
Additions:
- Invoice due date.
invoice.createdincludesdueDate. Labor decline reason.
project-phase.labor.declinedincludesreasonand, forOTHER,reasonOther. See Project phase events.Comment author name.
project-phase.comment.created,project-phase.comment.updatedandproject-phase.comment.deletedincludeauthorName. See Project phase events.Project topics. New topics
project-phase.cancelled,project-phase.material-order.placed,project-phase.material-order.updatedandproject-phase.material-order.removed. See Project phase events.
Version 1
Initial release.
Testing Webhooks
We have a webhook testing tool available that you can use to send test events. You can supply any secret you want to use for testing. It provides a number of example payloads you can emit, and you can alter them to test different scenarios. It will reject any payloads that don’t match the event schemas, so all events emitted by the tool should be representative of the events you’ll receive from Sibi.