412
4xx Client ErrorPrecondition Failed
A precondition in the request headers evaluated to false.
412 Precondition Failed means a conditional header like If-Match or If-Unmodified-Since didn't hold, so the server refused to act. Its most useful job is optimistic concurrency: send If-Match with the ETag you last saw, and if someone else changed the resource since, you get a 412 instead of silently overwriting their work.
What 412 looks like on the wire
PUT /api/documents/33 HTTP/1.1 Host: api.example.com If-Match: "v41" HTTP/1.1 412 Precondition Failed ETag: "v42"
About 4xx Client Error
The request has a problem the client needs to fix, like a bad URL, missing auth, or invalid input.
How to fix 412 Precondition Failed
- Re-fetch the resource to get its current ETag, then retry with that value.
- Treat a 412 on a write as 'someone else edited this' and merge before retrying.
- Check that the client isn't caching and reusing a stale ETag.
Where it's defined
412 Precondition Failed is defined in RFC 9110 §15.5.13. MDN's 412 reference covers browser behavior and examples.