HTTP 412 Precondition Failed

One or more conditions in the request header fields evaluated to false.

4xx Client Error

412

Precondition Failed

Description

The 412 Precondition Failed status code indicates that one or more conditions given in the request header fields evaluated to false when tested on the server. This response code allows the client to place preconditions on the current resource state (its current representations and metadata) and thus prevent the request method from being applied if the target resource is in an unexpected state. Preconditions are typically specified using headers like If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since, and If-Range.

When Is It Used?

Returned when conditional request headers (such as If-Match with an ETag) fail. Used in optimistic concurrency control to prevent lost updates - for example, when two users edit the same resource simultaneously and the second update would overwrite the first.

Example Response

HTTP/1.1 412 Precondition Failed
Content-Type: application/json

{"error": "precondition_failed", "message": "The resource has been modified since your last request"}

Look Up Any Status Code

Browse all status codes