Skip to content

Errors

The API returns an error object with each unsuccessful request.

Backstack uses conventional HTTP response codes to indicate the failure of a request. Codes in the 4xx range indicate a request failed (i.e. a required parameter was omitted). Codes in the 5xx range indicate a system error.

Error object

json
{
  "error": {
    "request_method": "post",
    "type": "user",
    "code": 400,
    "message": "Required values are missing.",
    "fields": {
      "username": "This value is required.",
      "password": "This value is required."
    },
    "dev_message": "Unknown resource."
  }
}

INFO

The error.message is always suitable for user feedback. When the error type is user, details are provided to assist the user in recovery. Otherwise, the default "An error occurred. Please try again later." is provided.

PropertyTypeDescription
error.request_methodStringThe request method.Use this to evaluate your response message.
error.typeStringThe error type. (See error types for more information.)
error.codeIntegerThe error code. (See error codes for more information.)
error.messageStringThe error message. This value is always suitable for user feedback. When the error type is user, details are provided to assist the user in recovery. Otherwise, the generic "An error occurred. Please try again later." is provided.
error.fieldsArrayAn array of field names and their associated error messages for display in your UI.
error.dev_messagestringA message that better explains the issue.

Error types

You can also evaluate the error by checking the error.type. All errors are categorized by one of the following types.

TypeDescription
userAn error occurred as a result of user provided values (e.g. invalid password, required data missing).
codebaseThe request was invalid or missing required parameters that could not be provided by the user (e.g. uri, api keys, record IDs).
systemSystem errors indicate there was a problem on our end.

Error codes

CodeTypeDescription
400Bad RequestThe request was unacceptable, often due to missing a required parameter.
401UnauthorizedInvalid API initialization.
403ForbiddenThe API key doesn't have permissions to perform the request.
404Not FoundThe requested resource doesn't exist.
429Too Many RequestsToo many requests hit the API too quickly.
500Server ErrorsSomething went wrong on our end.