DocsData & access · FRL
On this page

Protect your first record

Write a minimal FRL rule and follow a record action.

A Frontbacked theme is the reusable website package you ship: pages, styles, scripts, assets, optional skins, and optional rules for the data and actions the site supports.

Frontbacked Rule Language (FRL) gives that theme a protected data layer without making every theme become a server project. It answers four questions for every post type:

  1. What fields are allowed?
  2. How should incoming data be cleaned or computed?
  3. Who can create, get, list, edit, or delete this data?
  4. Should this action create related writes or async work?

FRL lives in the theme's single rules file: backend/index.frl.

What FRL Unlocks

FRL is more than a validation file. It is the place where a theme describes its data powers:

FeatureWhat it lets your theme do
version 2;Declare the current FRL grammar. Put it before any other statement.
post blocksDefine records such as articles, products, comments, plans, tickets, reviews, portfolios, or lessons.
user blockShape and validate custom signed-in user data.
schemaReject unknown fields and validate nested objects, arrays, enums, files, prices, defaults, and immutable fields.
before hooksTrim, normalize, compute slugs, set derived status, and prepare trusted fields before validation.
allow rulesDecide who can create, get, list, edit, delete, read, or write each post type.
after hooksRun follow-up work after validation and permissions pass.
Related writesCreate, edit, delete, or increment related posts after a successful action.
allow list(...) policiesControl who can list a post type and set default/max list limits.
endpoint.* blocksAdd custom guarded JSON endpoints for workflows that are not plain CRUD.
http.* helpersContact approved outside services from FRL with host review and loop protection.
must(...) and mustNot(...)Stop a hook or endpoint when a required assertion fails.
dedupeMake repeat endpoint requests return the same outcome instead of duplicating work.
$secretReference admin-filled private values without building custom settings forms.
as aliasesGive admin UIs friendlier labels for post types, fields, endpoints, secret keys, and private settings without renaming the stored data.

One Current Syntax

FRL uses version 2, including when the version declaration is omitted. Keep version 2; at the top of your rules to make the language version explicit. Version 1 rules must be migrated before use.

Older syntaxWrite this instead
await http.post(...)http.post(...); calls are awaited automatically.
promise(...) and on resolvedAn endpoint.* callback with dedupe and post.* writes.
profile or auth blocksuser with $user.current.data and $user.pending.data. Account access is controlled by site settings.
process or create process in a postbefore create, before edit, or another write hook.
Structural trigger blockspost.* helpers inside after hooks.
An endpoint's nested process blockStatements directly inside the endpoint.
idempotencydedupe.
str.id(length)random.id(length).
not value!value; use mustNot(...) for assertions.
validateExistsexists.
servertimeserverTime.
A fields { ... } wrapper inside schemaField declarations directly inside schema { ... }. Nested object fields still use fields: { ... }.

An after hook waits for its calls to finish. For queued notification delivery, use notification.send(...).

A Minimal Rule File

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.

This defines a leads post type. When a frontend page calls Frontbacked.createPost({ type: "leads", post }), Frontbacked applies the rule and either stores a clean, valid post or returns a useful error.

Rule Flow

For create, edit, and delete actions, Frontbacked evaluates a post rule in this order:

  1. Prepare rule values such as $post, $actor, $action, $admin, $secret, $page, $currency, and $this.
  2. Fill server-generated fields, then schema defaults for missing or null fields during create.
  3. Run every matching before hook in source order. before write runs for create, edit, and delete, and comma groups such as before create, edit share setup across selected actions.
  4. Validate the schema.
  5. Evaluate every matching allow rule. All of them must pass.
  6. Run matching after hooks for write actions when present.
  7. Materialize any related writes queued by post.* helpers.

get and list do not run before or after hooks. get checks single-post permissions, while list checks whether the visitor may request the list and what size the list may be. Use FQL where or filter to choose which rows appear in a list. Because allow read: also applies to list requests, allow read: and allow list: cannot use post-scoped values such as $post, $row, or $rowMeta, even through helper functions. If an action has no matching allow rule, Frontbacked denies it.

For webhook callbacks and delayed external work, use endpoint.* with dedupe and post.* helpers. That keeps callback handling in the same clear endpoint model as every other custom route.

Continue with Define record and account rules.