Installation
Add Good Webhooks to an existing application. Install, create a key and the tables, and connect.
Requirements: Node.js 24 or later, and PostgreSQL 16 to 19 for delivery and standalone endpoint management. TypeScript needs 5.9.3 or later with moduleResolution set to NodeNext or Bundler. Edge runtimes are not supported.
Install
npm install good-webhooks pg zodnpm install --save-dev @types/pgPayload schemas can use any Standard Schema library; these docs use Zod.
Create a storage key
This key encrypts endpoint signing secrets in your database. Generate it once:
node -e 'import("good-webhooks").then(m => console.log(m.generateEncryptionKey()))'Store the output in your secret manager or .env as WEBHOOK_ENCRYPTION_KEY. Every process that sends or manages webhooks needs the same key.
Create the tables
Write the SQL to a migration file, then apply it with your migration tool or psql:
node -e 'import("good-webhooks/migrations").then(m => process.stdout.write(m.getPostgresMigration()))' > 001-webhooks.sql
psql "$DATABASE_URL" --single-transaction -v ON_ERROR_STOP=1 -f 001-webhooks.sqlThe tables are prefixed webhook_ and go in public. To use another schema, see migrations.
Create the client
import { createWebhooks } from 'good-webhooks'
import { Pool } from 'pg'
import { z } from 'zod'
export const pool = new Pool({ connectionString: process.env.DATABASE_URL })
export const webhooks = createWebhooks({
database: pool,
encryptionKey: process.env.WEBHOOK_ENCRYPTION_KEY!,
events: {
'invoice.paid': z.object({ invoiceId: z.string(), amount: z.number().int() }),
},
})Check the schema at startup. It throws SCHEMA_MISMATCH if the tables are missing or outdated:
await webhooks.check()Nothing is sent yet: that takes a published event and a running worker.
Publish events
Define your event catalog and publish from your app.
Run a worker
Start the process that sends and retries.
Manage endpoints
Register where events go.
Receive webhooks
Verify signatures on the receiving side.
Each process imports only the entry point it needs, so a receiver never loads database code.