400 Bad Request

The server will not process the request because something about it is malformed.

Status

HTTP/1.1 400 Bad Request

Details

400 covers anything the server considers a client-side defect it cannot classify more precisely: invalid syntax in the request line, a malformed body, a header the parser rejects, or a framing error. It is the general-purpose client error, and a well-behaved API narrows it to something more specific whenever possible.

Because it is a catch-all, the body matters. A 400 that does not say which field or header was wrong forces the caller to guess, and guessing is what turns a five minute fix into an afternoon.

Common causes

How to fix it

As the client

As the server

Examples

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

{"quantity": }

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8

{"error":"invalid_json","detail":"Unexpected token } at position 13"}

Notes for proxy users

A proxy can produce a 400 of its own when the request it is asked to forward is malformed at the proxy layer, for example a CONNECT request to a host it cannot parse or a request line with an absolute URL it rejects. If the same request succeeds directly but fails through the proxy, suspect the request line and header formatting rather than the target site.

Specifications

RFC 9110 §15.5.1

See also