Custom senders
Keep your own delivery pipeline and use Good Webhooks endpoint management as its source of recipients and signing secrets.
Already have a queue that sends HTTP requests? Keep it, and use Good Webhooks only for endpoint management. Both providers expose management.source, an EndpointSource with the two reads a sender needs:
import type { EndpointSource } from 'good-webhooks/management'
// interface EndpointSource {
// matchRecipients(scope, eventType): Promise<readonly string[]>
// resolveEndpoint(scope, endpointId): Promise<
// | {
// status: 'active'
// url: string
// secrets: readonly string[]
// revision?: string
// headers?: Record<string, string>
// }
// | { status: 'paused' | 'deleted' }
// >
// pause?(scope, endpointId, { reason, revision }): Promise<boolean>
// }scope is null for application scope or { type, id }. The source returns plaintext signing secrets, so keep it in trusted server code. The built-in sources return the endpoint's decrypted headers when it has some. Send them with each attempt, under the signature headers.
A custom source may return headers too, and the built-in worker sends them on every attempt. It refuses reserved names (webhook-*, content-type, user-agent, and hop-by-hop names) and defers the delivery like a failed lookup.
Capture recipients once
When you accept an event, call matchRecipients() and store the complete list with it, paused endpoints included. On a repeat of the same event, reuse the stored list.
A rejected lookup is a failure, not "no recipients". Never store a partial list.
Resolve before every attempt
const endpoint = await source.resolveEndpoint(scope, endpointId)
if (endpoint.status === 'active') {
// Send to endpoint.url, signing with every secret in endpoint.secrets.
} else if (endpoint.status === 'paused') {
// Keep the delivery queued, within your expiry policy.
} else {
// Deleted or missing: cancel this delivery.
}Do this for retries too. The URL and secrets from publish time may be stale.
Sign and send safely
- Sign with the Standard Webhooks format, once per secret in
secrets, so receivers keep working during a rotation. The new secret comes first. - Add the resolution's
headers, if any, before the signature headers, so the signature headers win. - Keep the event ID and body identical across retries and replays.
- Before each connection, resolve the hostname, reject private and otherwise unsafe addresses, connect to the checked address with TLS hostname checks, and refuse redirects.
To pause endpoints that keep failing, as the built-in worker does, call source.pause(scope, endpointId, { reason: 'failing', revision }) with the revision from the resolution your failed attempts used. It pauses only if the endpoint hasn't changed since, and the owner sees pauseReason: 'failing'.
Durable queuing, bounded retries, attempt history, retention, and concurrency limits are also yours. If that list is longer than you want, connect the built-in delivery to the same source instead.
To keep the endpoint lifecycle API but store endpoints somewhere else, implement the ManagementRepository contract and pass it to createManagement(). Its create receives the limit as { limit }, and it must store encryptedHeaders and return it unchanged.