I hate seeing the same work done over and over. Receiving webhooks should be a solved problem, yet every team that takes them still builds its own receiver. Catching a webhook looks easy: expose a URL, read the body, and answer with the status code your contract with the sender calls for. Keeping that contract through broker outages, oversized payloads, and customers who run past their usage is where each and every team learns the same lessons the hard way.
I also learned those lessons as a founding engineer at Zapier. After I left, it was a problem that kept tickling my brain, so with a couple of weeks of free time on my hands I set about building Ankusa, an open source framework that makes durable webhook ingestion painless. It is written in Elixir, and it is a project I have wanted to build for a long time.
I already knew that building something like this can go very deep: optimizations, reliability paths, replay architecture, claim checks, etc. Each of those deserves its own post! For this one, I’ll stick to my motivations and an overview for anyone who wants to get started today.
Why I built it
Four lessons from scaling webhook ingestion at Zapier shaped Ankusa:
- A messaging bus outage cannot be allowed to cost you hooks. In the early days there were times our RabbitMQ cluster crashed and we lost thousands of them. That led us to journal hooks to disk on inbound HTTP servers and resubmit them once the bus was back up. Ankusa starts from the journal: it writes every hook to a durable local store before the provider gets its
201, and publishes to the broker afterwards, with retries. - Large payloads cannot transit the messaging bus in most setups. We learned that early, once webhooks crossed RabbitMQ’s maximum message size. In Ankusa, a body over the
inline_max_byteslimit goes to an object store and the message carries a small reference in its place, the claim check pattern. - You need to be able to replay webhooks during downstream outages. Ankusa retries each delivery with backoff, for 24 hours by default, then moves it to a dead-letter queue that one API call replays.
- You need to be able to throttle, or put a hold on, webhooks ingested past a customer’s usage. In Ankusa each customer is a tenant with a quota in hooks per second, and optionally in bytes. A sender past it gets
429withRetry-After, and you can change a tenant’s limit at runtime through the admin API.
These challenges came back to mind when I wrote the Advent of Enterprise Integration Patterns last year. I used durable webhook handling at scale as an example and it expanded organically into two dedicated posts: Day 7 went from a synchronous API to a webhook platform, and Day 8 added retries, dead letter queues, circuit breakers, and claim checks.
The last reason is the oldest. Ever since I learned Elixir, I have wanted to build a webhook ingestion framework with it. Elixir runs on the Erlang VM, and Erlang was built to run telephone switches. Processes are cheap enough to spawn one per call. They share nothing and talk only by passing messages. When one crashes, a supervisor restarts it and the rest keep going. Swap “call” for “webhook” and that is the system I wanted. Those building blocks are more relevant than ever! Back in 2024 I called Elixir a language I always admired but seldom got to work in. This is that framework.
The name
अंकुश (aṅkuśa) is Sanskrit for “hook” or “goad”: the curved tool a mahout uses to steer an elephant. I thought it was apt. Webhook traffic at scale stampedes at your systems like a herd of elephants, and the goal is to steer it. So the framework does two things: it absorbs the traffic durably and fast, then steers where it goes next through routing and dispatch. The boot banner prints the tagline: “Don’t fight the traffic. Steer it.”

What Ankusa is
Ankusa is Apache 2.0 licensed and runs as a self-hosted container in front of your workers. Point Stripe, GitHub, Shopify, or any service that sends webhooks at it, and every webhook becomes a message on the broker you already run: Kafka, RabbitMQ, NATS JetStream, SQS, Google Pub/Sub, or Redis pub/sub. If you prefer HTTP, it POSTs signed deliveries to your service. Ankusa calls each of those destinations a sink.
Ankusa’s contract with the provider is that a 201 means the hook is stored somewhere that survives the failure you are worried about. Which “somewhere” is one config key, wal.type:
wal.type | 201 means | An acked hook survives |
|---|---|---|
disk (default) | fsynced in this node’s local store | a process crash and power loss on this host |
dual | fsynced here and confirmed in a Kafka intake log | the loss of this host, unless every in-sync replica of the log is lost with it |
none | every sink confirmed, inside the request | whatever the sink durably holds |
In every mode, a node that cannot keep that contract answers 503 with Retry-After, and the provider retries.

