Errors
The error document and the status codes the API answers
The API uses standard HTTP status codes: 2xx for success, 4xx for a problem with the request, 5xx for a problem on our side. Every error answers a JSON:API error document with Content-Type: application/vnd.api+json.
The error document
A business refusal looks like this:
Other codes you can meet are team_not_deleted_because_has_site_exception (deleting a team that still holds websites) and site_without_repository_user (issuing a login link for a website with no WordPress user synced).
A validation failure lists one error object per problem, so a single response can carry several entries in errors.
Status codes
Handling errors
- Branch on the HTTP status and on
statusand, when it is present, oncode. Do not branch ondetail: its wording can improve over time and differs between errors of the same status. - Show
detailto a person when it helps: it is written to be read. - Use
source.parameterto point at the field to fix.
