DSamuelHodge

payload plugin outbound webhooks

by DSamuelHodge
Jobs & automation
v3
^3.0.0
MIT

Overview

Summary generated from the README

Fires signed HTTP callbacks when documents in chosen collections are created, updated or deleted. Deliveries run through Payload's Jobs Queue with retries and a circuit breaker, so a job runner must be configured. Endpoints can be set in config or managed from an admin collection, and a delivery log records each attempt. Requires Payload 3.

Features

  • Per-collection event selection with optional filter function to decide which changes fire
  • Endpoints defined in config or managed in an admin collection, with wildcard subscriptions like orders.*
  • HMAC-SHA256 signed requests with a timestamp and a verification helper for receivers
  • At-least-once delivery with retry classification for transient and permanent failures
  • Circuit breaker that auto-disables failing endpoints, with half-open probes for static ones
  • Delivery log collection recording status, response code and errors

Use cases

  • Connect Payload to Zapier, Make or n8n workflows when documents change
  • Sync orders or content to a CRM or other external service
  • Notify downstream systems only when a post becomes published

From the author

Generic outbound webhooks for Payload CMS: fire signed HTTP callbacks on collection create/update/delete, delivered durably via the Jobs Queue.

Installation

npm i payload-plugin-outbound-webhooks

0

Stars

0

Forks

0

Open Issues

2 months ago

Last Updated

6

Weekly Downloads

v0.3.5

npm Version

57.8 KB

Unpacked Size

0

Dependencies

GitHub stars

00 since Sep 20

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260
Nov 21, 20260
Nov 20, 20260
Nov 19, 20260
Nov 18, 20260
Nov 17, 20260
Nov 16, 20260
Nov 15, 20260
Nov 14, 20260
Nov 13, 20260
Nov 12, 20260
Nov 11, 20260
Nov 10, 20260
Nov 9, 20260
Nov 8, 20260
Nov 7, 20260
Nov 6, 20260
Nov 5, 20260
Nov 4, 20260
Nov 3, 20260
Nov 2, 20260
Nov 1, 20260
Oct 31, 20260
Oct 30, 20260
Oct 29, 20260
Oct 28, 20260
Oct 27, 20260
Oct 26, 20260
Oct 25, 20260
Oct 24, 20260
Oct 23, 20260
Oct 22, 20260
Oct 21, 20260
Oct 20, 20260
Oct 19, 20260
Oct 18, 20260
Oct 17, 20260
Oct 16, 20260
Oct 15, 20260
Oct 14, 20260
Oct 13, 20260
Oct 12, 20260
Oct 11, 20260
Oct 10, 20260
Oct 9, 20260
Oct 8, 20260
Oct 7, 20260
Oct 6, 20260
Oct 5, 20260
Oct 4, 20260
Oct 3, 20260
Oct 2, 20260
Oct 1, 20260
Sep 30, 20260
Sep 29, 20260
Sep 28, 20260
Sep 27, 20260
Sep 26, 20260
Sep 25, 20260
Sep 24, 20260
Sep 23, 20260
Sep 22, 20260
Sep 21, 20260
Sep 20, 20260
npm weekly downloads

3−552 since Sep 23

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20263
Dec 4, 20263
Dec 3, 20263
Dec 2, 20266
Dec 1, 20268
Nov 30, 20268
Nov 29, 20267
Nov 28, 20267
Nov 27, 20267
Nov 26, 20267
Nov 25, 20268
Nov 24, 20266
Nov 23, 202611
Nov 22, 202613
Nov 21, 202613
Nov 20, 202613
Nov 19, 202614
Nov 18, 202612
Nov 17, 202612
Nov 16, 20269
Nov 15, 20268
Nov 14, 20268
Nov 13, 20269
Nov 12, 202612
Nov 11, 20269
Nov 10, 20269
Nov 9, 202610
Nov 8, 202610
Nov 7, 202615
Nov 6, 202619
Nov 5, 202616
Nov 4, 202616
Nov 3, 202618
Nov 2, 202619
Nov 1, 202618
Oct 31, 202615
Oct 30, 20269
Oct 29, 20268
Oct 28, 20268
Oct 27, 20267
Oct 26, 20269
Oct 25, 202611
Oct 24, 202611
Oct 23, 202611
Oct 22, 202616
Oct 21, 202621
Oct 20, 202621
Oct 19, 202615
Oct 18, 202614
Oct 17, 202613
Oct 16, 202615
Oct 15, 202616
Oct 14, 202611
Oct 13, 202614
Oct 12, 202615
Oct 11, 202615
Oct 10, 202624
Oct 9, 202626
Oct 8, 202623
Oct 7, 202627
Oct 6, 202623
Oct 5, 202625
Oct 4, 202638
Oct 3, 202637
Oct 2, 202644
Oct 1, 202682
Sep 30, 2026108
Sep 29, 2026663
Sep 28, 2026660
Sep 27, 2026646
Sep 26, 2026637
Sep 25, 2026626
Sep 24, 2026585
Sep 23, 2026555

