Black Friday Offer: Get 50% OFF Starter & Basic Yearly Plans 🎉

Open Source Webhook Management for AI Video Pipelines

Oct 1, 2026

Why Webhooks Are the Backbone of AI Video Workflows

Every serious video generation pipeline eventually hits the same wall: the work takes minutes, not milliseconds. A text prompt becomes a storyboard, a storyboard becomes keyframes, keyframes become a sequence of short clips, and each of those clips may need upscaling, frame interpolation, audio alignment, and a final mux. No HTTP request should stay open that long, and no client should be polling every two seconds to find out whether anything changed.

Webhooks solve this by inverting control. Instead of your application asking "is it done yet?", the rendering service tells your application what happened, when it happened, and what to do next. That single inversion changes the shape of your architecture: you stop writing polling loops and start writing event handlers, state machines, and coordinators.

The open source angle matters because event plumbing is exactly the kind of infrastructure you should own. Webhook receivers, signature verification, retry queues, dead letter stores, and delivery dashboards are all well served by mature open source components. You can inspect them, self-host them, and adapt them to the quirks of video workloads — large payloads, long-running jobs, and multi-stage dependencies that generic webhook tools were never designed to model.

There is also a practical argument. Video generation is a fast-moving space. Models appear, change capability sets, and disappear. If your integration logic is glued to a vendor SDK, every change becomes a migration. If it is built around a stable event contract you control, a model swap is a configuration change.

This guide walks through a complete approach: how events flow, which components to choose, how to design payloads that survive change, how to secure inbound traffic, and which reliability practices separate a weekend demo from a production system.

How an Asynchronous Video Pipeline Actually Flows

The request-acknowledge pattern

The canonical pattern has three beats. First, your application submits a job to a generation service and receives an immediate acknowledgement containing a job identifier. Second, the generation service does the work and fires one or more webhook events back to an endpoint you control. Third, your handler validates the event, updates state, and decides what happens next — publish the asset, kick off the next stage, or notify a human.

The acknowledgement is not the result. Treat it as a receipt. Store the job identifier, the chosen model, all parameters, and a correlation identifier that ties the original request to every downstream event. If you skip that last part, you will find yourself debugging a forty-minute render with no way to connect the finished asset back to the prompt that created it.

Event types worth modelling

A small, well-chosen event vocabulary beats a sprawling one. Most pipelines need:

  • job.queued — the work has been accepted and scheduled.
  • job.progress — optional, but useful for long renders and user-facing progress bars.
  • job.completed — output artifacts are available, with URLs and metadata.
  • job.failed — includes an error code, a human-readable message, and whether retrying could help.
  • job.cancelled — the work stopped because someone asked it to.

Resist the temptation to emit an event for every internal state transition. Every event type is a contract you must maintain, version, document, and test. Five stable events outperform thirty unstable ones.

The job state machine

Write down the states before you write code: draft → queued → running → post_processing → completed, with failed and cancelled reachable from the middle states. Handlers should only be allowed to move a job forward along legal transitions. If a job.completed event arrives for a job already marked completed, that is not an error — it is a duplicate, and it should be ignored rather than applied twice.

Modelling transitions explicitly also gives you free diagnostics. When something goes wrong, "job 8871 jumped from queued to completed without passing running" is a far more actionable log line than a stack trace from a null reference.

Choosing Open Source Building Blocks

Ingress: receiving events safely

Your ingress layer needs to do four things quickly: verify the signature, parse the body, persist the raw event, and return a fast success response. Frameworks with first-class middleware and dependency injection make this pleasant — NestJS, FastAPI, Laravel, and Rails all have established patterns for it. The important architectural rule is that the endpoint should do almost nothing else. Heavy work belongs behind a queue.

Persist the raw payload before you interpret it. When a schema change breaks a handler at three in the morning, having the original bytes on disk is the difference between a five-minute fix and a two-day investigation.

Keep responses fast and unambiguous. Return 2xx only when you have durably stored the event. Return 4xx when the request is malformed or the signature is invalid — replays will not help. Return 5xx only when you want the sender to retry, which means transient failures such as a database blip. Getting these codes right is a large part of building a well-behaved integration.

Queue and workers

Once the event is durable, hand it to a queue. Redis-backed queues, RabbitMQ, NATS, and PostgreSQL-based queues all work. Choose based on two criteria: whether you need ordered processing per job, and how much operational complexity you can tolerate.

For video pipelines, per-job ordering usually matters. Two events for the same job arriving out of order — completion before progress, for instance — can corrupt state if your handler is naive. Partition by job identifier so that all events for a job land on the same consumer, while different jobs still process in parallel.

Storage and state

You need three kinds of storage: raw events for auditing, job state for querying, and artifacts for delivery. A relational database handles the first two well, especially if you keep events in an append-only table and mutable state in a separate table. Object storage handles artifacts.

A workable events table has columns for the event identifier, type, schema version, provider, received timestamp, signature verification result, and the raw body as JSON or text. Add a unique index on the event identifier, and deduplication becomes a database guarantee rather than application logic you might forget.

