Edge Functions

Scheduling Edge Functions


The hosted Supabase Platform supports the pg_cron extension, a recurring job scheduler in Postgres.

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:


_13
select
_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
);

Resources