Webhooks let your app find out the instant a video job finishes, instead of hammering an endpoint asking "done yet?" over and over. When you generate video at scale with Wavemaker, that difference matters. A render can take a few minutes, and polling that whole time wastes requests, burns your rate limit, and adds lag. With webhooks, Wavemaker sends you a signed HTTP callback the moment a video is ready, so your pipeline can download, publish, or hand off the result right away.

This guide covers why webhooks beat polling for long-running video jobs, how Wavemaker's HMAC-signed webhooks work, and a production pattern you can build today. We'll also cover pairing the REST API with SSE progress streaming.

Why webhooks beat polling for video jobs

Video generation isn't instant. Wavemaker runs a full pipeline (script, storyboard, generated visuals, voiceover, music, and an AI vision QC pass), so most videos take two to five minutes. That's a long time to sit in a polling loop.

About polling: you don't know when the job will finish, so you keep asking. Ask too often and you burn requests and run into the API's rate limit. Ask too rarely and users wait longer than they need to. Either way, you're guessing.

Webhooks flip the model. You register a URL once, kick off a job, and go do something else. When the render completes (or fails), Wavemaker POSTs an event to your URL. No wasted requests, no guessing, no lag.

Polling vs Webhooks
Factor Polling Webhooks
Who initiates Your app, repeatedly Wavemaker, once per event
Latency to result As slow as your poll interval Near-instant
Rate-limit cost High (many status checks) Near-zero
Scales to many jobs Poorly (loops multiply) Well (event-driven)
Infra needed Just an API client A public HTTPS endpoint
Best for Quick one-off jobs, local scripts Production pipelines, batch generation

The trade-off: webhooks need a public HTTPS endpoint that Wavemaker can reach. For a quick local script, polling is fine. For anything running in production or generating videos in volume, webhooks are the right call.

video-generation-webhooks - Body1

How Wavemaker's HMAC-signed webhooks work

A webhook is just an HTTP POST that Wavemaker sends to a URL you control. The catch is trust: anyone who learns your webhook URL could send fake events to it. So every Wavemaker webhook is HMAC-signed. That signature is how you prove a request came from Wavemaker and wasn't tampered with in transit.

Verify the signature (do this first)

HMAC works with a shared secret that only you and Wavemaker know. You get it once, when you register the endpoint with `POST /v1/webhooks/endpoints`. Each delivery carries a `Wavemaker-Signature` header of the form `t={unix time},v1={hex}`, where the hex value is an HMAC-SHA256 of `{t}.{raw body}` under that secret. Your job is to compute the same hash on your end and check that the two match.

The pattern looks like this in pseudo-code:

def handle_webhook(request):
    header = request.headers["Wavemaker-Signature"]   # "t=1764850000,v1=ab12..."
    t, signatures = parse_signature_header(header)    # v1 can appear twice during a secret rotation
    payload = request.raw_body                        # use the RAW bytes, not parsed JSON

    if abs(time.time() - int(t)) > 300:
        return 401                                    # reject: too old, could be a replay

    # lowercase hex, the same form as the v1 values in the header
    expected = hmac_sha256(secret=WEBHOOK_SECRET, message=f"{t}.".encode() + payload)

    if not any(constant_time_equals(sig, expected) for sig in signatures):
        return 401                                    # reject: not from Wavemaker

    event = parse_json(payload)
    process_event(event, delivery_id=request.headers["Wavemaker-Delivery"])
    return 200

Four rules that matter here:

  • Check the timestamp. Reject a delivery whose `t` is more than five minutes (300 seconds) from your clock. A valid signature on an old request is how a replayed copy gets in.

  • Hash the raw body, not a re-serialized version. If you parse the JSON and stringify it again, the bytes change and the signature won't match.

  • Use a constant-time comparison to check the signature. A normal `==` can leak timing information that helps an attacker guess the secret.

  • Return 200 only after you've accepted the event, and within 10 seconds. A non-2xx response, or no answer in time, tells Wavemaker the delivery failed, which triggers a retry (more on that below).

Never skip verification, even in a hurry. An unverified endpoint is an open door for anyone who guesses your URL to inject fake "video ready" events into your pipeline.

Handle the events

Once a request is verified, look at the event type (also sent in the `Wavemaker-Event` header) and act on it. You choose the types when you register the endpoint. For video work the useful ones are `turn.completed` when the agent finishes a brief, `turn.failed` when it couldn't continue, and `delivery.created` each time a finished file lands.

