Signed, retried, replayable webhooks.
Publish typed events from your TypeScript app. Good Webhooks stores them in your PostgreSQL database and delivers them as signed Standard Webhooks requests, with retries and a record of every attempt.
$ npm install good-webhooks
import { createWebhooks } from 'good-webhooks'
import { z } from 'zod'
const webhooks = createWebhooks({
database: pool, // pg.Pool
encryptionKey: process.env.WEBHOOK_ENCRYPTION_KEY,
events: {
'invoice.paid': z.object({
invoiceId: z.string(),
amount: z.number().int(),
}),
},
})
// Register the endpoint that receives them.
const { secret } = await webhooks.endpoints.create({
url: 'https://receiver.example/webhooks',
eventTypes: ['invoice.paid'],
})
// Publish a typed event, in your transaction.
await webhooks.publish({
type: 'invoice.paid',
data: { invoiceId: 'inv_123', amount: 4200 },
})
// A worker you run signs, sends, and retries.
await webhooks.worker.run({ signal })- Publish
publish()validates a typed event and finds subscribed endpoints. - StoreThe event and its deliveries commit with your own data.
- DeliverYour worker signs, sends, retries, and records every attempt.
- Verify
parseWebhook()checks the signature and returns a typed event.
Publish on your side. Verify on theirs.
The client validates the payload against your schema and records the event inside your transaction. The receiver imports only the verify module and checks the signature in one call.
Sender · your app
import { createWebhooks } from 'good-webhooks'
import { z } from 'zod'
export const webhooks = createWebhooks({
database: pool, // pg.Pool
encryptionKey: process.env.WEBHOOK_ENCRYPTION_KEY,
events: {
'invoice.paid': z.object({
invoiceId: z.string(),
amount: z.number().int(),
}),
},
})
// Inside the transaction that marks the invoice paid.
await webhooks.publish(
{
type: 'invoice.paid',
data: { invoiceId: 'inv_123', amount: 4200 },
},
{ transaction: client },
)import { createDelivery } from 'good-webhooks/delivery'
import {
createBetterAuthManagement,
} from 'good-webhooks/better-auth'
import { z } from 'zod'
import { auth } from './auth'
const management = await createBetterAuthManagement(auth)
export const delivery = createDelivery({
database: pool, // pg.Pool
source: management.source,
events: {
'invoice.paid': z.object({
invoiceId: z.string(),
amount: z.number().int(),
}),
},
})
// In the signed-in user's scope: their endpoints, nobody else's.
await delivery.forScope({ type: 'user', id: user.id }).publish({
type: 'invoice.paid',
data: { invoiceId: 'inv_123', amount: 4200 },
})Receiver · their endpoint
import { parseWebhook, WebhookError } from 'good-webhooks/verify'
import { events } from './events'
export async function POST(request: Request) {
try {
const event = await parseWebhook({
body: new Uint8Array(await request.arrayBuffer()),
headers: request.headers,
secret: process.env.WEBHOOK_SECRET!,
events,
})
// Check event.type; then event.data is typed.
return new Response(null, { status: 204 })
} catch (error) {
if (error instanceof WebhookError) {
return new Response('Invalid webhook', { status: 400 })
}
throw error // 500: the sender retries.
}
}import { Hono } from 'hono'
import { bodyLimit } from 'hono/body-limit'
import { parseWebhook, WebhookError } from 'good-webhooks/verify'
import { events } from './events'
const app = new Hono()
const limit = bodyLimit({ maxSize: 512 * 1024 })
app.post('/webhooks', limit, async (c) => {
try {
const event = await parseWebhook({
body: new Uint8Array(await c.req.arrayBuffer()),
headers: c.req.raw.headers,
secret: process.env.WEBHOOK_SECRET!,
events,
})
// Check event.type; then event.data is typed.
return c.body(null, 204)
} catch (error) {
if (error instanceof WebhookError) {
return c.text('Invalid webhook', 400)
}
throw error // 500: the sender retries.
}
})
export default appimport express from 'express'
import { parseWebhook, WebhookError } from 'good-webhooks/verify'
import { events } from './events'
const app = express()
// Raw bytes, not parsed JSON: the signature covers the exact body.
const raw = express.raw({
type: 'application/json',
limit: '512kb',
})
app.post('/webhooks', raw, async (req, res) => {
try {
const event = await parseWebhook({
body: req.body,
headers: req.headers,
secret: process.env.WEBHOOK_SECRET!,
events,
})
// Check event.type; then event.data is typed.
res.sendStatus(204)
} catch (error) {
if (error instanceof WebhookError) {
return res.status(400).send('Invalid webhook')
}
throw error // Express 5 answers 500: the sender retries.
}
})
app.listen(3000)What a webhook request looks like
A plain HTTPS POST, signed over the exact body bytes and a timestamp. Any Standard Webhooks library can verify it. Pick a header to see what it covers.
- POST /webhooks HTTP/1.1
- Host:receiver.example
- Content-Type:application/json
- webhook-id:7a0c3f3e-5b2c-4f8e-9d1a-2e6b8c4d9f10
- webhook-timestamp:1760000000
- webhook-signature:v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj6D2hFcTjqRVo=
- {
- "id": "7a0c3f3e-5b2c-4f8e-9d1a-2e6b8c4d9f10",
- "type": "invoice.paid",
- "occurredAt": "2026-10-09T09:46:40.000Z",
- "data": { "invoiceId": "inv_123", "amount": 4200 }
- }
webhook-signature = v1, base64( HMAC-SHA256( secret, id.timestamp.body ) )
What you get
The parts of delivery that are tedious to get right, done once and tested.
Typed events
Any Standard Schema validator. The publisher rejects bad payloads; the receiver decodes into the same types.
Standard Webhooks signing
webhook-id, webhook-timestamp, and an HMAC-SHA256 signature on every request. Any compliant verifier works.
Transactional publish
Pass your open PostgreSQL client. If the business write rolls back, the event never existed.
Retries and replay
Bounded retries that honor Retry-After, every attempt recorded, and failing endpoints paused, never deleted.
Better Auth plugin
Users manage their own endpoints through authenticated routes, with organization permissions.
Bring your own sender
A two-method EndpointSource contract feeds an existing pipeline with recipients and secrets.
Safe destinations
URLs validated at registration, addresses re-resolved and pinned per connection, no redirects.
Nothing implicit
No connections, migrations, or workers start on their own. You own the pool and the process.
Pick a setup
Endpoint management and delivery are separate pieces. Take both, or just the one you are missing.
Run a complete application
Two applications in the repository install the published package and show the full path from a business action to a verified webhook. Copy either one into your own project, or receive signed webhooks right away in the hosted Playground.
Start here
Send your first signed webhook in five minutes.
One file publishes an event and a local receiver verifies it. Nothing to sign up for.