DocsCustom actions · FRL
On this page

Limit repeated activity

Declare policies for records and account actions.

Protect sign-in, uploads, post operations, and checkout with reusable rate limits. Define sensible defaults in your theme and let site admins adjust selected policies in Abuse and protection.

Define a policy

frl

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

The label appears in the admin dashboard. Consecutive comments immediately above the definition become its description. Both // comments and /* block comments */ work; a blank line separates unrelated comments. Write these descriptions for site admins.

OptionMeaning
limitPositive whole-number allowance, up to 100,000.
windowDuration such as 30s, 10m, 1h, or 1d; from one second to one day.
by: actorSeparate allowance per signed-in account; guests use their client IP.
by: ipShared allowance for requests from the same client IP, including signed-in visitors.
adjustableOptional bounds for admin changes. Omit it to keep theme-defined values. All four bounds are required.
scopeOptional automatic coverage for an operation group, described below.

Allowances are separate for each site. A policy uses a fixed window starting with its first request; after that window ends, the next request starts a fresh allowance. Requests made just before and after a boundary can use both windows. Rate limits do not replace permissions or reservation rules.

Attach policies to post actions

Inside an existing post block, add:

frl

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

Declare product_list_attempts as its own policy before using it. Supported post actions are create, get, list, edit, and delete. Reusing a policy name shares its allowance across those actions and post types. Different policy names have independent allowances.

Each explicitly requested post or list selector counts as an operation, regardless of how many rows it returns. A query containing three protected list selectors consumes three units. Reads and writes performed by FRL inside an endpoint or hook do not consume a second public-operation allowance.

Built-in account protection

Every site automatically has separate Sign-in attempts (sign_in) and Sign-up attempts (sign_up) policies. No theme declaration or user binding is required. Both use the client IP, including when an account is already signed in. Unsuccessful attempts count too. For external sign-in providers, the sign-in allowance applies when the sign-in ticket is exchanged; fetching available providers and following redirects do not consume it. Creating a new account through a provider also checks the sign-up allowance.

PolicyDefaultAdmin allowance rangeAdmin window range
sign_in10 attempts per 10 minutes1–1001 minute–1 day
sign_up5 attempts per hour1–301 minute–1 day

Site admins can adjust these policies in Abuse and protection. To customize their defaults, labels, descriptions, or adjustment ranges, declare the reserved name:

frl

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

These customize the existing policies; they do not add duplicate checks. Omitted properties, including individual adjustment bounds, inherit the built-in defaults. The defaults must fit inside the adjustment bounds, and theme bounds must stay within the platform ranges above. These policies cannot be disabled, moved to another scope, or changed to by: actor. by: ip is optional and is the only accepted identity setting.

Do not bind sign_in or sign_up inside a user block, post, or endpoint: they already cover their account operations automatically. Other policies keep the usual explicit binding behavior.

A valid admin adjustment takes precedence over the theme defaults; theme defaults take precedence over the built-in defaults. If a theme update makes an existing admin adjustment invalid, the theme defaults apply. Restore defaults removes the admin adjustment and restores the current theme defaults, or the built-in defaults if the theme has no customization.

Add extra account policies

You can still attach additional named policies inside your user block:

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.

Define each referenced policy. Every applicable policy must pass. Account actions support create, get, edit, delete, signIn, resetPassword, and verifyEmail. Only operations exposed by your site's account APIs can trigger them.

Continue with Handle rate limits.