A Webhooks allows Artelo to provide real-time information about various events.
Webhooks must return a response within 10 seconds. For this reason, long-running processes should be run asynchronously.
Any response outside the 2xx range, a timeout, or a connection error counts as a failure. A failed request is retried with exponential backoff, waiting about 15 minutes, then 30 minutes, then 1 hour, doubling each time. If an event fails 8 times in a row (about 32 hours), the webhook is deleted. Responding with 410 Gone deletes the webhook immediately.
Every request includes a x-artelo-webhook-id header. Retries of the same event carry the same value, so use it to ignore duplicate deliveries.
It is recommended to verify that webhook requests are coming from Artelo. The recommended method is to use the x-artelo-signature security header that you receive in each request. The value of this header corresponds to the SHA256 hash of the request body using your client secret.
const bodySignature = crypto
.createHmac('sha256', process.env["WEBHOOK_SECRET"])
.update(JSON.stringify(req.body)) // or disable body parsing
.digest('hex');
if (bodySignature !== request.headers['x-artelo-signature']) {
return res.status(400).json({
code: 'invalid_signature',
error: 'Signature does not match',
});
}