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:
_13select_13 cron.schedule(_13 'invoke-function-every-minute',_13 '* * * * *', -- every minute_13 $$_13 select_13 net.http_post(_13 url:='https://project-ref.supabase.co/functions/v1/function-name',_13 headers:='{"Content-Type": "application/json", "Authorization": "Bearer YOUR_ANON_KEY"}'::jsonb,_13 body:=concat('{"time": "', now(), '"}')::jsonb_13 ) as request_id;_13 $$_13 );