typedhookv0.1.0

Type-safe webhooks
for TypeScript

Send, store and verify webhooks. Typed from the schema you send to the payload your customers receive.

then ask

A few lines on each side

Declare events once. Send them signed, right away or after your transaction commits. Verify them with the types attached.

import { webhooks } from "@typedhook/sdk";
import { z } from "zod";

export const wh = webhooks({
  events: {
    "invoice.paid": z.object({ invoiceId: z.string(), amountCents: z.number() }),
  },
  subscribers: async ({ event, subject }) => db.findSubscribers(event, subject),
  signing: { secret: process.env.WEBHOOK_SECRET! },
});

const result = await wh.send({
  event: "invoice.paid",
  subject: "acct_42",
  data: { invoiceId: "inv_1", amountCents: 4200 },
});
if (!result.ok) console.error(result.error); // never throws
01

Typed events

Any Standard Schema library. The event name narrows data.

zodvalibotarktype
02

Scoped to a subject

Each event names the account it's for, signed into the body.

subject: "acct_42"
03

Outbox in your transaction

The event commits with your data, or not at all.

BEGIN→INSERT→COMMIT
04

Retries that back off

30s, doubling up to 1h. After 20 attempts the row is marked dead.

05

Verify on any runtime

Zero dependencies. WebCrypto only. Never throws on a bad request.

NodeBunDenoWorkers
06

Typed for your customers

They import your event types and get typed payloads.

(property) amountCents: number

Send your first
signed webhook

Install the sender, declare one event and call send(). About five minutes.