What is the correct status code for a request that is syntactically correct but violates business logic?
Last updated
Return
422 Unprocessable Entity: the request is well-formed and parseable, but it breaks a semantic or business rule (e.g. transfer amount exceeds balance).Not
400 Bad Request, which implies malformed syntax the server cannot parse. Some teams use409 Conflictfor resource-state rules (duplicates, version conflicts).Always include an error body explaining which rule failed.
- https://pulsetic.com/errors/422-unprocessable-content/
- https://beeceptor.com/docs/concepts/400-vs-422/
- https://medium.com/@jlaah2003/400-vs-422-which-one-should-you-use-3ed4213afdd5
- https://httpwg.org/specs/rfc9110.html
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422
- https://blog.postman.com/http-422-error/
- https://medium.com/@atunc8402/understanding-the-422-unprocessable-entity-status-code-490849ff6a20