A condition in the request headers was not met — almost always an If-Match ETag that no longer reflects the current state of the resource.
Defined in RFC 9110 §15.5.13 — 412 Precondition Failed · MDN reference
Optimistic concurrency — two people editing the same record, and the second write arriving with a version the server has already moved past.
The core of optimistic concurrency. If you never see a 412 in testing, your client is probably not sending If-Match at all, and lost updates are going unnoticed.
This is the code that stops a lost update, so treat it as a real outcome rather than an error. Re-fetch the resource, decide whether the change still applies to the new version, merge or prompt, and retry with the fresh ETag. Retrying with the same stale validator will produce the same 412 forever.
53 endpoints in this playground answer with 412. Every one is free, needs no signup, and can be called from the browser or with curl.
PUT https://funapi.dev/api/friends/v1/characters/{id} — Update a character (Friends API) Open & run this endpointDELETE https://funapi.dev/api/friends/v1/characters/{id} — Delete a character (Friends API) Open & run this endpointDELETE https://funapi.dev/api/superheroes/v1/heroes/{id} — Retire a hero (Superhero API) Open & run this endpointPUT https://funapi.dev/api/pizza/v1/orders/{id}/status — Update order status (Pizza Orders API) Open & run this endpointPUT https://funapi.dev/api/coffee/v1/orders/{id}/ready — Mark an order ready (409 if already ready) (Coffee Shop API) Open & run this endpointDELETE https://funapi.dev/api/football/v1/teams/{id} — Remove a team (409 if it has played matches) (Football API) Open & run this endpointPUT https://funapi.dev/api/movies/v1/movies/{id}/rating — Rate a movie (0–10 inclusive) (Movies API) Open & run this endpointDELETE https://funapi.dev/api/movies/v1/movies/{id} — Remove a movie (Movies API) Open & run this endpointPUT https://funapi.dev/api/wizarding/v1/students/{id} — Update a student (Harry Potter API) Open & run this endpointDELETE https://funapi.dev/api/wizarding/v1/students/{id} — Expel a student (Harry Potter API) Open & run this endpointPUT https://funapi.dev/api/galaxy/v1/characters/{id} — Update a character (Star Wars API) Open & run this endpointDELETE https://funapi.dev/api/galaxy/v1/characters/{id} — Remove a character (Star Wars API) Open & run this endpointPUT https://funapi.dev/api/holmes/v1/suspects/{id} — Update a suspect (Sherlock Holmes API) Open & run this endpointDELETE https://funapi.dev/api/holmes/v1/suspects/{id} — Clear a suspect (Sherlock Holmes API) Open & run this endpointPUT https://funapi.dev/api/pokemon/v1/pokemon/{id} — Update a Pokémon (level up, heal, etc.) (Pokémon API) Open & run this endpointDELETE https://funapi.dev/api/pokemon/v1/pokemon/{id} — Release a Pokémon (Pokémon API) Open & run this endpointPUT https://funapi.dev/api/middleearth/v1/fellowship/{id} — Update a fellowship member (Middle-earth API) Open & run this endpointDELETE https://funapi.dev/api/middleearth/v1/fellowship/{id} — Remove a member from the fellowship (Middle-earth API) Open & run this endpointPUT https://funapi.dev/api/office/v1/employees/{id} — Update an employee (The Office API) Open & run this endpointDELETE https://funapi.dev/api/office/v1/employees/{id} — Fire an employee (The Office API) Open & run this endpointPUT https://funapi.dev/api/dinopark/v1/dinosaurs/{id} — Update a dinosaur (Dino Park API) Open & run this endpointDELETE https://funapi.dev/api/dinopark/v1/dinosaurs/{id} — Relocate a dinosaur off-site (Dino Park API) Open & run this endpointPUT https://funapi.dev/api/marvel/v1/heroes/{id} — Update a hero (Marvel API) Open & run this endpointDELETE https://funapi.dev/api/marvel/v1/heroes/{id} — Retire a hero (Marvel API) Open & run this endpointPUT https://funapi.dev/api/got/v1/nobles/{id} — Update a noble (Game of Thrones API) Open & run this endpoint…and 28 more endpoints across the catalog.
All HTTP status codes · All 55 mock REST APIs · Getting started guide
Last updated