What does HTTP status code 400 mean?
The 400 Bad Request status code indicates that the server is unable to understand or process the request due to structural client errors (e.g., parsing errors, malformed headers, or bad syntax).
When to use it in APIs
Use 400 when the request body is syntactically invalid (e.g., malformed JSON) or when dynamic structural constraints fail before domain validation begins (like invalid cursor formats).
How it compares to other codes
- 422 Unprocessable Entity: Use 422 for semantically valid JSON payloads that fail business validation. Use 400 for payloads that cannot even be parsed.