DocsMessages & jobs
On this page

Run a background job

Start a job and show its progress.

Build imports, account provisioning, reports, and other automations that keep running after the visitor leaves the page. Start a job from an endpoint, return its ID immediately, and use that ID to reconnect to progress after a refresh.

A job is simply a named body of FRL. Your endpoint handles sign-in, permission checks, input validation, and dedupe. Jobs are private to the account that starts them.

Start a job

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.

The start response contains {id, status: "queued"}. Save id in page state, a URL parameter, or browser storage. The job receives the values you pass in $job.input; it has no $request. $job.id, $job.name, and $job.ownerId are also available. A job continues using the FRL definition it started with, even if the theme is subsequently updated.

Use your third-party API's actual request and response contract. External services follow the same approval and access rules as other FRL HTTP requests. A successful HTTP transport does not necessarily mean that the service accepted the operation; check its response in the retryable block.

Parallelism is independent of jobs

for_parallel accepts an array or arr.range(start, end). The end is exclusive. concurrency sets how many items can be in flight, from 1 to 512 inside a job and 1 to 64 in a request-bound loop; the default is 5. This is a ceiling, not a guaranteed number of active requests. Choose a value appropriate for the external service's rate limits. Higher values can increase load and cost without improving throughput. The local development server executes up to 64 iterations concurrently; large hosted jobs can use the full 512. Smaller jobs may use fewer executors to avoid unnecessary startup overhead.

frl

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

Each parallel iteration has its own $local and $context values. Assigning to them does not update another iteration or the surrounding loop's state. Use post operations such as post.increment for shared counters. Request-bound loops wait for all iterations and collect their staged writes in input order; they do not continue after the request ends. Large hosted jobs can execute across several workers while keeping one job ID and one concurrency limit for the entire loop.

Inside a job, use key="accounts" to name a progress group. Another loop might use key="emails". These names are your choice, not built-in account types. A sequential for can also have a progress key.

Job inputs and saved retry contexts support up to 64 KB of JSON each; each feedback payload supports up to 4 KB. Pass IDs for large existing records instead of copying their contents into a job.

Job loops support ranges of up to 100 million items and arrays of up to 10,000 items. Use ranges for large counts. A job can have up to 128 progress groups. Outside jobs, loops support at most 100 items. Put parallel loops and progress groups directly in the job body or its if branches; small sequential loops can also run inside helper functions. Nested parallel loops are not supported.

Parallel iterations have separate local and context values. Do not use a shared $context field as an accumulator across parallel items. Use progress groups, emitted feedback, or explicit post writes instead.

Continue with Display job progress.