Docs › Supabase: pg_cron and Edge Functions with RunVouch

Supabase: pg_cron and Edge Functions with RunVouch

The documented pattern is cron.schedule() calling net.http_post() to an Edge Function. pg_net is fire-and-forget: a function that never ran, or ran and failed, leaves only a row in net._http_response that nobody reads.

How it runs on Supabase (pg_cron + Edge Functions)

Inside the Edge Function (Deno), with two fetch() calls around the work.

Store the key

supabase secrets set RUNVOUCH_KEY=rv_...; read it with Deno.env.get("RUNVOUCH_KEY").

Report the run (two HTTP calls)

// supabase/functions/nightly-report/index.ts
Deno.serve(async () => {
  const h = {"X-API-Key": Deno.env.get("RUNVOUCH_KEY")!, "content-type": "application/json"};
  const {run_id} = await (await fetch("https://api.runvouch.com/v1/runs/start", {method: "POST", headers: h,
    body: JSON.stringify({agent: "nightly-report", source: "supabase"})})).json();
  const inserted = await buildReport();
  await fetch("https://api.runvouch.com/v1/runs/end", {method: "POST", headers: h,
    body: JSON.stringify({run_id, status: "ok", evidence: {inserted: inserted > 0}})});
  return new Response("ok");
});
-- SQL, once:
select cron.schedule('nightly-report', '0 2 * * *',
  $$ select net.http_post(url := 'https://PROJECT.supabase.co/functions/v1/nightly-report',
       headers := '{"Authorization": "Bearer SERVICE_ROLE_KEY"}'::jsonb) $$);

The start call returns run_id; the end call takes status (ok or fail), optional cost and tokens, and evidence as a JSON object of booleans. Full reference on the API page.

Register the cadence and caps

rv agent nightly-report --cadence 24h --grace 30m --max-runtime 1h --evidence --cap-run-cost 2

Register the agent once, from anywhere with the key. Cadence is what turns a schedule that stopped into an alert; --evidence makes a run without evidence a failure; the caps pause the agent when it overspends.

What goes silent on Supabase (pg_cron + Edge Functions)

What RunVouch detects

AlertWhat it means here
MISSEDcadence plus grace passed and no run started
FAILEDnon-zero exit or a reported failure, with the stderr excerpt
NO_EVIDENCEthe run said ok but the file, URL or assertion you required is missing
STALLEDa run started and never ended within max runtime
RETRY_STORMthe same tool called with identical input many times in one run
BUDGET_RUN / BUDGET_DAYcost cap crossed; the agent is paused until you resume it
DRIFTduration or output size far off its 7-run baseline

Need a key? Get a free key · Stuck? contact