Webhooks
Receive real-time event notifications from Analision.
Overview
Webhooks let you subscribe to events in Analision and receive HTTP POST requests to your server whenever those events occur.
Supported Events
| Event | Description |
|---|---|
stock.low | Stock fell below reorder threshold |
stock.updated | Any stock movement recorded |
order.received | Purchase order marked as received |
product.created | New product added |
product.deleted | Product removed |
Creating a Webhook
POST /v1/webhooks{
"url": "https://yourapp.com/hooks/analision",
"events": ["stock.low", "order.received"],
"secret": "your_signing_secret"
}Verifying Payloads
Every request includes an X-Analision-Signature header. Verify it with HMAC-SHA256:
import crypto from 'crypto';
function verifyWebhook(payload: string, signature: string, secret: string) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}Retries
Failed deliveries (non-2xx response) are retried up to 5 times with exponential backoff: 1m, 5m, 30m, 2h, 8h.