USING WEBHOOKS TO KICK OFF A SERIES OF EVENTS: 5 PATTERNS FOR EVENT CHAINS

Using webhooks to kick off a series of events: 5 patterns for event chains

One scheduled webhook is a trigger; a series of events is a workflow. Five patterns for batching, fanning out, and chaining events from a single cron-driven webhook delivery.

A webhook that fires once on a schedule is a trigger. What turns it into a workflow is the decision nobody writes down: what does one delivery mean? Handled with intent, a single cron-driven webhook can kick off a numbered series of events, fan out across services, sequence a multi-stage pipeline, and even end in an AI agent doing the work. This article walks through five patterns, in increasing complexity, all built on the same primitive — a schedule with defined events, delivered as signed webhooks.

Pattern 1: One schedule, many events (the batch)

The most direct way to express “a series of events” is to stop thinking one schedule → one payload and start thinking one fire → a batched series. Attach several event definitions to the same schedule and group them under a subject — events sharing a subject on the same fire arrive in a single delivery:

# First event lands with the schedule via with-webhook...
curl -X POST https://api.recurrence.cloud/api/v1/schedules/with-webhook \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "schedule": { "name": "nightly-billing-run", "cronExpr": "0 1 * * *", "timezone": "UTC" },
    "webhook":  { "url": "https://api.yourcompany.dev/billing/run", "secret": "<webhook secret>" },
    "event":    { "subject": "billing-run-11-17", "payload": { "type": "billing.rollup", "period": "2025-11" } },
    "appId":    "$APP_ID"
  }'

# ...subsequent events in the series attach to it directly
curl -X POST https://api.recurrence.cloud/api/events \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "scheduleId": "$SCHEDULE_ID", "organizationId": "$ORG_ID",
        "subject": "billing-run-11-17", "payload": { "type": "billing.invoices", "period": "2025-11" } }'

curl -X POST https://api.recurrence.cloud/api/events \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "scheduleId": "$SCHEDULE_ID", "organizationId": "$ORG_ID",
        "subject": "billing-run-11-17", "payload": { "type": "billing.notifications", "period": "2025-11" } }'

At 1am, one webhook arrives — not three:

{
  "events": [
    {
      "subject": "billing-run-11-17",
      "count": 3,
      "events": [
        { "id": "evt_01", "subject": "billing-run-11-17", "scheduleName": "nightly-billing-run", "data": { "type": "billing.rollup",         "period": "2025-11" } },
        { "id": "evt_02", "subject": "billing-run-11-17", "scheduleName": "nightly-billing-run", "data": { "type": "billing.invoices",      "period": "2025-11" } },
        { "id": "evt_03", "subject": "billing-run-11-17", "scheduleName": "nightly-billing-run", "data": { "type": "billing.notifications", "period": "2025-11" } }
      ]
    }
  ],
  "organizationId": "org_1",
  "appId": "app_1",
  "webhookId": "wh_1",
  "batchId": "bat_01",
  "attempt": 1,
  "firedAt": "2025-11-17T01:00:00.500Z"
}

The receiver becomes a tiny dispatcher that processes the series in order:

import { Hono } from "hono";

const app = new Hono();

app.post("/billing/run", async (c) => {
  const batch = await c.req.json();            // verify signature first — see the security post
  const runId = batch.batchId;                 // your idempotency anchor

  for (const group of batch.events) {
    const events = Array.isArray(group.events) ? group.events : [group];
    for (const event of events) {
      switch (event.data.type) {               // dispatch on the event type you defined
        case "billing.rollup":         await rollup(event, runId);      break;
        case "billing.invoices":       await generateInvoice(event, runId); break;
        case "billing.notifications":  await sendNotices(event, runId); break;
      }
    }
  }
  return c.text("ok");
});

export default app;

Why this beats three separate schedules: one signature check, one HTTP round trip, one activity-trail entry to correlate, and a guaranteed shared context — every event in the batch carries the same run (billing-run-11-17).

Pattern 2: Fan out into a queue, chain in the background

Scheduled webhooks are the tick, not the workhorse. When the real work is heavy — rendering, bulk API writes, ML jobs — the receiver’s whole job is to translate one delivery into queue messages and return fast:

Recurrence Cloud ──signed POST──► receiver ──► queue (SQS / Redis / Upstash)
                                     │                 │
                                return 200 fast    workers consume,
                                                   emit completion events
app.post("/billing/run", async (c) => {
  const batch = await c.req.json();
  for (const event of flatten(batch.events)) {
    await queue.send({
      kind: event.data.type,
      eventId: event.id,
      batchId: batch.batchId,
      payload: event.data,
    });
  }
  return c.text("enqueued"); // scheduler sees a fast 2xx; work continues asynchronously
});

The chain continues inside your workers; a completion event (written back to the activity trail or your own system) closes the loop. The delivery’s attempt header plus the queue’s own dedup are your at-least-once safety net — see the reliability rules at the end.

Pattern 3: Sequential pipelines by cron offset

