Guides
Search documentation... ⌘K
API references
Working with the API

Error handling

How to interpret API responses and handle common error scenarios gracefully.

Overview

Reservepay uses a standardized error format called Error Triples. When a request cannot be processed, the API returns a 400 Bad Request status code with a JSON array containing three elements: a machine-readable code, a human-readable message, and additional details.

The Error Triple

Every error response follows this exact structure:

[ERROR_CODE, ERROR_MESSAGE, ERROR_DETAILS]
Element Type Description
Code string A unique, machine-readable identifier for the error (e.g., INVALID_ARGUMENTS).
Message string A short description of what went wrong, intended for developers.
Details any Additional data to help diagnose the issue. This can be an object, an array, or null.

When errors occur

The API only uses the 400 Bad Request status code for expected error conditions. This includes:

  • Validation failures: Missing required fields or invalid data formats.
  • Business logic errors: Insufficient funds, expired tokens, or invalid transitions.
  • Authentication issues: Missing or invalid API keys.

If you receive any other status code (like 500 or 404), it indicates an unexpected system error or a routing issue rather than a handled API error.

Working with details

The third element of the triple, ERROR_DETAILS, provides context that varies depending on the error code.

For validation errors, it often contains an array of specific field issues:

[
  "INVALID_ARGUMENTS",
  "One or more of the supplied arguments are invalid",
  [
    {
      "type": "invalid",
      "argument": "month",
      "message": "Invalid format, expected YYYY-MM, got 12/2025"
    }
  ]
]

In other cases, such as a generic authentication failure, the details might be null:

[
  "UNAUTHORIZED",
  "Invalid API key provided.",
  null
]

Your error handling logic should check if details is present before attempting to parse it.

Common errors

While specific endpoints may define their own error codes, here are some you will encounter across the API:

Code Description
INVALID_ARGUMENTS This error occurs when the request contains invalid or missing parameters. Common cases include missing required fields, or values that don't match the expected format or type.
NOT_FOUND This error occurs when some records could not be found for the given ID(s).
UNAUTHORIZED This error occurs when the request lacks valid authentication credentials.
BAD_VERSION This error occurs when making requests to an API version that does not exist. This commonly happens when using an outdated SDK or when the API version specified in the request URL is incorrect.
UNHANDLED_ERROR This error occurs when the server encounters an unexpected internal error that it cannot handle gracefully. This typically happens due to bugs, infrastructure issues, or edge cases that weren't anticipated during development.
Working with the API

Learn the fundamental concepts of the Reservepay API to build a robust and secure integration.

Calling the API

Understand the request and response structure that all of our API endpoints follows.

Read the guide
Authentication

Learn how to authenticate your requests using API keys for backend and Installation IDs for frontend.

Read the guide
Error handling

How to interpret API responses and handle common error scenarios gracefully.

Read the guide