Save records in an endpoint
Guard related writes and order multi-step actions.
Before you begin: Make actions safe to retry.
Endpoint Writes
Endpoint bodies can use controlled write helpers when the endpoint should create, edit, or delete related posts.
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.
Pair endpoint-created records with dedupe when repeats would be harmful. Frontbacked generates the related post id, and the exact string "$id" can be used inside the related post data when that generated id should be copied into a normal field.
Use post.createAsSystem(...) for automatic endpoint work such as webhook imports, logs, and background records. Use post.createAsActor(...) only when the endpoint requires a signed-in visitor/admin and the created record should belong to that person.
Practical Patterns
| Pattern | Why endpoints help |
|---|---|
| Availability check | Return { ok, available } without storing a new post. |
| Quote calculator | Compute from settings posts, $currency, request body, and current user state. |
| Action button | Let one click perform a guarded server-side operation. |
| Callback-style workflow | Accept a structured payload, check it, and update related data. |
| Paid action | Use chargeUser(...) inside a guarded endpoint or hook when the action should require wallet confirmation. |
Keep endpoints small and explicit. If the result is a normal user-created record, prefer createPost. If the action needs a custom request shape, a custom response, dedupe, or controlled side effects, use an FRL endpoint.
Retrying after a reservation conflict
A failed checkout with code: "reservation_unavailable" and HTTP 409 is saved under its dedupe key. Reusing that key replays the failure even if capacity later becomes available. After showing the stock message, start the customer's next deliberate checkout attempt with a new key. Do not automatically retry in a loop.
A request fingerprint conflict instead returns code: "dedupe_conflict". Resolve the conflicting request before replacing its key. Keep the same key after network failures or uncertain outcomes so an existing payment is not duplicated. The wig theme demonstrates these distinct paths.
Rate-limit responses (429, code: "rate_limited") are retryable with the same key and unchanged request details after Retry-After. A rateLimit before dedupe also checks replay requests; one after dedupe runs only if execution continues. See Rate Limits and Abuse Protection.
Statement order
FRL executes endpoint statements in their written order, awaiting each action before continuing. Definitions such as schemas and named rate-limit policies remain declarations.
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.
Declare both rate-limit policies separately. The first policy checks every request reaching it. Authentication runs next. Dedupe may return immediately; only a request that continues reaches the second policy and checkout actions. A return or failed assertion stops all later statements. Moving a check across the dedupe line changes whether it runs on replay.
Named declarations follow the FRL naming rules. The system, system_…, and system.… names are reserved for Frontbacked, case-insensitively. Ordinary data fields are unaffected.
Admin Management Actions
Custom admin pages call the same named endpoints as other theme pages. Declare their navigation in backend/admin.json, then enforce permissions and validate the target inside each endpoint. Use post schemas for stored fields and must for operation-specific checks. See Theme admin pages for forms, safe writes, and the bank’s card-issuing example.