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/428428 vs similar status codes
Frequently Asked Questions
What does HTTP Status 428 mean?
Why am I getting a 428 status code?
How do I fix a 428 Precondition Required error?
What is the difference between 428 Precondition Required and 412 Precondition Failed?
How can I test how my app handles a 428 response?
Other 4xx status codes
Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.