HookRail

Developer Documentation — SDK v2.8

Publish once. Replay anytime.

npm install @hookrail/sdk Open Retry Simulator

01 / Workflow

Publish a Durable Event

Enqueue an event with an idempotency key. HookRail fans out to all matching tenant endpoints with automatic retries.

src/billing/emit.ts
import { HookRail } from "@hookrail/sdk";

const bus = new HookRail({ apiKey: process.env.HOOKRAIL_KEY });

await bus.events.publish({
  tenantId: "org_4920",
  type: "invoice.settled",
  idempotencyKey: "inv_8831_v1",
  payload: { invoiceId: "inv_8831", amountCents: 49000, currency: "USD" },
});

02 / Workflow

Verify HMAC-SHA256 Signatures

Validate both the cryptographic digest and the 5-minute replay tolerance window on your subscriber server.

src/webhooks/verify.ts
import { verifySignature } from "@hookrail/sdk/verify";

export async function POST(request: Request) {
  const rawBody = await request.text();
  const event = verifySignature({
    payload: rawBody,
    headers: request.headers,
    secrets: [process.env.WEBHOOK_SECRET_CURRENT!, process.env.WEBHOOK_SECRET_PREV!],
    toleranceSeconds: 300,
  });

  return Response.json({ received: event.id });
}

03 / Workflow

Selective Dead-Letter Replay

Recover cleanly after a downstream outage by replaying only failed 502/503 events inside the incident window.

src/ops/replay.ts
const job = await bus.dlq.replay({
  endpointId: "ep_01J8X9Q",
  statusCodes: [502, 503, 504],
  since: "2026-11-26T14:00:00Z",
  until: "2026-11-26T15:30:00Z",
  maxRatePerSecond: 250,
});