Ingest (the edge in the diagram) and delivery (dispatch) are decoupled after the accept. Dispatch is a scheduler over rows in the store, so a slow sink never stops the edge from acking.
Erlang’s processes and supervisors show up in two places in that design. Batcher processes collect hooks as they arrive, and a writer commits the waiting batches in one synced write, so a burst of hooks shares one fsync. The supervision tree doubles as a list of failure domains: a sink that keeps crashing stops dispatch while the edge keeps acking, and hooks wait in the store until dispatch returns.
Start small: one container
One container is a complete receiver, and it keeps its working state in one data volume. That is all a startup taking Stripe events needs:
export ANKUSA_ADMIN_TOKEN=$(openssl rand -hex 32) # the admin API needs a credential off loopback
docker run -d --name ankusa \
-p 4000:4000 -p 127.0.0.1:4002:4002 -e ANKUSA_ADMIN_IP=0.0.0.0 -e ANKUSA_ADMIN_TOKEN \
-v ankusa-data:/var/lib/ankusa \
jamescarr/ankusa:edge
# the image ships a healthcheck: wait for it rather than racing the listener
until [ "$(docker inspect --format '{{.State.Health.Status}}' ankusa)" = healthy ]; do sleep 1; done
curl -XPOST localhost:4000/webhooks/demo -H 'content-type: application/json' -d '{"id":"evt_1"}'
# => {"id":"01a0...","status":"accepted"} (returned only after the store fsync)
Port 4000 is ingest, 4002 is the admin API, and /var/lib/ankusa holds the only state worth keeping. The image’s default config declares a demo source that accepts anything, so this works before you have provider credentials.
Configuration is one YAML file mounted at /etc/ankusa/ankusa.yml, and a real provider is one more source in it:
node:
roles: [edge, dispatch, storage]
data_dir: /var/lib/ankusa
admin:
enabled: true
sources:
stripe:
tenant: default
verify:
type: stripe
secret: "${STRIPE_WHSEC}"
tolerance_seconds: 300
# A rotated secret should not silently eat real events: hold them instead.
on_verify_failure: quarantine
sinks:
- type: http
url: "${SINK_URL}"
method: post
secret: "${SINK_WHSEC}"
timeout_ms: 5000
headers:
x-ankusa-source: stripe
verify.type: stripeis a preset. There are presets for GitHub, Shopify, Slack and Standard Webhooks. Ankusa also verifies any HMAC scheme described in config, Ed25519 or RSA signatures, bearer tokens and mTLS client certificates.on_verify_failure: quarantineholds a hook that fails verification instead of dropping it. Once the secret is fixed, you release the held hooks with one replay.type: httpPOSTs the raw body to your endpoint, signed withSINK_WHSEC.
The configuration docs have the full file and other starting points, and the quickstart walks through pointing a real provider at Ankusa.
To see what the store buys you, clone the repo and go to examples/http-consumer, which runs the image next to a small FastAPI worker. Remove the first container with docker rm -f ankusa, because the example uses the same ports. Then start it with docker compose up --build -d --wait and run the long-outage drill:
docker compose stop worker
curl -XPOST localhost:4000/webhooks/demo -H 'content-type: application/json' -d '{"id":"evt_3"}'
sleep 20
curl -s localhost:4002/v1/dlq
# => {"total":1,"entries":[{"id":"01a0...","source_id":"demo",...}]}
docker compose start worker
curl -XPOST localhost:4002/v1/replays -d '{"kind":"dlq","source_id":"demo","rate":100}'
# => 202 {"id":"01a0...","kind":"dlq","state":"running","filter":{"source_id":"demo"},...}
sleep 1 && docker compose logs worker | grep evt_3
The provider still got its 201 while the worker was down, and the hook landed in the dead-letter queue. The replay that delivered it is a durable, rate-limited job you can cancel. This example caps retries at 6 attempts so the drill takes seconds.