Some stages genuinely can’t overlap — extract before transform, transform before load. Two honest options:

  1. Receiver-driven chaining: stage N finishes by calling stage N+1 directly (sign it as you would any webhook). Maximum tightness; your stages must share trust and handle “next stage is down” yourself.
  2. Schedule-driven chaining: each stage gets its own schedule at an offset, and the sequence advances by time, not by callback:
Stage Schedule name cronExpr Fires
Extract billing-extract 0 1 * * * 1:00am
Transform billing-transform 30 1 * * * 1:30am
Load billing-load 0 2 * * * 2:00am

Each stage verifies its incoming signed delivery, does its unit of work, and finishes. Nothing waits on anything; each hop is observable in the activity trail; a stage failing is a failed run you can see and page on — not a mystery half-way through an in-process pipeline. For most teams this is the highest-value pattern on this list, because it deletes the fragile “step 2 of 7” glue code entirely.

Pattern 4: Cross-service choreography

Give each consuming service its own webhook and let the event envelope route the work:

{
  "events": [ { "id": "evt_01", "subject": "tenant-acme", "scheduleName": "tenant-sweep", "data": { "type": "sync.crm", "tenant": "acme" } } ],
  "organizationId": "org_1",
  "appId": "app_1",
  "batchId": "bat_02",
  "attempt": 1
}
  • The receiver checks X-Organization-Id and the event subject to know whose data this is.
  • data.type is namespaced (sync.crm, sync.mailing) so each subscriber picks its own event types out of the stream.
  • Subject per tenant (tenant-acme) means a tenant’s events arrive together — respecting their rate limits and giving one unit of work per tenant (see batching by subject).

No service knows the others exist; the schedule and the event definitions are the contract.

Pattern 5: Chain into AI agents

The newest pattern: end the series with an agent, not a script. A schedule can target an MCP tool invocation instead of an HTTP webhook — the fire becomes a tools/call against your MCP server with the batch’s events as arguments:

curl -X POST https://api.recurrence.cloud/api/v1/schedules/with-webhook \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "schedule": { "name": "morning-agent-brief", "cronExpr": "0 8 * * 1-5", "timezone": "America/New_York" },
    "mcp": { "url": "https://mcp.yourcompany.dev", "toolName": "briefing.generate", "arguments": { "scope": "customer-ops" } },
    "event": { "subject": "ops-brief", "payload": { "type": "ops.brief", "include": ["incidents", "invoices", "churn"] } },
    "appId": "$APP_ID"
  }'

Now “kick off a series of events” can finish in an agent reasoning over the batch — a weekly report written by an LLM, a triage pass, a digest. And because agents can create schedules through the same API or MCP tools, the chain can grow at runtime: the agent that receives a fire can register the follow-up schedule itself (see scheduled MCP tool calls).

Reliability rules for every pattern

Five rules that keep any chain standing:

  1. Verify-or-die at every hop. A chain is only as trustworthy as its weakest receiver; an unsigned hop is a remote trigger anyone can fire.
  2. Idempotency keyed on identity, not time. Retries reuse batchId and event.id — key deduplication there, not on timestamps.
  3. Process batches in subject order. Within a batch, treat the event list as ordered intent; your dispatcher is the only judge of parallelism.
  4. Watch attempts, alert on final failure. X-Recurrence-Attempt tells you which try you’re on; schedule retry policies with backoff and failure alerts so the last domino falling pages someone.
  5. Correlate with batchId + subject. Every delivery, response code, and duration lands in the activity trail — grep by subject and you can see the series end to end (see monitoring scheduled deliveries).

The meta-pattern

Notice what all five patterns share: the schedule contributes a clock and a signed, batched event envelope, and everything after that is ordinary HTTP. You never installed a workflow engine, and you never will — a series of events is just your receiver reading its mail in order.

Get started

FAQ

Can one webhook trigger multiple events?

Yes. In Recurrence Cloud you attach any number of event definitions to a schedule; events sharing a subject on the same fire are delivered together in one webhook as a batch ({ subject, count, events: [...] }), and your receiver dispatches them in order.

How do you chain webhooks together?

Each webhook receiver performs its stage of work and then triggers the next stage — either by calling the next service directly (signed again), or by letting the scheduler advance a sequence of offset cron schedules (extract at 0 1 * * *, transform at 30 1 * * *, load at 0 2 * * *). Verify every hop and key each stage's work on the event id.

What is the difference between event choreography and orchestration?

Choreography lets each service react to events and trigger follow-ups with no central coordinator; orchestration drives the sequence from a central workflow. Scheduled webhook chains give you a hybrid: the schedule is the conductor, the deliveries are the score, and receivers stay independent.

How do you make a webhook event chain reliable?

Four rules: verify the signature at every hop, key deduplication on the event id and batch id (retries reuse them), process batched events idempotently in subject order, and correlate everything for observability using X-Recurrence-Batch-Id and the subject — the activity trail shows every delivery and response code.

When should a webhook chain fan out into a queue?

Whenever the real work exceeds the receiver's time or resource budget — heavy compute, high subrequest counts, or long API call tails. The scheduled webhook becomes the tick; the queue absorbs the work; a completion event closes the chain.