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

EventDescription
stock.lowStock fell below reorder threshold
stock.updatedAny stock movement recorded
order.receivedPurchase order marked as received
product.createdNew product added
product.deletedProduct 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.

On this page