Use request and event context
Read endpoint, payment, actor and secret values.
Before you begin: Define record and account rules.
Custom Endpoints
Use endpoint.get, endpoint.post, endpoint.put, endpoint.patch, or endpoint.delete when a theme needs a guarded JSON route that is not just storing one post.
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 theme calls it by name with Frontbacked.endpoints.call("estimateReturn", { body }). Direct HTTP callers can use /fb-endpoints/investments/estimate. See Endpoints and Dedupe for request fields, repeat-request behavior, path params, cancellation, and endpoint write helpers.
Payment Events
Use payment created, payment underpaid, payment confirmed, and payment failed when a theme needs to react to payment lifecycle events.
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
Use confirmed, not successful, in FRL event names. Stored transaction rows can still expose successful to FQL, but $payment.status is normalized to confirmed inside FRL payment events.
Rule Context
FRL expressions use rule variables. The most common are:
| Variable | Meaning |
|---|---|
$post.current.id / $post.pending.id | The generated id for the current post. In a user hook, use $user.id. |
$post.current.data | Saved post data for get, edit, and delete checks. Empty during create. |
$post.current | Post metadata for the saved post. |
$post.pending.data | New or edited data that will be saved. Write this in before create and before edit. |
$post.pending | Post metadata for the pending write, including the generated id during create. |
$payment | The current payment during payment created, payment underpaid, payment confirmed, and payment failed events. |
$user | The affected user inside user hooks. Read $user.id, safe $user.current and $user.pending state, and $user.changes during edits. |
$action | Metadata for the current operation, including requested read filters at $action.where, the current payment event at $action.payment, and booleans such as isCreate, isGet, isRead, isList, isEdit, isDelete, isWrite, and isSignIn. |
$actor | The requester causing the rule run. Use $actor.id, $actor.email, $actor.data, $actor.wallet, $actor.isGuest, $actor.isSignedIn, $actor.isAdmin, $actor.isEndpoint, and $actor.endpoint. |
$admin | Content permission helpers such as $admin.canEdit("products") or $admin.canEdit("$this.name") for FRL-managed posts. |
$secret | Secret values referenced by the theme, such as $secret.PAYMENT_SECRET. fb-admin creates fields for referenced secret keys automatically. |
$page | Page settings from the site settings. These are edited through theme/page settings rather than the FRL admin forms. |
$currency | Platform currency config. $currency.value is a code such as USD or NGN; $currency.mode is currently fixed. |
$this | Current post type metadata, including field labels, defaults, and enum helpers such as $this.fields.status.enums.published. |
$context | Scratch data for the current rule run. Write it in hooks, endpoint bodies, event blocks, and jobs; read it in allow rules and helpers. |
$local | Scratch data inside one helper function call or job run. |
Admin Fields from $secret
Declare every $secret.someKey at the top of backend/index.frl, immediately after version 2;. Give it a compulsory display name and description so site owners know what to provide. Frontbacked builds a secure form from these declarations and rejects undeclared secret references during theme processing. Store business settings in protected posts and build their forms in your theme's admin pages. See Theme admin pages for a complete settings example.
Use as to give permissions, secret keys, and developer tools a clearer label:
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.
Aliases do not rename the underlying post type, field, endpoint, route, secret key, private key, query path, or permission path. The schema keyword itself cannot be aliased.
Continue with Calculate values in FRL.