400 Bad Request
The HTTP status meaning the request is malformed or asks for something outside what the API allows, such as a page size above the maximum.
In more detail
Use a more specific 4xx code when one fits, and always explain the problem in a problem details body. Repeating the same request will fail again, so the client must change it.
Examples
In the APIs course: The course service answers 400 for a limit outside 1 to the maximum and for an unsupported sort key.The course's strict signup answers unknown fields with a bad request that names them, turning schema probing into a visible signal.Related terms
- HTTP status code — The three-digit number at the start of a response, such as 200 or 404, that says how the server handled the request.
- Problem Details — A standard JSON shape for HTTP error responses, defined in RFC 9457, with members such as type, title, status, detail and instance.
- input validation — Checking that data from a user, file or caller is acceptable before using it, and rejecting or asking again if not.
- model validation — Checking that incoming data meets the rules, such as required fields and ranges, before the application acts on it.
- field error — A validation failure tied to one input field, reported with the field name and a message such as "must not be blank".
- mass assignment — A bug where a handler copies every field of a request body into a data model, so a caller can set fields such as role or balance that were never meant to be writable.
- schema validation — Checking incoming data against a declared shape, such as allowed field names and types, and rejecting anything that does not fit.
Taught in
- Headers And Content Negotiation — Modern API Architecture: REST, GraphQL & gRPC
- Sorting Results — Modern API Architecture: REST, GraphQL & gRPC
- Security Best Practices — Modern API Architecture: REST, GraphQL & gRPC
- Model Validation and FluentValidation — Modern .NET Core, C# & Enterprise Microservices
- Exception Handling To Problem Details — Modern Java: Virtual Threads & High-Throughput Services
- Mass Assignment — Application Security & Threat Modeling for Engineers