Choose when it runs
In the function editor, open Trigger → On a schedule and pick one of three options:
Each schedule also takes these settings:
timezoneis an IANA name such as"Europe/Berlin". The default isUTC. Times are read in this timezone, so a 09:00 run stays at 09:00 local time when daylight saving changes.starts_at/ends_at(cron and every only, both optional) limit the schedule to a window. An interval counts fromstarts_at. Withoutstarts_atit counts from midnight, so “every 15 minutes” runs at :00, :15, :30 and :45, and “every 1 week” runs on Mondays.
Run once for each matching record
Addfor_each to run the function once for every record that matches a filter. Each run sets trigger.record_id to that record.
- Each record gets its own transaction. If the run for one record fails, the runs that already succeeded stay saved.
- If a guard step stops the run for a record, that record is skipped. A guard stop is not counted as a failure.
- Records are taken in id order, up to
limit(default 100, at most 1000) per run. - The
wherefilter can readtrigger.scheduled_for.
What steps can read
Scheduled functions always run as the system (
run_as: "system"), because no user starts them. They cannot have inputs.
A scheduled function can also make PDFs with the Generate a PDF step (for example, a monthly statement per customer with for_each). See PDF templates.
How runs behave
- Publish and enable it. Only the published version of an enabled function runs. A newly published version starts counting from the moment you publish it. Disabling a function stops it. When you enable it again, its schedule starts from that moment, so runs it missed while disabled are not replayed.
- Runs of one function never overlap. If a run is due while the previous one is still running, it starts when the previous one finishes.
- Missed runs run once. If the server was down when runs were due, the function runs once when it is back, for the latest missed time. The run log records how many runs were missed (
missed). - Long runs stop early. A
for_eachrun that takes longer than 10 minutes stops starting new records and is marked partial. - Run now. The Run now button, or
POST /api/projects/{projectId}/functions/{id}/run, queues a run straight away and returns202. The next scheduled run does not change. - Test. A test run (dry run) runs as if the schedule were due now, then undoes everything. With
for_each, it uses the record you pick, or else the first matching record.
for_each, appears in the Runs tab with its step trace.
Hosting
Scheduled functions need the Laravel scheduler and a queue worker:functions:schedule runs every minute. It queues the functions that are due and recovers runs that a crashed worker left unfinished.
Scheduled functions cannot send email yet. Steps that send messages or call other services will come with the outbox.
