HTTP Status Codes / 4xx HTTP Status Codes / HTTP 400

400 Bad Request

This is an educational reference page about HTTP 400 Bad Request. The page itself is served as 200 OK so it can be indexed as HTTP documentation.

The server cannot or will not process the request because of something it sees as a client error, such as malformed syntax, invalid framing, or deceptive routing.

Specification

Registered in the IANA HTTP Status Code Registry as Bad Request. Defined in RFC 9110, Section 15.5.1.

What it means

HTTP 400 Bad Request means the server will not process the request because of a client error. RFC 9110 gives malformed syntax, invalid message framing, and deceptive request routing as examples. In APIs, 400 is the usual response for JSON that does not parse, missing required parameters, and query strings the server cannot read.

When to use it

Common causes

How to fix it

Examples

Malformed JSON

POST /api/orders HTTP/1.1
Host: api.example.com
Content-Type: application/json

{"sku":"A-100","quantity":2,

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

{
  "type": "https://api.example.com/problems/malformed-json",
  "title": "Request body is not valid JSON",
  "status": 400,
  "detail": "Unexpected end of input at line 1, column 29."
}

Common mistakes

Developer notes

Teams split 400 and 422 differently. A common rule is 400 when the server cannot parse the request and 422 when it can parse it but the values break a rule. Pick one rule, write it down, and use it everywhere in the API.

Questions

What does HTTP 400 Bad Request mean?

HTTP 400 means the server will not process the request because of a client error, such as malformed syntax or invalid framing.

Should invalid JSON return 400 or 422?

Invalid JSON should return 400 because the server cannot parse it. Use 422 when the JSON parses but the values fail validation.

Why do I get 400 Bad Request in the browser?

Common causes are a malformed URL, an oversized or corrupted cookie, or a request a browser extension modified. Clearing the site's cookies fixes many cases.

See also

Header and content rules

RFC 9110 adds no header or content rule specific to 400. The 4xx class rules also apply. See 400 in the response obligations table.

Related comparisons

Related API error guide

Use RFC 9457 Problem Details to add a standard application/problem+json body without changing the meaning of HTTP 400.

4xx client error – the request contains bad syntax or cannot be fulfilled


HTTP status code lookup
REST API status code chooser
cURL command generator
By Ping Now, a website/API/service uptime monitor
Data from Wikipedia