Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

428 Precondition Required

Server requires client to send a precondition header before processing request.

When you see this status

  • Client sends request without required If-Match or If-Unmodified-Since headers
  • Server enforces optimistic concurrency control but lacks precondition headers
  • Request modifies state but lacks conditional headers for conflict prevention

Common causes

  • Missing required conditional request headers
  • Server configured to require precondition checks
  • Client unaware of server's precondition requirements

How to debug it

  1. Verify request includes required If-Match or If-Unmodified-Since headers
  2. Check API documentation for precondition requirements
  3. Inspect server logs for missing header details
  4. Update client to include necessary conditional headers

Return this code in your framework

Express (Node.js)
res.status(428).send('Precondition Required');
FastAPI (Python)
from fastapi import status

@app.post("/")
async def create_item(request: Request):
    return JSONResponse(status_code=428, content={"detail": "Precondition Required"})
NestJS
import { HttpStatus } from '@nestjs/common';

@Post()
create(@Res() res) {
  res.status(HttpStatus.PRECONDITION_REQUIRED).send();
}
Go (net/http)
w.WriteHeader(http.StatusPreconditionRequired)

About HTTP 428

HTTP status code 428 Precondition Required is part of the 4xx Client Error family. Server requires client to send a precondition header before processing request. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Why does my API return 428 instead of 400 for missing headers?

428 explicitly indicates the server requires specific precondition headers, while 400 is generic for malformed requests.

Can I use 428 for any missing header?

No, 428 should only be used when the missing header is a precondition for processing the request.

How do I handle 428 in a client application?

Inspect the response, add the required precondition header, then retry the request with the header included.