4xx Client ErrorCommonly usedRFC 9110

400Bad Request

Server cannot process the request due to a client error.

What it means

The server cannot or will not process the request due to something wrong with the request itself — malformed syntax, invalid parameters, missing required fields, or invalid data. The client should not repeat the request without modification.

When to use it

  • Request body is malformed or invalid JSON
  • Required fields are missing
  • Field validation failed (wrong type, out of range)
  • Query parameters are invalid

Common causes

  • Sending invalid JSON in request body
  • Missing required fields
  • Wrong data types (string where number expected)
  • Invalid date formats

Code Examples

Express with Zod validation
typescript
import { z } from 'zod';

const schema = z.object({
  email: z.string().email(),
  age: z.number().min(18),
});

app.post('/users', (req, res) => {
  const result = schema.safeParse(req.body);
  if (!result.success) {
    return res.status(400).json({
      error: 'Invalid request',
      details: result.error.flatten(),
    });
  }
  // process valid data...
});

Quick Facts

Code400
CategoryClient Error
SpecRFC 9110
CommonYes
← Back to all status codes