topic
Verified 2026-09-18API Validation and Error Responses
API validation should distinguish malformed syntax, unsupported media types, invalid fields, and conflicts with current resource state.
Use 400 for malformed request syntax, 415 for an unsupported representation format, 422 for semantically invalid content, and 409 for state conflicts. Return stable Problem Details with field-level extensions rather than leaking parser internals.
httpapivalidationerrors
Reference (http)
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json
{"type":"https://api.example.com/problems/validation","status":422,"invalidParams":[{"name":"email","reason":"invalid format"}]}Use 400 for malformed request syntax, 415 for an unsupported representation format, 422 for semantically invalid content, and 409 for state conflicts. Return stable Problem Details with field-level extensions rather than leaking parser internals.
Common mistakes
- Using 400 for every failure, returning a different error shape per endpoint, or exposing database and stack-trace details in validation responses.
Sources