If you prefer a managed backend, Supabase or a comparable Postgres-based platform gives you row-level security, realtime subscriptions, and a REST layer without much setup. Just be deliberate about which operations happen in the database and which happen in your worker processes. Long transactions and video metadata do not mix well.

Delivery and fan-out

When your pipeline finishes, someone usually needs to know: an internal dashboard, a client application, a chat channel, or an external partner's endpoint. Treat outbound delivery as its own concern with its own retry policy, signing keys, and logs. Never let an outbound delivery failure roll back an inbound job that already succeeded.

Designing Event Schemas, Payloads, and Idempotency

Version your schema from day one

Include a schema version in every payload. A practical shape:

  • event_id — a globally unique identifier for this event instance
  • event_type — the semantic name
  • schema_version — an integer or a date string
  • occurred_at — an ISO 8601 timestamp with timezone
  • job_id and correlation_id
  • data — the type-specific body

Additive changes are safe within a version. Removing or renaming a field is not. When you must break compatibility, publish a new version and let handlers opt in through configuration rather than forcing a flag day.

Idempotency keys and deduplication

Webhooks are delivered at least once. Assume duplicates. Deduplicate on event_id with a short-lived store — a unique index in the events table works well and doubles as your audit log. For outbound calls your own system makes, propagate an idempotency header so the receiving service can collapse repeats.

Idempotency is not just about duplicate deliveries. It also protects you during replays, when you deliberately re-run events after a bug fix, and during reconciliation, when you correct drifted state.

Correlation and parent-child relationships

Multi-stage pipelines produce trees of jobs. A single prompt might spawn six clip renders, each with an upscale job, followed by a concatenation job and an audio mix. Carry a parent_job_id and a shared correlation_id so you can reconstruct the tree, compute stage-level timings, and cancel an entire branch with one request.

Multi-Model Routing and Multi-Stage Orchestration

Different models are good at different things. A routing layer lets you pick a model based on the request rather than hard-coding it into the client. Practical routing criteria include shot type, desired duration, motion complexity, resolution, and whether the output needs to be photoreal or stylised.

Two patterns work well:

Static rules with a fallback chain. Try the primary model; if it fails with a retryable error, fall through to the next candidate. Simple, predictable, and easy to explain to stakeholders.

Capability-based selection. Each model advertises capabilities — supported aspect ratios, maximum duration, image conditioning, audio support, seed control. The router matches job requirements against the capability matrix. More flexible, but it needs maintenance as models evolve.

For multi-stage pipelines, model the stages explicitly. A typical chain: generate keyframes, animate keyframes into clips, interpolate frames for smooth motion, upscale, then mux audio and video. Each stage emits its own webhook, and a coordinator decides when the branch is complete. The coordinator should tolerate partial failure — if frame interpolation fails on one clip, you may still want to deliver the rest and flag the gap rather than discard everything.

A useful rule: the coordinator should never do rendering work. It only reads state, evaluates completion conditions, and enqueues the next stage.

Security: Signing, Allowlisting, and Secret Hygiene

HMAC signatures and timestamp windows

Sign the raw request body with a shared secret and send the signature in a header alongside a timestamp. On receipt, recompute the signature over the raw bytes — not over a re-serialised JSON object, which will almost always produce different bytes because of key ordering and whitespace — and compare in constant time. Reject requests whose timestamp falls outside a short window, typically a few minutes, to blunt replay attacks.

Log signature verification failures as their own metric. A sudden spike is either a misconfigured integration or someone probing your endpoint, and both deserve attention.

Network boundaries and allowlists

Webhook endpoints are public by definition, but they do not have to be open. Where the provider supports it, allowlist source IP ranges. Where it does not, require a short-lived token in a header or path. Put rate limits in front of the endpoint, and return 429 rather than 500 when you are throttled, because senders treat those differently.

Also validate the payload itself. A correctly signed event can still contain a callback_url pointing somewhere it should not. Never fetch a URL from a webhook payload without checking it against an allowlist and blocking private address ranges, which is how server-side request forgery usually starts.

Rotation, least privilege, and audit trails

Rotate signing secrets on a schedule and support two active secrets during the transition so you are never locked out mid-rotation. Give each integration its own secret so revoking one does not break the others. Log who changed what, keep the raw event store append-only, and redact signatures and signed URLs from your application logs.

Reliability: Retries, Backoff, and Dead Letters

Backoff that respects the provider

Exponential backoff with jitter is the baseline. Start around a second, cap at a few minutes, and cap total attempts. Video providers are often rate limited during peak hours, so a throttling response deserves a longer wait than a generic server error. Randomising the delay slightly prevents a fleet of workers from retrying in lockstep after an outage.

Dead letter queues and replay

After the final attempt, move the event to a dead letter store with its full context: attempts, last error, timestamps, and the raw payload. Then build a replay tool. Operators should be able to select events by type and time window, inspect them, and re-inject them into the normal pipeline. A replay button turns a catastrophic data-loss scenario into an afternoon of cleanup.

