Precondition Failed
This error occurs when you attempt to update or delete a record, but the record was modified after you fetched it. In HTTP APIs, this is called an Optimistic Concurrency Collision or a Precondition Failure.
It acts as an automated safety shield to prevent “lost updates” — ensuring that one user’s changes do not silently overwrite another user’s simultaneous edits.
Error Response Example (RFC 9457)
Section titled “Error Response Example (RFC 9457)”{ "type": "https://docs.apinow.app/errors/precondition-failed", "title": "Precondition Failed", "status": 412, "code": "E_PRECONDITION_FAILED", "detail": "If-Match precondition failed. Current ETag '\"2\"' does not match '\"1\"'.", "hint": "Retrieve the latest version of the resource (GET /orders/101) before attempting this mutation.", "instance": "/orders/101"}What Caused This Error?
Section titled “What Caused This Error?”- Stale Revision (
If-Match): Your request included anIf-Matchheader containing a revision tag (ETag) from an older version of the record. Since you last read the record, another user, background job, or API call saved a new change. - Date Out of Sync (
If-Unmodified-Since): Your request included anIf-Unmodified-Sinceheader, but the record’s modification date is newer than the date you specified. - Missing Resource: You passed
If-Match: *(indicating the resource must exist), but the target record was not found.
Troubleshooting Guide
Section titled “Troubleshooting Guide”For API Consumers (Frontends & No-Code Apps)
Section titled “For API Consumers (Frontends & No-Code Apps)”- Fetch the Newest Data: Call
GET /resource/:idto retrieve the current state of the record and its latestETagheader. - Review or Merge Changes: Inspect the newest record or display a message to the user informing them that the record has changed.
- Retry the Save: Submit your
PUT,PATCH, orDELETErequest again, supplying the updatedETagvalue in theIf-Matchheader.
For API Authors (API & Domain Modeler Notes)
Section titled “For API Authors (API & Domain Modeler Notes)”- Automatic Revision Tracking: API Now automatically maintains revision tokens (
_etag) on all database tables for single-resource operations (UpdateandDelete). - Version Semantics: If your entity has a property tagged with the
Versionsemantic module, API Now evaluatesIf-Matchagainst clean sequential integers ("1","2","3") instead of internal hex tokens. - 1:1 Connected Records: Modifying a 1:1 sub-resource (e.g.
PUT /users/:id/profile) automatically updates the parent entity’sETagto prevent stale reads on the parent resource.