On this page
Make actions safe to retry
Use dedupe and validate signed webhook requests.
Before you begin: Call an endpoint from a page.
Dedupe
Use dedupe when a request may be repeated by the browser, a user double-click, a network retry, or an external callback.
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.
With a dedupe key:
| Situation | Result |
|---|---|
| First request for a key | The endpoint runs normally. |
| Same key, same request, already completed | Frontbacked returns the saved response. |
| Same key, same request, still running | HTTP 202 with { "ok": true, "status": "processing" }. |
| Same key after a server failure (5xx) | The request can retry. |
| Same key after a validation failure (4xx, except wallet confirmation and rate limiting) | Frontbacked returns the saved failure. |
| Same key, different body, query, route parameters, method, or path | HTTP 409 Conflict; the action does not run again. |
Keys are scoped to the site and endpoint. Frontbacked uses the developer’s key without adding a user identity. Include $actor.id when the action belongs to a user; for webhooks, use the sender’s stable event ID. Place authorization checks before dedupe to check them on every request. A saved response stops execution at the dedupe statement; later checks and actions do not run.
Frontbacked does not automatically rerun failed endpoints. The caller decides whether and when to retry, using the same key and request. A server failure (5xx) leaves the attempt retryable instead of permanently replaying that failure. HTTP 202 means the attempt is still processing; wait before checking again. Do not retry every non-200 response: validation failures need correction, and a key conflict needs a different key for a genuinely different action.
Completed responses remain replayable: a completed key never starts a new purchase, even after its payment expires. Generate a new attempt ID for a new purchase or to replace an expired payment. Generate the ID once in the browser and keep it across retries and reloads; do not generate it inside the endpoint.
A payment created inside a deduplicated endpoint is recovered when the same attempt retries after an interruption. Reusing that payment attempt with different payment details is rejected. Keep payment calls and their ordering stable during retries. Built-in endpoint writes and the saved successful response commit together. Calls to external services still need the external service’s own idempotency support.
Saved responses and payment expiry
Dedupe saves the endpoint response, whether it contains a payment, a newly created record, or a custom result. A completed matching request returns that saved response without rerunning the action or refreshing the data inside it. Fetch the resource separately when you need its current state.
For example, an endpoint returning payment.create(...) first returns payment A with its original payment details. If payment A later succeeds or expires, the same key and matching request still replay that original endpoint response, including payment A’s ID. The response may still describe the payment as pending because it is a snapshot. The payment widget fetches the current payment state by ID.
Payment expiry does not expire or reset the dedupe key. Reusing a completed key cannot extend the payment’s expiry, generate fresh payment instructions, or create payment B. To replace an expired payment, start a new checkout attempt with a new key. If the original endpoint was interrupted before its response was saved, recovery still refers to payment A rather than creating a replacement under the same key.
Headers are excluded from the request comparison, allowing retries to carry fresh authorization tokens, webhook signatures, or delivery timestamps. Checks before dedupe still validate each request. If a header identifies a different action, include that value explicitly in the dedupe key.
For a conflict, Frontbacked returns:
Send the original request to retry the same action. Use a new key only when intentionally starting a different action; automatically changing keys after errors defeats duplicate protection.
Good keys are deterministic and scoped to the real-world action:
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
Avoid random keys for repeat-safe endpoints:
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
A random key changes on every retry, so Frontbacked cannot tell that two requests are the same action.
Signed Webhooks
For third-party callbacks, verify the signature before writing anything. Use $request.rawBody for the signed payload unless the provider documents a different signed string.
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.
Continue with Save records in an endpoint.