Skip to main content
This guide outlines how our API handles errors, providing consistent, structured information to developers to help them diagnose and respond to failures effectively.

HTTP Error codes

We follow industry standards for HTTP status codes and enrich them with detailed error information using the RFC 9457 Problem Details for HTTP APIs specification.

Standard Status Codes

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., a required parameter was omitted, etc.). Codes in the 5xx range indicate an error with our servers (these are rare).

Problem Details

When an error occurs, we return a JSON response conforming to RFC 9457. For example, a typical error response might look like this:
This standard ensures that each error response includes a consistent set of fields, such as:
  • type: A URI identifier for the error type.
  • title: A short, human-readable summary of the problem.
  • status: The HTTP status code.
  • detail: A human-readable explanation specific to the occurrence.
  • instance: A unique identifier for the error occurrence (can be used in support/debugging).
These fields help developers quickly understand the nature of the error and how to resolve it.

Application Error Codes

In addition to HTTP status codes, we provide application-level error codes for granular insight into what went wrong during a payment operation.

Error Object

When a payment attempt fails, the failure is recorded in the last_payment_error field of the response. This object is included in payment related responses and has the following structure:
The fields are:
  • error_code: A general error code indicating the high-level reason for failure, (e.g. card_declined). See Error Codes.
  • decline_code: A more specific code that explains why a card transaction was declined, typically provided by the issuing bank, payment processor, or credit card network. (e.g. insufficient_funds). See Decline Codes.
  • message: A human-readable message describing the error.
  • timestamp: An ISO 8601 timestamp indicating when the error occurred.

Error Codes

A general error code indicating the high-level reason for failure. The following are the possible values for the code field, along with their descriptions:

Mandate Error Codes

When processing payment sessions, mandates enable recurring or series-based payments. A mandate is created during a first_in_series payment by passing a mandate_options block, which defines the consent taken from the customer. This mandate is then associated with the customer’s payment method and enforced on subsequent next_in_series payments. If a mandate validation fails during a next_in_series payment, the API returns a synchronous error response in the standard RFC 9457 format:
The following mandate error codes may be returned:

Decline Codes

A more specific code that explains why a card transaction was declined, typically provided by the issuing bank, payment processor, or credit card network. The following are the possible values for the decline_code field, along with their descriptions and recommended rectification actions:

Best Practices for Clients

To ensure reliable and developer-friendly integrations, we recommend the following practices when handling errors from our API:
  • Always check the HTTP status code before attempting to parse the response body. Use it to determine the broad category of error (e.g., client-side vs. server-side).
  • Use the error_code field for internal application logic. This field is stable and maps to general error categories (e.g., card_declined). It’s ideal for branching error-handling flows or conditional retry logic.
  • Use the message field for human-readable error messages that can be logged or displayed in dashboards. This message is designed to be developer-friendly but not always end-user appropriate.
  • Use the decline_code field for additional context, especially for card-related failures. These codes represent issuer-specific reasons for declines and are useful for analytics, support tooling, or to tailor customer-facing messages when applicable.
  • Log the full last_payment_error object on failed payment attempts for easier debugging and operational visibility.
  • Retry only when appropriate:
    • Retry on 5xx errors with backoff.
    • Do not retry on 4xx errors unless explicitly documented as safe to do so (e.g. when rate limited).
  • Monitor for 402 - Request Failed errors to detect cases where the request has been accepted but the state of the object may indicate a processing error, for example a payment has been created, but the payment processing may still have failed.
  • Monitor for 422 - Unprocessable Content errors to detect integration issues, such as invalid payment state or business rule violations.