DocsPermissions & hooks · FRL
On this page

Protect record actions

Choose allowed actions using actor and admin permissions.

Permissions are written with allow rules. A post action is allowed only when every matching permission expression resolves to a truthy value.

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.

If an action does not have an allow rule, the action is denied.

Actions

ActionWhen it runs
createA new post is being created.
getOne post is being fetched.
listA collection of posts is being fetched.
readA grouped permission that applies to both get and list.
editAn existing post is being updated.
deleteA post is being deleted.
writeA grouped permission that applies to create, edit, and delete.

Each concrete action can have a separate rule because safe single-post access is often different from safe list access. Use allow read: expression when the same expression should protect get and list, allow write: expression when the same expression should protect create, edit, and delete, or comma-separated actions such as allow create, edit: expression when a smaller group shares one rule.

Use comma-separated grouped actions when the same broad condition should cover every read and write action:

frl

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

Matching rules intersect. If a rule file declares allow read, write: ..., allow read: ..., and allow get: ..., a get request must pass all three matching rules.

allow list: decides whether a visitor may request a list. Use FQL where or filter to choose which rows appear in that 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. This also applies inside helper functions called from list permissions. Put single-post conditions in allow get: instead.

Runtime Values for Permissions

Permission expressions commonly use these variables:

VariableUse
$post.current.dataThe saved post data before the action. Useful for published/draft and owner checks.
$post.currentBackend metadata for the saved post, such as id and author id.
$post.pending.dataThe submitted or merged data that will be saved. before create and before edit hooks write here.
$post.pendingBackend metadata for the pending write, including the generated id during create.
$actionMetadata for the current operation. $action.where contains requested read filters, $action.payment names the current payment event, $action.isRead is true for get/list, and $action.isWrite is true for create/edit/delete.
$actorCurrent requester. Use $actor.id, $actor.email, $actor.name, $actor.data, $actor.wallet, $actor.isGuest, $actor.isSignedIn, $actor.isAdmin, $actor.isEndpoint, and $actor.endpoint when available.
$adminContent permission helpers for FRL-managed posts and profile data.
$secretSecret credentials referenced by FRL. fb-admin automatically creates Secret Keys fields for referenced keys.
$pagePage settings from the site's page settings.
$currencySite currency config, including value, baseCurrency, and the selected support mode when configured.
$contextScratch values for the current rule run. Write it in before hooks, after hooks, endpoint bodies, and event blocks; read it in allow rules and helper functions.
$localScratch values inside one fn call. Use it when a helper needs temporary values before returning a result.

Admin Permission Helpers

Use $admin.canRead(...), $admin.canCreate(...), $admin.canEdit(...), and $admin.canDelete(...) when the current user must have site-admin permission for FRL-managed content.

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.

Pass a post type for post-level permission, or a field path for field-level permission:

frl

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

Field checks inherit from broader permissions. For example, products.price.amount passes when the admin has permission for products.price or products. Array indexes are ignored, so products.images[0].url is checked like products.images.url.

Inside a post or user rule, $this means the current post type. For example, inside post products, $admin.canEdit("$this.name") is checked as products.name.

Calling a helper with no argument checks all-post permission for that action across FRL-managed content:

frl

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

That no-argument form is useful for broad admin dashboards. Prefer resource-specific checks when a rule protects one post type or one sensitive field.

Continue with Apply ownership rules.