`turn.completed` means the turn ended, not that your video exists. Read the turn with `GET /v1/sessions/{id}/turns/{turn_id}` and check its `outcome.status`. Only `delivered` means every video you asked for came back. `partial` means some did, and `needs_input` means the agent has a question for you. Your handler routes on that:

def process_event(event, delivery_id):
    if event["type"] == "turn.completed":
        turn = get(f"/v1/sessions/{event['session_id']}/turns/{event['turn_id']}")["data"]
        if turn["outcome"]["status"] == "delivered":
            queue_publish(turn["outcome"]["deliveries"])
        else:
            alert(turn)                     # partial, needs_input, stopped...
    elif event["type"] == "turn.failed":
        alert_and_requeue(event["session_id"], event["turn_id"])

Keep the handler fast. Verify, acknowledge with a 200, and push the real work (downloading, transcoding, publishing) onto a background queue. If your handler does heavy work inline and takes too long, the connection can time out and Wavemaker will treat the delivery as failed.

Build in idempotency

This is the rule people forget. Webhooks can arrive more than once. A network blip, a retry, or a timeout on your side can all cause Wavemaker to redeliver the same event. If your handler publishes a video every time it sees a `turn.completed` event, a duplicate delivery means a duplicate publish.

The fix is idempotency: make processing the same event twice have the same effect as processing it once. Each delivery carries an ID in the `Wavemaker-Delivery` header. Record the IDs you've already handled and skip repeats.

def process_event(event, delivery_id):
    if already_processed(delivery_id):
        return                      # duplicate, ignore
    mark_processed(delivery_id)
    # ... do the real work

A small table or cache keyed on delivery ID is enough. Bottom line: assume at-least-once delivery and design so duplicates are harmless.

video-generation-webhooks - Body2

A production pattern: submit, receive, publish

Here's how the pieces fit into a real pipeline. The flow has three stages, and none of them block.

1. Post the brief. Your service posts the brief as a turn in a session (`POST /v1/sessions/{id}/turns` on `https://api.wavemaker.io`). Wavemaker returns the turn's ID right away. You store that ID, note that the job is in progress, and move on. No waiting.

turn = post(f"/v1/sessions/{session_id}/turns", json={
    "request_id": "spring-sale:promo-v1",
    "controller": controller_token,
    "text": "30-second promo for our spring sale",
    "deliverables": [{"id": "promo", "kind": "video", "aspect": "9:16", "duration_s": 30}],
})
save_job(turn["data"]["id"], status="processing")

Every reply from the API comes in one envelope, `{ok, data, error, ...}`. When `ok` is true the result is in `data`, which is why the turn's ID is `turn["data"]["id"]`. When it's false, `error` says why.

2. Receive the signed webhook. Minutes later, when the agent finishes, Wavemaker POSTs a `turn.completed` event to your registered endpoint. You verify the signature, check the delivery ID for idempotency, mark the job done, and queue the follow-up work.

3. Download and publish. A background worker picks up the finished job, reads the turn (`GET /v1/sessions/{id}/turns/{turn_id}`), checks that `outcome.status` is `delivered`, and takes each file's signed download link from the outcome. The links expire after an hour, so download the files rather than storing the links. Then it does whatever's next: uploads it to your CMS, posts it to social, drops it in a review folder, or hands it to Adwave to run as a streaming TV commercial on 100+ networks from $30 a day.

The reason this pattern scales is that stage 1 and stage 3 are decoupled by stage 2. You can fire off a hundred jobs in a loop without a hundred polling loops running behind them. Each one comes back on its own when it's ready. This is the same event-driven backbone behind automating video creation with n8n and the API, where a no-code workflow submits jobs and reacts to completion events without you writing a polling loop by hand.

Retries and failure handling

Networks fail. Deploys restart. Your endpoint will occasionally be unreachable when Wavemaker tries to deliver. That's expected, and there's a standard way to handle it.

Wavemaker retries failed deliveries. If your endpoint doesn't return a 2xx within 10 seconds (it errors, times out, or is down), Wavemaker treats the delivery as failed and retries it six times over about 9 hours, first after 30 seconds and last after 6 hours. A retry after a timeout on your side can mean you receive an event you already processed, so your handler has to be idempotent.

