Are error objects optional in error responses?


With error responses, such as 4xx and 5xx, are error objects in the response optional?

From reading it seems like they are, but I’d like to confirm.




A document MUST contain at least one of the following top-level members:

  • data: the document’s “primary data”
  • errors: an array of error objects
  • meta: a meta object that contains non-standard meta-information.

The members data and errors MUST NOT coexist in the same document.

You are correct that the spec does not say that you MUST have at least one error document inside of the top-level errors key.


Also, the spec does not state that you MUST respond with any document, so it is perfectly valid to respond with an HTTP error code and no body.