API · Webhooks

Webhooks

All webhook endpoints need the webhooks:manage scope. Seven event types exist today (see the list below). Telemetry threshold events are configured in Carriers & telemetry.

Event types

  • compliance.status_changed
  • regulation.alert
  • item.telemetry.threshold — a telemetry reading crossed a tenant-configured threshold rule
  • event.lifecycle.recorded — a lifecycle actor recorded an event through the portal
  • billing.payment_succeeded
  • billing.payment_failed
  • billing.subscription_updated — the three billing events mirror payment events from the billing provider

POST /webhooks

Request

{
  "url": "https://example.com/hooks/listrar",
  "events": ["compliance.status_changed", "regulation.alert"],
  "description": "Compliance pipeline"
}

url must be https. The response (201) includes the signing secret — it is generated server-side and returned exactly once; store it, it cannot be retrieved again.

GET /webhooks

Lists your tenant's subscriptions. Never includes the signing secret.

DELETE /webhooks/{id}

Removes a subscription. Returns 204 on success.

Delivery

Each delivery is an HTTP POST with a JSON body of the form { event, tenantId, occurredAt, data } and the headers content-type: application/json, x-listrar-event (the event type) and x-listrar-signature. Your endpoint must answer within 5 seconds; a 2xx status counts as success, anything else (including a timeout or a redirect — redirects are not followed) counts as failed. Each event has one delivery-log row per subscription showing the latest attempt's status, HTTP status and response snippet, plus an attempt counter; a retry overwrites that row.

Verifying the signature

The signature header looks like x-listrar-signature: t=1700000000,v1=<hex>. t is the Unix time in seconds at which that attempt was signed; v1 is the hex-encoded HMAC-SHA256, keyed with your webhook secret, of the string {t}.{raw request body} — the timestamp, a literal dot, then the body exactly as received. Compute the HMAC over the raw bytes before any JSON parsing; re-serialising the parsed JSON can change the bytes and break the match.

Compare with a constant-time function. We recommend rejecting a delivery whose t is further from your clock than a few minutes (for example 5 minutes) to limit replay of a captured request; this tolerance is your choice, not enforced by Listrar. Every attempt, including a retry, is signed afresh with the current time, so a retry is not rejected by this check.

Node.js

import { createHmac, timingSafeEqual } from "node:crypto";

const TOLERANCE_SECONDS = 300; // your choice

export function verifyListrarSignature(rawBody, header, secret) {
  const parts = Object.fromEntries(
    String(header ?? "")
      .split(",")
      .map((p) => p.split("=", 2)),
  );
  const t = Number(parts.t);
  if (!Number.isInteger(t) || typeof parts.v1 !== "string") return false;
  if (Math.abs(Date.now() / 1000 - t) > TOLERANCE_SECONDS) return false;

  const expected = createHmac("sha256", secret)
    .update(`${t}.${rawBody}`, "utf8")
    .digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(parts.v1);
  return a.length === b.length && timingSafeEqual(a, b);
}

Retries

The first attempt happens right after the triggering event. A delivery that failed is picked up by a background sweep that runs about every 15 minutes and when the worker starts. The sweep retries every failed delivery it finds, with no minimum delay since the previous attempt, so the gap between attempts ranges from seconds up to about 15 minutes. A delivery is attempted up to 3 times (the first attempt plus two retries); after that it stays failed in the delivery log and is not retried again. Retries are skipped while the subscription is disabled.

Delivery is at-least-once: more than one sweeper can run, so the same event may occasionally reach your endpoint more than once, close together. Make your handler idempotent. There is no delivery-id header; deduplicate on values parsed from the body — event, tenantId, occurredAt and data are stored and re-sent unchanged across retries. Never deduplicate on a hash of the raw body: a retry re-serialises the stored payload, so its bytes can differ from the first attempt. Verify each request against its own raw body and its own t.

Webhooks | Listrar Docs | Listrar