Error body
Errors use the response envelope with error fields instead ofdata.
Branch on
status, not on the text of message. Messages are written for people and can change.
Three kinds of refusal are answered by the access checks before a request reaches the API and carry no body: 401, 403 from the key or host checks, and 400 for an ambiguous path. Handle them by status code alone.
Field errors
A400 caused by invalid input lists each problem in errors. Each entry names the field and says what is wrong.
Unknown field: '<name>'.
Status codes
Other client errors raised while handling the request, such as an unsupported media type, use the same envelope and the standard status code.