DocsMessages & jobs
On this page

Pause a job at a rate limit

Choose which work pauses when a limit is reached.

Before you begin: Run a background job.

Pause new work after a rate limit

job.sleep(milliseconds) requests a cooldown for the whole job. New iterations and scheduled job steps wait until the wake time; iterations already in progress can finish. The wake time survives a restart. Job snapshots show status: "sleeping" and a wakeAt Unix timestamp in milliseconds. Repeated sleep requests keep the latest wake time. Durations can be from 1 millisecond to 24 hours.

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

Use the service's Retry-After value when available, converting seconds or an HTTP date to milliseconds. In this example, the rejected action remains available for explicit retry; sleeping does not automatically repeat it. Your endpoint chooses when retries are safe. Place job.sleep(...) directly between job steps when subsequent steps must wait. Inside a helper or iteration it requests the cooldown without suspending the rest of that currently executing helper or iteration, so use job.fail to end a rejected retryable block, as shown above. Sleep is available only in jobs.

Choose what pauses

The optional second argument selects the scope:

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

Executor scope pauses new items assigned to that executor while other executors continue. In local development, a job uses one executor, so this pauses all its new work. It does not identify an IP address. IP scope is not supported.

For account-specific cooldowns, declare throttle on the parallel loop:

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

key="deliveries" names the progress counter. throttle selects a shared cooldown key for each item. Use a stable string of 1–200 characters, calculated from the item or job input without making requests. Matching keys share a cooldown across this job's executors and loops; other jobs are unaffected. Include the service name when the same account can use several independently limited services.

Keyed sleep postpones matching items and permits other ready items to run. It does not interrupt requests already running, and distributed cooldown propagation is not instantaneous. The scheduler looks ahead through a bounded window; unrelated items behind a long run of paused items may also wait. Explicit retries retain and respect their original throttle key.

Up to 128 distinct keys can be paused at once. If concurrent executors together exceed that limit, the job conservatively pauses until the latest cooldown expires. A direct attempt to add more than 128 keys in one executor is rejected. Repeated cooldowns extend the deadline; shorter requests never shorten it. Cooldowns do not automatically retry failed actions or suspend the rest of the calling block.

Continue with Retry selected job work.