HOW TO SCHEDULE EDGE FUNCTIONS WITH WEBHOOKS: CLOUDFLARE WORKERS, VERCEL, AND DENO
How to schedule edge functions with webhooks: Cloudflare Workers, Vercel, and Deno
Edge functions only run on request — cron has nowhere to live. Trigger Cloudflare Workers, Vercel Edge, or Deno Deploy on any schedule with signed webhook deliveries and a full activity trail.
Edge functions are the best economics in compute right now: scale to zero, pay per request, sub-millisecond starts close to users. They have exactly one blind spot — time. A scale-to-zero environment can’t wake itself up, and nothing inside a request-scoped runtime can hold a clock. Any “every morning at 6, do X” feature has to come from somewhere outside the edge.
The platform answer is a cron trigger bolted to your deploy. The portable answer is a scheduled webhook: an external scheduler fires a signed POST at your edge function on any cron expression. Your edge handler stays 60 lines of stateless, verifiable logic — and the schedule becomes infrastructure you can manage via API, move between platforms, and hand to an AI agent.
Platform cron triggers and where they stop
Every major edge platform shipped a “tick” primitive. They work, and for same-deploy glue they’re fine — but look closely at what they actually give you:
| Platform primitive | What it gives you | What it leaves out |
|---|---|---|
| Cloudflare Cron Triggers | scheduled() handler, cron in wrangler.toml |
No event payloads, schedule coupled to the deploy, no per-run audit outside the dashboard |
| Vercel Cron Jobs | Hits a route path on a config-defined schedule | GET pings with empty bodies, no signing, no retries you can inspect, per-project |
| Netlify Scheduled Functions | Time-triggered invocations | Same coupling: schedule lives in the repo, no payload, no batching |
| Deno.cron | In-code cron for Deploy | Same again — plus platform lock-in on every one |
Three gaps repeat across all of them:
- The schedule is config in a repo. Changing “9am” to “9:30am” is a deploy. Your ops team can’t touch it, your API can’t create it, an agent can’t schedule it.
- There’s no event model. The tick fires nothing — no typed event, no subject, no payload. Every consumer re-implements “what is this run supposed to do” inside the handler.
- No delivery audit. Did the 3am run happen? What did the endpoint return? A log line somewhere. Scheduled work deserves an activity trail.
A scheduled webhook fixes all three by moving the clock out of the deploy.
The pattern: scheduler-outside, receiver-at-the-edge
Recurrence Cloud (scheduler) Your edge function (receiver)
───────────────────────────── ─────────────────────────────
cronExpr: "0 6 * * *" fetch(request) {
timezone: "America/New_York" verify HMAC signature
events: signed payload ────POST───► read batch.events
fan out / process
X-Webhook-Signature return 2xx
X-Recurrence-Batch-Id }
The scheduler lives outside your deploy. Your function can scale to zero, be redeployed twenty times a day, or be rewritten in another language next week — the schedule doesn’t care. Retries, an activity log, and a per-batch batchId come with the delivery instead of a platform dashboard.
One API call to wire it up
Create the schedule, the webhook target, and the first event in a single request:
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-digest",
"cronExpr": "0 6 * * *",
"timezone": "America/New_York"
},
"webhook": {
"url": "https://digest.yourapp.workers.dev/",
"secret": "<webhook secret — e.g. your app API token>"
},
"event": {
"subject": "digest-prod",
"payload": { "window": "overnight", "channels": ["email", "slack"] }
},
"appId": "$APP_ID"
}'
What you get back is everything wired together: a schedule running 0 6 * * * in America/New_York, a webhook registered to your Worker, and a recurring event batch grouped under subject digest-prod. Change the cron, pause for a deploy freeze, or fan the schedule out to new environments through the same API — no redeploy.
The receiver: a Cloudflare Worker that verifies first
Edge runtimes implement the Web Crypto API, so signature verification needs zero dependencies. Every delivery is signed with an HMAC-SHA256 digest of the raw body, sent in X-Webhook-Signature:
// worker/index.ts — Cloudflare Worker (module syntax)
export default {
async fetch(request, env): Promise<Response> {
if (request.method !== "POST") return new Response("pong");
const raw = await request.text();
const signature = request.headers.get("X-Webhook-Signature");
if (!signature || !(await verifyHmac(raw, signature, env.WEBHOOK_SECRET))) {
return new Response("invalid signature", { status: 401 });
}
const batch = JSON.parse(raw);
// batch = {
// events: [ { id, subject, scheduleId, scheduleName, data }, ...
// or grouped: { subject, count, events: [...] } ],
// organizationId, appId, webhookId, batchId, attempt, firedAt
// }
const attempt = request.headers.get("X-Recurrence-Attempt");
// Retry deliveries reuse batchId — dedupe on (batchId, attempt)
// if a redelivery must be a no-op on your side.
for (const event of batch.events ?? []) {
// Multiple events sharing a subject arrive grouped:
// { subject, count, events: [ { id, subject, ... , data } ] }
if (Array.isArray((event as any).events)) {
for (const inner of (event as any).events) await handleEvent(inner, env);
} else {
await handleEvent(event, env);
}
}
return new Response("ok");
},
};
async function verifyHmac(raw: string, sigHex: string, secret: string) {
const key = await crypto.subtle.importKey(
"raw",
new TextEncoder().encode(secret),
{ name: "HMAC", hash: "SHA-256" },
false,
["sign"],
);
const digest = await crypto.subtle.sign(
"HMAC",
key,
new TextEncoder().encode(raw),
);
const hex = [...new Uint8Array(digest)]
.map((b) => b.toString(16).padStart(2, "0"))
.join("");
return hex === sigHex;
}
async function handleEvent(event: any, env: any) {
// event.data is whatever you attached to the schedule
console.log("dispatch", event.subject, event.scheduleName, event.data);
}
The same receiver works on Vercel Edge Functions and Deno Deploy with only the entry point changing:
// api/scheduled.ts — Vercel Edge
export const runtime = "edge";
export async function POST(request: Request): Promise<Response> {
// identical body: read text, verify X-Webhook-Signature, process batch
return handle(request);
}
One receiver, signed deliveries, zero npm dependencies — and it runs anywhere the Web Crypto API does.
Edge-specific playbooks
Running scheduled delivery into an edge runtime has quirks worth knowing:
- Cold starts are the wake-up call, not a bug. The external scheduler is what turns your function on. A few milliseconds of isolate spin-up at 6am is the entire cost of never running a server.
- CPU and subrequest caps → fan out. If a nightly batch exceeds edge limits, treat the webhook as a trigger and push each event into a queue (see chaining events), where long-running work belongs.
- Batching is a feature here, not an optimization. Events sharing a
subjectarrive in one delivery — one request, one signature check, one activity entry. On platforms that bill per request, subject grouping is a line item you can see (see batching by subject). - Timezones are first-class.
cronExprplustimezonemeans “6am there” is correct for a tenant in Berlin even if your Worker executes in New Jersey. - Set the webhook timeout deliberately. Edge handlers are fast, but outbound calls they make (an S3 upload, a third-party API) may not fit the default 30s window — configure
timeoutMson the webhook, and keep the handler under it. - Use regional execution to your advantage. Route delivery to a Worker in the same region as your data store, and scheduled cross-region reads disappear.
When to still use platform cron triggers
Be honest about tradeoffs: if the tick and the work live in the same deploy, run under one minute, need sub-minute frequency, and nobody else will ever manage the schedule — a platform trigger is less moving parts. Reach for a scheduled webhook when any of these are true:
- The schedule must change without a deploy, or be created at runtime via API
- Multiple tenants need their own grouped, per-subject event payloads
- You need signed deliveries your receiver can verify independently
- The delivery needs an audit trail, retries with backoff, and failure alerting
- An AI agent should create or manage schedules on its own (see scheduled MCP tool calls)
Most teams land on both: platform triggers for glue inside one deploy, scheduled webhooks for everything that outlives one.
Get started
- How to schedule webhooks with cron — the full zero-to-delivery walkthrough
- Cron expressions for scheduled webhooks — copy-paste expressions for every cadence
- Monitoring webhook deliveries — because an edge tick you can’t observe is a shrug at 3am
FAQ
Can edge functions run on a schedule?
Not by themselves. Edge functions are request-scoped — nothing inside a scale-to-zero environment can wake itself up. Major platforms patch the gap with platform cron triggers (Cloudflare Cron Triggers, Vercel Cron Jobs, Netlify Scheduled Functions, Deno.cron), which run inside your deploy on the platform's clock.
How do I trigger a Cloudflare Worker on a schedule?
Two ways. Use Cron Triggers (add a `scheduled()` handler plus cron entries in wrangler.toml) for same-deploy glue, or register the Worker's fetch endpoint with an external scheduler like Recurrence Cloud and receive signed webhook POSTs on any cron expression — no redeploy needed to change the schedule.
Why use an external scheduler instead of platform cron triggers?
Platform triggers are tied to one deploy, carry no event payload, have no tenant grouping, and can't be created or managed by API or by AI agents. An external webhook scheduler keeps the schedule out of your repo, signs every delivery, batches events per subject, and gives you a per-delivery audit trail with retries.
Can an edge function verify a signed webhook?
Yes. Edge runtimes implement the Web Crypto API, so you can verify an HMAC-SHA256 signature header (X-Webhook-Signature) without any npm dependency — see the Cloudflare Worker example in this article.
Do cold starts break scheduled workloads?
No — cold starts are a receiving cost, not a scheduling one. The external scheduler wakes the function on time; an occasional cold-start penalty is usually milliseconds at the edge. If a workload exceeds CPU or subrequest caps, fan the events out into a queue.