Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

400 Bad Request

The server cannot process the request due to client-side errors like malformed syntax.

When you see this status

  • Request body is not valid JSON
  • Missing required query parameters
  • Invalid data types in request payload
  • Malformed URL or headers

Common causes

  • Client sends malformed request syntax
  • Invalid request headers or payload
  • Missing required parameters
  • Syntax errors in query strings

How to debug it

  1. Validate request payload with JSON schema
  2. Check server logs for malformed input
  3. Inspect client-generated request
  4. Test with minimal payload to isolate issue

Return this code in your framework

Express (Node.js)
res.status(400).json({ error: 'Bad Request' });
FastAPI (Python)
return JSONResponse(status_code=400, content={"error": "Bad Request"})
NestJS
@Get() @HttpCode(400) getBadRequest() { return { error: 'Bad Request' }; }
Go (net/http)
w.WriteHeader(http.StatusBadRequest); w.Write([]byte(`{"error":"Bad Request"}`))

About HTTP 400

HTTP status code 400 Bad Request is part of the 4xx Client Error family. The server cannot process the request due to client-side errors like malformed syntax. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Should 400 always include a response body?

Yes, include a descriptive error message for debugging. Empty bodies hinder client-side error handling.

How to differentiate between 400 and 422?

400 indicates syntax errors (e.g., malformed JSON). 422 indicates semantic errors (e.g., invalid field values).

Can 400 be cached?

No. 400 responses are not cacheable per RFC 7234, as they indicate client errors that may not persist.