What 428 Precondition Required means

428 Precondition Required tells the client to add an If-Match or similar conditional header before the server will process the request. This is a defense against the "lost update" problem: the server is saying "do not let me write this without you confirming you saw the latest version". You see 428 most often on PUT and PATCH endpoints that mandate optimistic concurrency control.

When servers should return it: Return 428 from PUT/PATCH endpoints that require ETag-based concurrency to prevent lost updates.

Common causes

  • PUT or PATCH without If-Match header
  • Server enforces optimistic concurrency on this resource

How to fix 428 Precondition Required

  • GET the resource first to obtain the current ETag
  • Send PUT/PATCH with If-Match: "etag-value"
  • Implement automatic conditional retry in your HTTP client

Example response

curl -i -X PUT -d '{"name":"Ada"}' https://api.example.com/users/42

HTTP/2 428
content-type: application/json
{"error":"precondition required","need":"If-Match header"}

More references

For a one-page reference of all HTTP status codes, see the HTTP cheat sheet. For testing API responses, try the API Tester tool. For inspecting responses on the command line, the curl cheat sheet covers the most common flags.