Home

Scheduling Edge Functions

The hosted Supabase Platform supports the pg_cron extension, a simple cron-based job scheduler for PostgreSQL that runs inside the database.

In combination with the pg_net extension, this allows us to invoke Edge Functions periodically on a set schedule.

Examples#

Invoke an Edge Function every minute#

Make a POST request to a Supabase Edge Function every minute:

select
  cron.schedule(
    'invoke-function-every-minute',
    '* * * * *', -- every minute
    $$
    select
      net.http_post(
          url:='https://project-ref.functions.supabase.co/function-name',
          headers:='{"Content-Type": "application/json", "Authorization": "Bearer YOUR_ANON_KEY"}'::jsonb,
          body:=concat('{"time": "', now(), '"}')::jsonb
      ) as request_id;
    $$
  );

Resources#

Need some help?

Not to worry, our specialist engineers are here to help. Submit a support ticket through the Dashboard.