Reconciliation as a safety net

Events get lost. Networks partition, providers have incidents, databases get restored from an older snapshot. Run a periodic reconciliation job that queries the provider for jobs still marked as running locally and updates state accordingly. This is boring work, and it is the single highest-value reliability practice in the entire system.

Metrics that matter

Track event receipt rate, signature verification failures, handler latency, queue depth, retry counts grouped by error code, dead letter volume, and end-to-end job duration broken down by stage. Queue depth and dead letter volume are your two best leading indicators of a brewing incident.

Cost control and budget guardrails

Long renders are expensive in both time and compute. Tag every event with the stage and the model that produced it, then aggregate cost per stage. You will often discover that one stage — usually upscaling or frame interpolation — dominates the budget. Enforce per-job ceilings so a runaway retry loop cannot quietly consume your entire monthly allowance, and alert when retry volume exceeds a threshold.

Common Mistakes and How to Avoid Them

  • Doing work in the webhook handler. The handler should validate, persist, enqueue, and return. Everything else belongs in a worker.
  • Trusting payload order. Partition by job and treat out-of-order arrivals as normal rather than exceptional.
  • Re-serialising before verification. Sign and verify raw bytes.
  • Skipping idempotency. Duplicates are guaranteed, not hypothetical.
  • Hard-coding model names. Model availability changes; route through capabilities instead.
  • No cancellation path. Long renders consume real time and money. Build cancellation early, not after the first angry support ticket.
  • Logging secrets. Redact signatures, tokens, and signed URLs.
  • Testing only the happy path. Write tests that deliver the same event three times, deliver events out of order, and deliver a valid signature with an expired timestamp.

A Practical End-to-End Build Walkthrough

Putting it together, here is a minimal but production-shaped workflow.

  1. Your API receives a prompt plus rendering options and creates a job record with status queued.
  2. It calls the generation provider with a callback URL and your correlation identifier, then stores the provider's job identifier.
  3. The provider fires job.completed to your endpoint. Your ingress verifies the signature against the raw body, writes the event to an append-only table, and publishes a message to a queue partitioned by job identifier.
  4. A worker consumes the message, confirms the transition is legal, downloads or references the artifacts, and updates the job record.
  5. A coordinator checks whether all sibling jobs in the correlation group are complete. If yes, it enqueues the next stage — upscale, then mux.
  6. The final stage publishes to object storage, writes a delivery record, and fires your own outbound webhook to interested consumers, signed with your own key.
  7. A nightly reconciliation job compares local state with the provider's records and repairs drift.

A minimal handler skeleton looks roughly like this:

handle(request):
  raw = request.body_bytes
  if not verify_signature(raw, request.headers) -> return 401
  if timestamp_too_old(request.headers) -> return 401
  event = parse(raw)
  if already_seen(event.event_id) -> return 200
  store_raw(event, raw)
  enqueue(queue_for(event.job_id), event)
  return 200

Every step is independently testable, and every failure mode has a defined response. That is the whole point: the system should degrade in predictable ways rather than surprising ways.

FAQ

Do I need a dedicated gateway, or can I use my application framework?
Start with your framework. Add a gateway when you need centralised rate limiting, signature verification across many providers, or traffic replay across services.

How long should I keep raw events?
Long enough to cover your longest incident investigation, often a month or two in hot storage, with cold archives beyond that. Events are small compared to video artifacts.

Should progress events be persisted?
Persist them at a reduced sampling rate. They are useful for user experience and diagnostics but generate a large amount of volume relative to their long-term value.

What is the right queue choice?
If you already run Postgres and value simplicity, a Postgres-backed queue is fine. Move to a dedicated broker when throughput, fan-out, or delivery guarantees demand it.

How do I handle very large payloads?
Send references, not binaries. Webhook payloads should carry metadata and signed URLs, and workers should fetch artifacts separately with their own retry logic.

Can I run multiple stages in parallel?
Yes, and you should. Partition by job, coordinate by correlation group, and make the coordinator the only component that decides when a stage is complete.

How do I test webhooks locally?
Tunnel your local server to a public URL, seed a fixed signing secret, and replay captured payloads from fixtures. Keep a small library of real-world events — including malformed ones — as regression fixtures.

What if the provider offers polling instead of webhooks?
Wrap polling behind the same event contract. Your internal handlers should not care whether events arrive by push or by a scheduled poller; keeping that boundary clean means you can switch approaches without rewriting the pipeline.

Key Takeaways

Webhook-driven video pipelines are not complicated in concept, but they reward discipline. Own the plumbing, version your contracts, sign and verify everything, deduplicate ruthlessly, and build replay before you need it. Model your job states explicitly, route between models by capability rather than by name, and reconcile state on a schedule even when everything looks healthy.

Do that, and adding another model, another stage, or another integration becomes a configuration change rather than a rewrite. The teams that ship AI video features reliably are rarely the ones with the most models available — they are the ones whose event handling never loses a job.

Alexander

Alexander