Human guide
Read the reasoning behind raw-body verification, durable acknowledgement, deduplication, retries, and provider registration.
Rails Implementation Guide · $12
Receiving a webhook is easy. The code that still works when it arrives twice, arrives out of order, or fails halfway through is where things get interesting.
The guide is written for a human who needs to understand the boundaries. The companion gives a coding agent explicit contracts, examples, and review questions to consult while it extends an existing Rails application.
Six chapters + debugging appendix · PDF, EPUB, and HTML · Agent Companion included
The guide and the companion
Webhooks in Rails is a human guide first. It walks through the request boundary, the delivery record, the job, and the handler so you can make the tradeoffs deliberately.
The Agent Companion turns those decisions into small, inspectable entrypoints: contracts to check, recipes to adapt, examples to compare, and a review checklist for the work that comes back.
It is for brownfield Rails work. Start with the application you already have, map its conventions, and adapt the companion’s patterns. This is context for an agent, not a promise that an unfamiliar codebase can accept a drop-in patch.
Read the reasoning behind raw-body verification, durable acknowledgement, deduplication, retries, and provider registration.
Give a capable agent explicit places to look before it changes a webhook flow, with room for you to review every boundary.
The POST is the easy part
Signatures are calculated over raw bytes. Parse too early or compare the wrong thing and a valid request looks fake.
Provider retries and queue retries happen on opposite sides of your successful HTTP response. The handoff needs to be durable.
Webhook delivery is at-least-once. Use a real database uniqueness boundary instead of hoping an exists? check wins a race.
Received is not processed. A failed job should leave enough state to retry the work instead of accidentally skipping it forever.
One Rails shape, two providers
Stripe-SignatureStripe::Webhook.construct_eventX-Hub-Signature-256request.raw_postX-GitHub-Delivery as the delivery identifierWhat's inside
Machine endpoints, raw request bodies, acknowledgement boundaries, and why duplicate delivery is normal.
Verify Stripe signatures, persist a durable delivery, hand work to Active Job, and keep the HTTP response fast.
Separate received from processed, close concurrency races with database constraints and locks, and keep failures retryable.
Calculate HMAC-SHA256 over the exact request body, use delivery GUIDs correctly, and dispatch verified events.
Create, update, and remove provider-side hooks through Octokit without pretending two systems share a transaction.
Request specs for signatures and malformed bodies, job retry specs, WebMock, and provider registration tests.
The appendix follows one delivery from the provider dashboard through Rails and Solid Queue, covers tunnels and replay, and shows where an inspection tool such as CatchHook fits without making the architecture depend on it.
What $12 includes
AGENTS.md and CLAUDE.md entrypointsWhat the guide cares about
The examples separate delivery identity from business-object identity, put a UNIQUE index behind deduplication, mark work processed only after it succeeds, and keep remote API calls outside database locks.
It also covers out-of-order events, payload retention, idempotency for external side effects, explicit operator retries, and why provider registration has its own failure lifecycle.
received
↓
processing
├──→ processed
└──→ failed
↓
retryWebhooks in Rails
Six focused chapters, a debugging appendix, and an Agent Companion with contracts, provider recipes, examples, review checks, and AGENTS.md / CLAUDE.md entrypoints.