Each point is npm's rolling 7-day download count.

Health Score

59/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1378504171-root.svg)](https://payloaddirectory.dev/plugins/1378504171-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1378504171-root"><img src="https://payloaddirectory.dev/badge/1378504171-root.svg" alt="Payload Directory"></a>
Updated Sep 20, 2026Created Sep 20, 2026Published Sep 20, 2026

README

payload-plugin-outbound-webhooks

npm version test License: MIT

Generic outbound webhooks for Payload CMS. Fire signed HTTP callbacks whenever documents in chosen collections are created, updated, or deleted — delivered through Payload's Jobs Queue so it's non-blocking and durably retried.

Why

Payload doesn't ship a generic "POST to a URL on document change" mechanism. This plugin adds one, aimed at wiring Payload into Zapier/Make/n8n, syncing to a CRM, or notifying any external service.

Install

pnpm add payload-plugin-outbound-webhooks
// payload.config.ts
import { outboundWebhooksPlugin } from 'payload-plugin-outbound-webhooks'

export default buildConfig({
  // ...
  jobs: {
    // Required: the plugin delivers via the Jobs Queue, so it needs a runner.
    autoRun: [{ cron: '*/10 * * * * *', limit: 10, queue: 'default' }],
  },
  plugins: [
    outboundWebhooksPlugin({
      collections: {
        posts: { events: ['create', 'update'] },
        orders: {},
      },
      endpoints: [
        {
          label: 'CRM sync',
          url: 'https://example.com/hooks/payload',
          subscriptions: ['orders.*'],
          secret: process.env.WEBHOOK_SECRET,
        },
      ],
    }),
  ],
})

Managing endpoints from the admin UI

By default the plugin adds a webhookEndpoints collection so editors can add, disable, or remove destinations without a deploy. Set enableEndpointsCollection: false to turn this off and rely solely on the endpoints array in your config.

Endpoints from both sources are merged at delivery time and matched against a collection.event string, e.g. orders.create. Use * as a wildcard on either side: orders.* matches every event on orders; *.delete matches deletes on any watched collection.

Delivery log

A webhookLogs collection records every delivery attempt (status, HTTP response code, error). Set enableDeliveryLog: false if you don't want the extra collection.

Filtering which changes fire a webhook

posts: {
  events: ['update'],
  filter: ({ doc, previousDoc }) =>
    doc.status === 'published' && previousDoc?.status !== 'published',
}

Payload sent to your endpoint

{
  "deliveryId": "b6b6e1c2-...",
  "event": "orders.create",
  "collection": "orders",
  "docId": "64f...",
  "doc": { "...": "the full document" },
  "previousDoc": { "...": "present on update events" },
  "occurredAt": "2026-09-19T20:00:00.000Z"
}

docId mirrors your collection's id type (string or number). deliveryId is generated once per triggering event (create/update/delete) and stays the same across every retry of that delivery — use it as your idempotency/dedupe key. Every request carries Content-Type: application/json, an X-Webhook-Event header (e.g. orders.create), and an X-Webhook-Id header mirroring deliveryId (so you can dedupe without parsing the body), plus X-Webhook-Signature when the endpoint has a secret set.

Delivery guarantees

Delivery is at-least-once, with retries classified by failure type:

  • Retryable failures — network errors, timeouts, and HTTP 5xx/408/429 responses — fail the job so Payload's Jobs Queue retries it, up to maxRetries times (default 5).
  • Permanent failures — any other 4xx response (bad URL, revoked auth, endpoint deleted, etc.) — are logged but not retried, since resending the identical request would fail the same way every time.

On a retry, only endpoints still pending are re-attempted: endpoints that already succeeded or permanently failed for that deliveryId are skipped (tracked via the webhookLogs collection, so this requires enableDeliveryLog to stay on). Because a retry can still redeliver to an endpoint that failed with a transient error, receivers should dedupe on deliveryId (or the X-Webhook-Id header) rather than (event, docId).

Circuit-breaker

Retries are per-delivery; the circuit-breaker protects you across deliveries. After failureThreshold consecutive failures (default 5, set to 0 to disable), an endpoint is automatically disabled so a dead destination stops burning job retries:

  • Admin-managed endpoints (webhookEndpoints collection) keep a persistent consecutiveFailures counter on their doc. Any success resets it; reaching the threshold sets autoDisabled, and delivery skips the endpoint from then on. This works even with enableDeliveryLog: false. To re-enable, fix the destination and uncheck autoDisabled in the admin UI — a beforeChange hook zeroes consecutiveFailures at the same time, so the endpoint gets a fresh run at the threshold instead of re-tripping on the next single failure.
  • Static endpoints (the endpoints array) have no doc to store a counter on, so the breaker reads their recent delivery history instead: if the last failureThreshold attempts for that URL all failed, the endpoint is skipped for this delivery (reported as skipped in the job output). This requires enableDeliveryLog to stay on — with the log disabled there is no history to read, so static endpoints are attempted every time (same caveat as retry-skip above). Tripped static endpoints self-heal via a half-open probe: once breakerProbeIntervalMs (default 5 minutes) has passed since the last attempt, one delivery is let through. If it succeeds, the streak is broken and normal delivery resumes; if it fails, the endpoint stays tripped and the cooldown restarts. To force an immediate retry instead of waiting out the cooldown, delete that URL's recent webhookLogs rows.

Both retryable (5xx, timeouts) and permanent (4xx) failures count toward the streak — a 404 from a deleted destination trips the breaker just like a 500 storm does.

Verifying the signature

If an endpoint has a secret set, requests include an X-Webhook-Signature header formatted as t=<unix timestamp>,v1=<hmac-sha256 hex digest>, signed over ${timestamp}.${rawBody}. Verify it on the receiving end:

import { verifyPayloadSignature } from 'payload-plugin-outbound-webhooks'

const isValid = verifyPayloadSignature({
  body: rawRequestBody, // the exact bytes received, before JSON.parse
  header: req.headers['x-webhook-signature'],
  secret: process.env.WEBHOOK_SECRET,
})

The helper also rejects signatures older than 5 minutes by default (toleranceSeconds), to blunt replay attacks.

Options reference

OptionTypeDefaultDescription
enabledbooleantrueDisable without removing from the plugins array.
collections{ [slug]: CollectionWebhookConfig }—Which collections/events to watch, required.
endpointsWebhookEndpoint[][]Statically configured destinations.
enableEndpointsCollectionbooleantrueAdds the webhookEndpoints admin collection.
enableDeliveryLogbooleantrueAdds the webhookLogs admin collection.
maxRetriesnumber5Job retry attempts per delivery.
failureThresholdnumber5Consecutive failures before an endpoint is auto-disabled (0 disables).
breakerProbeIntervalMsnumber300000Cooldown before a tripped static endpoint gets a half-open probe (0 probes every delivery).
timeoutMsnumber10000Per-attempt request timeout.

Development

pnpm install
pnpm test       # unit tests (src/**/*.spec.ts, no database needed)
pnpm test:int   # integration tests (needs DATABASE_URI, see below)
pnpm typecheck
pnpm build      # emits dist/ (the published artifact)

Integration tests boot the dev/ Payload harness (example posts + orders collections, local receiver on :4000) and need a Postgres database:

export DATABASE_URI=postgres://user:pass@localhost:5432/webhooks_plugin_test
pnpm test:int

License

MIT

Similar plugins