API

Hero image for API

Errors processing

The conventional HTTP status codes must be used to indicate the success or failure of an API request. In general:

  • Codes in the 2xx range indicate success.
  • Codes in the 4xx range indicate an error that failed given the information provided (e.g., required parameters missing, invalid pin or OTP, invalid token, etc.).
  • Codes in the 5xx range indicate an error with the servers.

Regardless of the HTTP status code, add an error_code that references the occurring error to make the error payload more explicit for consumers. For example, some 4xx errors that could be handled programmatically for different reasons (e.g., expired token or invalid login credentials) with the same HTTP status code.

These error codes from error objects shall be well documented so that the team consuming the API (i.e. mobile or front-end) can properly handle the errors in their client apps.

Check out more about the JSON:API error objects for reference