HTTP 428 Precondition Required
4xx Client Error
- Home
- HTTP Status Codes
- 4xx
- 428
What is HTTP 428 Precondition Required?
The 428 (Precondition Required) status code indicates that the origin server requires the request to be conditional. This helps prevent the "lost update" problem where a client overwrites another client's changes without being aware of them. Clients should include a precondition header like If-Match or If-Unmodified-Since.
Common Use Cases
- Preventing lost updates in collaborative editing
- Ensuring atomic operations on shared resources
Usage Example
When building a collaborative document editor, require all update requests to include an If-Match header with the document's current ETag. If the header is missing, return 428 Precondition Required to remind the client to fetch the latest version first.
// Laravel - requiring If-Match header
if (! $request->header('If-Match')) {
return response()->json([
'error' => 'Precondition required',
'message' => 'Include If-Match header with current resource ETag',
], 428);
}
Related Status Codes
Common Mistakes
Mistake: Using 428 when the client did provide preconditions but they failed
Fix: If the client provided conditional headers but they evaluated to false, use 412 Precondition Failed. Use 428 only when the conditional headers are completely missing.