DevKits
400

Bad Request

4xx Client Error

Last updated:

The server cannot process the request due to a client error (malformed syntax, invalid framing, etc.).

Description

The generic 'client screwed up' code. In practice, many APIs also use 400 for domain validation errors, though 422 Unprocessable Entity is a better fit for semantically-invalid but syntactically-valid input.

When to use

Return 400 for malformed JSON, missing required parameters, or invalid header formats.

Common pitfalls

Avoid returning 400 for authentication failures (use 401) or authorization failures (use 403).

Specification

RFC 9110 §15.5.1

Examples

HTTP response
HTTP/1.1 400 Bad Request
Content-Type: application/json

{"error":"Bad Request"}
Node.js (Express)
res.status(400).json({ error: "Bad Request" });
Go (net/http)
w.WriteHeader(http.StatusBadRequest)
Python (Flask)
return jsonify({"error": "Bad Request"}), 400

Related status codes

All 4xx codes