Guides
Webhooks
Receive asynchronous status updates without polling.
Guides
Receive asynchronous status updates without polling.
| Event | Description |
|---|---|
| job.started | Job accepted and started processing |
| job.completed | Job finished and output is available |
| job.failed | Job failed, check error payload |
| Header | Description |
|---|---|
| X-Webhook-Event | Event name, e.g. job.completed |
| X-Webhook-Delivery-Id | Unique delivery id |
| X-Webhook-Timestamp | ISO timestamp used for signing |
| X-Webhook-Signature | HMAC-SHA256 signature when signing secret is configured |
import crypto from 'node:crypto';
export function verifyWebhook(rawBody, timestamp, signature, secret) {
const signed = `${timestamp}.${rawBody}`;
const digest = crypto.createHmac('sha256', secret).update(signed).digest('hex');
const expected = `sha256=${digest}`;
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature || ''));
}