A few habits make failure handling reliable:

  • Acknowledge fast, process later. Return 200 as soon as you've verified and recorded the event. Do the slow work in a background job so a downstream hiccup never causes the webhook itself to fail and retry.

  • Have a reconciliation fallback. Webhooks are the fast path, not the only path. Run a periodic sweep that lists jobs still marked "processing" past a reasonable window and checks their status directly via the API. This catches the rare case where a webhook never lands (say, your endpoint was down through every retry).

  • Handle `turn.failed` explicitly. A turn can fail for its own reasons. When you get a failure event, log it, alert if it matters, and decide whether to requeue. Don't let failed jobs sit silently as "processing" forever.

  • Log every delivery. Store the event ID, type, and timestamp for each webhook you receive. When something looks off, that log is the first place you'll look.

The combination of retries (Wavemaker's side), idempotency (your side), and a reconciliation sweep (your safety net) gives you a pipeline that stays correct even when the network doesn't cooperate.

Combining webhooks with the REST API and SSE

Webhooks don't replace the rest of the API, they complete it. Here's how the three fit together.

  • REST API (`https://api.wavemaker.io`) is how you start work and check on it: `POST /v1/sessions/{id}/turns` posts a brief, and the session's events and turns tell you where it stands. It's the front door. Every pipeline uses it.

  • SSE progress streaming gives you live progress on a single session over a persistent connection: the same events, read with `Accept: text/event-stream`. It's perfect for a UI where a user is watching their own video render and you want a progress bar that updates through each pipeline stage. SSE is great for one job in the foreground.

  • Webhooks are the fan-out mechanism for many jobs in the background. You don't hold a connection open per job; Wavemaker calls you when each one lands.

A common production setup uses all three: REST to submit, SSE to power a live progress bar for interactive users, and webhooks to drive the background pipeline that publishes finished videos across a whole batch. Without webhooks, REST plus SSE covers interactive use well, and a light polling loop with generous intervals handles the rest.

For the full request and response reference, including how to authenticate and start jobs, see the video generation API guide. And when you're ready to wire it up, the developer docs have working examples.

video-generation-webhooks - Body3

Common questions answered

What does a webhook pipeline cost to run? You pay for the videos, in credits, and cost per video depends on length, takes and models. Your first video is on us: new accounts get 300 starter credits (they expire after 14 days). After that, credit packs start at $19.99 (300 credits, never expire) and Pro plans at $49 a month (850 credits). The developer docs cover how to set up API access and webhooks.

How do I verify a Wavemaker webhook is genuine? Every webhook is HMAC-signed. Take the `t` value from the `Wavemaker-Signature` header, compute an HMAC-SHA256 of `{t}.{raw body}` with your endpoint's secret, and compare it against the header's `v1` value using a constant-time comparison. If they match, the event is authentic and untampered. If not, reject it with a 401.

Why did I receive the same webhook twice? Webhook delivery is at-least-once, so retries after a network blip or a slow response on your side can redeliver an event you already handled. That's normal. Make your handler idempotent by recording each `Wavemaker-Delivery` ID and skipping any you've already processed, so a duplicate has no extra effect.

What happens if my endpoint is down when a video finishes? Wavemaker retries a failed delivery six times over about 9 hours, so a brief outage usually resolves itself once your endpoint recovers. For longer outages, run a reconciliation sweep that periodically checks any job still marked "processing" against the API directly, so nothing gets stuck if every retry misses.

Should I use webhooks or SSE? Use SSE when a user is watching a single video render and you want a live progress bar in the foreground. Use webhooks when you're generating many videos in the background and need to react to each completion without holding a connection open. Big production pipelines often use both, plus the REST API to submit jobs.

Can I publish a finished video to TV through the pipeline? Yes. Once a webhook tells you a video is ready, your worker can hand it to Adwave, which runs it as a real streaming TV commercial on 100+ networks from $30 a day (plus Google, YouTube, Meta, Reddit, and display). The video creation happens in Wavemaker; Adwave handles the paid distribution.

Ready to build? Start with the developer docs and wire up your first signed webhook: Wavemaker for developers. You can make your first video on us (300 starter credits) to test the flow end to end before you scale it up. Starter credits work in the app and in sign-in connections like MCP. API-key requests need a paid pack or plan.