Skip to content
The HTTP Cabinet

/static/gabinete/en/curiosidade/428/

Menu

HTP-020 · Client errors (4xx)

428 Precondition Required

No If-Match, no deal: the code that prevents the lost update.

Two clients read the same resource, both write, and the second erases the first one's work without knowing — the lost update. RFC 6585 created 428 so the server can demand conditional requests: send it again, but with If-Match and the ETag of the version you read.

Careful REST APIs return it on PUT and PATCH without a precondition. It is the server teaching the client concurrency, one error at a time — and one of the few codes whose presence signals care on the emitter's side.

HTTP/1.1 428 Precondition Required
Content-Type: application/json

{"error": "PUT requires If-Match"}
Write only if nobody wrote in the meantime.