Scope of 400 Bad Request

Here's the description of 422 Unprocessable Entity: The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415 (Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions. RFC-4918 Does it mean that I must return 400 Bad Request only in case of an incorrect syntax? For example, if a client tries to transfer a negative money amount, syntactically correctly, is 400 not appropriate, wrong? I believed 400 is something of a catch-all response code for all client errors when you can't or don't want to be more specific. An earlier RFC, 7231, seems to support this view: The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). RFC-7231 What's the true scope of 400?

May 31, 2025 - 03:50
 0

Here's the description of 422 Unprocessable Entity:

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415 (Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.

RFC-4918

Does it mean that I must return 400 Bad Request only in case of an incorrect syntax? For example, if a client tries to transfer a negative money amount, syntactically correctly, is 400 not appropriate, wrong? I believed 400 is something of a catch-all response code for all client errors when you can't or don't want to be more specific. An earlier RFC, 7231, seems to support this view:

The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

RFC-7231

What's the true scope of 400?