DevKits
412

Precondition Failed

4xx Client Error

Last updated:

A precondition given in the request headers (e.g. If-Match) evaluated to false.

Description

Used with ETag-based concurrency control. If the client sends If-Match: 'v1' but the server's current ETag is 'v2', respond with 412.

When to use

Return 412 on optimistic locking failures where an If-Match / If-Unmodified-Since header didn't match.

Specification

RFC 9110 §15.5.13

Examples

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

{"error":"Precondition Failed"}
Node.js (Express)
res.status(412).json({ error: "Precondition Failed" });
Go (net/http)
w.WriteHeader(http.Status412)
Python (Flask)
return jsonify({"error": "Precondition Failed"}), 412

Related status codes

All 4xx codes