The worker is still an HTTP endpoint, but a private one that only Ankusa calls, so it can be down or mid-deploy without the provider noticing. It returns 2xx when the work is done, and 5xx, 409 or 429 when the delivery should be retried. A permanent 4xx such as 422 is only for a hook that should go straight to the dead-letter queue and wait for a replay.
Add a broker when you outgrow HTTP
When more than one worker needs the same hooks, fan them out through a broker. The source stays as it is and only the sink changes:
sinks:
- type: rabbitmq
url: "${RABBITMQ_URL}"
exchange: "${RABBITMQ_EXCHANGE}"
exchange_type: topic
routing_key: "ingestion.stripe"
inline_max_bytes: 8192
Ankusa publishes to the exchange and never declares a queue. Each consumer owns its queue and binding, and unlike the HTTP worker it has no endpoint to expose.
The first Zapier lesson applies here. With the broker down, ingest keeps answering 201, because the ack never depended on the broker. Ankusa retries deliveries, and after 5 failures in a row the sink’s circuit breaker parks its hooks without spending attempts.
inline_max_bytes: 8192 is where the claim check starts in this config (the default is 64 KiB). Ankusa writes a larger body to the object store, and the message carries a reference and a sha256. The worker redeems it with one HTTP GET at the claim-check gateway and never holds bucket credentials. I argued for a gateway in front of claim checks in The Route Table Is the Contract. Ankusa ships one, and it gets its own post.
There are worker SDKs for TypeScript, Python, Go, Rust, Ruby, PHP, Elixir, Java and Clojure. They parse the delivery headers, decode queue messages and redeem claims, and all nine pass one shared conformance suite.

Kafka, NATS JetStream and SQS have runnable examples too, listed at the end.
Scale out: fleets, tenants, regions
At the scale of a Zapier or a Salesforce you have more hooks than one machine can take, a catch URL for every customer, and more than one region.
A fleet is more of the same container behind a load balancer. Each node runs every role and has its own volume, store, dead-letter queue and admin API. Nodes share nothing but the provider’s traffic, and optionally Redis for routes, sources, and fleet-wide rate limits and dedupe. If you would rather keep no state on the nodes, wal.type: none nodes scale like any stateless web app. The cost is no retry policy and no replay: the provider’s retry on a 503 is the only retry.
The Helm chart in deploy/helm/ankusa reads wal.type and renders a StatefulSet with a volume per pod for disk and dual, or a Deployment with an HPA for none. These are the chart’s values for a dual fleet, the mode that survives the loss of a host:
wal: {type: dual}
replicas: 3
perPodKeyPrefix: true
persistence: {size: 50Gi}
config:
storage:
type: s3
s3: {bucket: ankusa-segments, region: eu-west-1}
intake:
type: kafka
fleet: eu
kafka: {brokers: ["kafka-1:9092", "kafka-2:9092", "kafka-3:9092"]}
backup:
enabled: true
interval_ms: 60000
max_age_ms: 300000
secondary:
type: s3
s3: {bucket: ankusa-backups-dr, region: eu-central-1}
The same sources: block from earlier goes under config:, and helm install ankusa deploy/helm/ankusa -f my-values.yaml installs it. When a host is lost, a replacement node that starts on an empty volume with the lost node’s id restores the latest backup and replays the intake log.
Tenants are a routing mode plus a quota each:
http:
routing: tenant_path
prefix: /webhooks
rate_limits:
# Required with routing: tenant_path. The URL names the tenant, so without a
# default every tenant not listed here would have no limit at all. Per node:
# a fleet of N edges admits up to N x this.
default: {rate: 50, burst: 100}
tenants:
# A tenant of its own: more hooks, a body cap, and the most it may hold in
# this node's queues at once (past it: 429 tenant_overload, not 503).
acme: {rate: 500, burst: 1000, max_body_bytes: 1000000, max_queue: 2000}
routing: tenant_path makes the catch URL /webhooks/<tenant>/<source>, so one Stripe source serves every customer. A tenant with max_queue set, like acme, gets 429 tenant_overload past its share of the batchers, so the tenants still within theirs never see a 503 it caused. Dispatch shares delivery fairly between tenants too. rate_limits.scope: fleet moves the quota into Redis so N nodes enforce one limit. The full file is multi-tenant.yml, and docs/multi-tenancy.md covers the rest.
Past one region, the unit is a regional fleet. Each region runs its own fleet, intake topic and bucket, and a global load balancer pins each tenant to a home region. Nothing replicates between regions except backups.

