428
HTTPERRORNotable4xx Client ErrorHIGH confidence

Precondition Required

Production Risk

Low. It's a best practice for robust APIs, forcing clients to avoid accidental data overwrites. A client developer will see the error and know to implement conditional requests.

What this means

The origin server requires the request to be conditional. This response is intended to prevent the 'lost update' problem, where a client GETs a resource's state, modifies it, and PUTs it back to the server, while another client has modified the state on the server in the meantime.

Why it happens
  1. 1A client attempts to PUT or PATCH a resource without providing a conditional header like 'If-Match'.
  2. 2The server is configured to require optimistic concurrency control on all state-changing requests.
  3. 3This forces clients to be explicit about which version of a resource they are attempting to modify.
How to reproduce

A user tries to update a resource via an API without providing the 'If-Match' header containing the resource's current ETag.

trigger — this will error
trigger — this will error
PUT /api/items/123 HTTP/1.1
Host: example.com

expected output

HTTP/1.1 428 Precondition Required

Fix

Add a Conditional Header

WHEN Making a state-changing request to a server that requires it.

Add a Conditional Header
// First, GET the resource to find its ETag
// Then, include the ETag in the PUT request
PUT /api/items/123 HTTP/1.1
If-Match: "the-current-etag"

Why this works

Client-Side Logic

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All HTTP errors