Skip to main content
HTTP/4xx (Client Error)

428 Precondition Required

The origin server requires the request to be conditional (If-Match) to prevent lost updates.

❓ Why does this happen?

API enforces optimistic locking and the client sent a PUT/PATCH without an If-Match ETag header.

✅ How to fix it

GET the resource first, read its ETag, then send it back in the If-Match header.

Return or handle 428 in your stack

// app/api/resource/route.ts
export function GET() {
  return Response.json(
    { error: "Precondition Required", status: 428 },
    {
      status: 428
    }
  );
}

Live 428 mock endpoint

Point your app, tests, or retry logic at this free public URL to reproduce a real 428 response (CORS enabled, optional ?delay=ms up to 5000).

https://castov.com/api/mock/428

428 vs similar status codes

Frequently Asked Questions

What does HTTP Status 428 mean?
The origin server requires the request to be conditional (If-Match) to prevent lost updates.
Why am I getting a 428 status code?
API enforces optimistic locking and the client sent a PUT/PATCH without an If-Match ETag header.
How do I fix a 428 Precondition Required error?
GET the resource first, read its ETag, then send it back in the If-Match header.
What is the difference between 428 Precondition Required and 412 Precondition Failed?
412 means a conditional header (If-Match) did not match. 428 means the server requires a conditional header and none was sent.
How can I test how my app handles a 428 response?
Send a request to https://castov.com/api/mock/428 — it returns a real 428 Precondition Required response with CORS enabled. Add ?delay=2000 to simulate a slow server.

Other 4xx status codes

Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.