Two of the examples run fleets. examples/fleet-e2e is a two-node fleet that CI runs every night: it kills a node mid-run and checks that every acknowledged hook was processed. examples/jetstream-k8s puts a stateless fleet and a durable fleet on a local kind cluster, with a control panel that kills pods and cuts connections on request.
BTW, the 69-task hardening checklist I ran through my plan loop in October was Ankusa’s.
The patterns underneath
The diagrams above come from the Ankusa docs and are drawn in Enterprise Integration Patterns notation, so each legend is also a pattern list. These are the ones you meet first:
| Pattern | In Ankusa |
|---|---|
| Message Store | the node’s local store, where every hook lands before the 201 |
| Dead Letter Channel | the dead-letter queue, listed and replayed through the admin API |
| Claim Check | bodies over inline_max_bytes, sent as a reference |
| Idempotent Receiver | your worker, keyed on x-ankusa-idempotency-key |
| Content-Based Router | sink filters and topic names driven by the event type |
| Control Bus | the admin API on port 4002 |
What it does not do
- Delivery is at-least-once. A hook can arrive twice after a retry, so your worker dedupes on the idempotency key that comes with every delivery.
- A
disknode is durable to power loss on that host only. Losing the host loses the hooks acked since the last backup, which is the gapdualcloses. - It cannot help with a provider that does not retry on a timeout or a
5xx. - It is 0.x, and the APIs may change.
Pick an example and build
Those lessons took us years at Zapier, and I built Ankusa so the next team gets them from a config file.
There are nine runnable examples, and each one ends in a worker you can replace with your own service:
| Example | Delivers via | Worker | Shows |
|---|---|---|---|
http-consumer | HTTP | Python | signed deliveries to your own service, dead letters, replay |
quickstart | Kafka → SQS FIFO | Python | a consumer-owned queue, claim checks, replay |
rabbitmq-consumer | RabbitMQ | TypeScript | consumer-owned queues, claim checks |
kafka-sqs-consumer | Kafka → SQS FIFO | TypeScript | the SQS FIFO handoff and three failure drills |
event-routing | Kafka topic by event type, filtered HTTP | TypeScript | routing by content with no code |
nats-consumer | NATS JetStream | Rust | a consumer-owned stream and the Rust SDK |
oban-consumer | HTTP → Oban on Kubernetes | Elixir | three nodes on kind, pods killed mid-run |
fleet-e2e | RabbitMQ, two nodes behind nginx | TypeScript | the nightly multi-node run |
jetstream-k8s | NATS JetStream on kind | TypeScript | two fleets and a browser control panel |
Start with http-consumer, the one from the drill above.
If you write Elixir, Ankusa is also a Hex library. Add {:ankusa, "~> 0.7"} and the same pipeline runs inside your own supervision tree, with your own sinks, verifiers and route resolvers as behaviours documented on HexDocs.
Everything else, from every YAML key to the alert runbooks, is in the docs.