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.
31 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} — If-Match does not match current version (Friends API) Open & run this endpointDELETE https://funapi.dev/api/friends/v1/characters/{id} — If-Match does not match current version (Friends API) Open & run this endpointDELETE https://funapi.dev/api/superheroes/v1/heroes/{id} — If-Match does not match current version (Superhero API) Open & run this endpointPUT https://funapi.dev/api/pizza/v1/orders/{id}/status — If-Match does not match current version (Pizza Orders API) Open & run this endpointPUT https://funapi.dev/api/coffee/v1/orders/{id}/ready — If-Match does not match current version (Coffee Shop API) Open & run this endpointDELETE https://funapi.dev/api/football/v1/teams/{id} — If-Match does not match current version (Football API) Open & run this endpointPUT https://funapi.dev/api/movies/v1/movies/{id}/rating — If-Match does not match current version (Movies API) Open & run this endpointDELETE https://funapi.dev/api/movies/v1/movies/{id} — If-Match does not match current version (Movies API) Open & run this endpointPUT https://funapi.dev/api/wizarding/v1/students/{id} — If-Match does not match current version (Harry Potter API) Open & run this endpointDELETE https://funapi.dev/api/wizarding/v1/students/{id} — If-Match does not match current version (Harry Potter API) Open & run this endpointPUT https://funapi.dev/api/galaxy/v1/characters/{id} — If-Match does not match current version (Star Wars API) Open & run this endpointDELETE https://funapi.dev/api/galaxy/v1/characters/{id} — If-Match does not match current version (Star Wars API) Open & run this endpointPUT https://funapi.dev/api/holmes/v1/suspects/{id} — If-Match does not match current version (Sherlock Holmes API) Open & run this endpointDELETE https://funapi.dev/api/holmes/v1/suspects/{id} — If-Match does not match current version (Sherlock Holmes API) Open & run this endpointPUT https://funapi.dev/api/pokemon/v1/pokemon/{id} — If-Match does not match current version (Pokémon API) Open & run this endpointDELETE https://funapi.dev/api/pokemon/v1/pokemon/{id} — If-Match does not match current version (Pokémon API) Open & run this endpointPUT https://funapi.dev/api/middleearth/v1/fellowship/{id} — If-Match does not match current version (Middle-earth API) Open & run this endpointDELETE https://funapi.dev/api/middleearth/v1/fellowship/{id} — If-Match does not match current version (Middle-earth API) Open & run this endpointPUT https://funapi.dev/api/office/v1/employees/{id} — If-Match does not match current version (The Office API) Open & run this endpointDELETE https://funapi.dev/api/office/v1/employees/{id} — If-Match does not match current version (The Office API) Open & run this endpointPUT https://funapi.dev/api/dinopark/v1/dinosaurs/{id} — If-Match does not match current version (Dino Park API) Open & run this endpointDELETE https://funapi.dev/api/dinopark/v1/dinosaurs/{id} — If-Match does not match current version (Dino Park API) Open & run this endpointPUT https://funapi.dev/api/marvel/v1/heroes/{id} — If-Match does not match current version (Marvel API) Open & run this endpointDELETE https://funapi.dev/api/marvel/v1/heroes/{id} — If-Match does not match current version (Marvel API) Open & run this endpointPUT https://funapi.dev/api/got/v1/nobles/{id} — If-Match does not match current version (Game of Thrones API) Open & run this endpoint…and 6 more endpoints across the catalog.
All HTTP status codes · All 39 mock REST APIs · Getting started guide
Last updated