Errors people can act on
State the problem and the next useful action.
Name the field or operation
“Invalid request” offers little help. A response can identify the affected field and explain the expected shape without exposing internal implementation details. Keep the language consistent between the API reference and the response.
Do not promise a retry will help
A corrected input, new authentication and a later retry are different actions. Only suggest retrying when the operation and failure mode support it. Repeated non-idempotent requests can create unwanted duplicates.
Separate human and machine needs
A stable error code helps a client decide what to do. A readable message helps a person understand why. Do not make the client parse a sentence whose wording may change, and do not require a person to decipher a bare numeric code.