400

Bad Request

4xx · Client Error common

Overview

400 Bad Request is a generic client error meaning the request is malformed and the server cannot process it — broken body syntax, invalid framing, or failed basic validation.

The most common causes are malformed JSON, missing required parameters, and a mismatched Content-Type. It means the server could not understand the request at the syntax level, which is a different layer from authentication (401) or authorization (403).

When it happens

Request / Response example

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

{"name": "Ada", }
Response
HTTP/1.1 400 Bad Request
Content-Type: application/json

{"error":"Malformed JSON","detail":"Unexpected token '}' at position 15"}

In code

app.post('/api/users', (req, res) => {
  if (!req.body || typeof req.body.name !== 'string')
    return res.status(400).json({ error: 'name is required' });
  // ...
});
from flask import abort, request
@app.post('/api/users')
def create():
    if not request.is_json:
        abort(400, 'expected application/json')
    return {}, 201

Common causes

How to fix

Notes

Related status codes

Related headers

Specification