logoAccess

Errors

Error response format, error types, and all error codes returned by the Access API.

All API errors return a consistent JSON body with machine-readable fields.

Error Format

Error response
{
  "error": {
    "type": "invalid_request_error",
    "code": "not_found",
    "message": "Customer not found.",
    "doc_url": "https://docs.tryaccess.xyz/docs/errors/not_found"
  }
}
FieldTypeDescription
typestringTop-level error category
codestringMachine-readable error code
messagestringHuman-readable description
paramstringPresent when a specific request field caused the error
doc_urlstringLink to the documentation for this error code

Error Types

TypeHTTP RangeDescription
invalid_request_error4xxBad input, missing fields, wrong types, resource not found
authentication_error401 / 403Missing or invalid API key
verification_error4xxPayment receipt verification failed
upstream_error502 / 503Bank or PSP service failure
api_error5xxUnexpected internal failure

Error Codes

Input / Validation

CodeHTTPDescription
parameter_missing400A required field was not provided
parameter_invalid400A field value failed validation
parameter_unknown400An unrecognised field was sent
invalid_psp400The specified PSP is not recognised

Resource State

CodeHTTPDescription
not_found404The requested resource does not exist
duplicate409A resource with the same identifier already exists
invalid_state400The action is not allowed in the current resource state
already_paid400The invoice is already marked as paid
already_voided400The invoice has already been voided
subscription_already_canceled400The subscription is already canceled or scheduled to cancel

Auth

CodeHTTPDescription
unauthorized401API key is missing or invalid
forbidden403API key does not have permission for this action
key_generation_failed500Failed to generate an API key

Verification Pipeline

CodeHTTPDescription
verification_failed400Payment could not be verified
tx_ref_not_found404Transaction reference not found at the PSP
image_fetch_failed400Could not retrieve the receipt image
image_extraction_failed400Could not extract data from the receipt image
extraction_failed400Data extraction from the receipt failed
date_parse_failed400Could not parse the date from the receipt
empty_input400No input was provided for verification

Upstream / PSP

CodeHTTPDescription
bank_fetch_failed502Failed to fetch transaction data from the bank or PSP
bank_url_build_failed500Could not construct the request URL for the PSP
unsupported_psp400The specified PSP is not supported

Upstream / Crypto

CodeHTTPDescription
crypto_payment_failed502A crypto payment operation could not be completed
crypto_payout_failed502A crypto payout could not be processed
crypto_currency_unavailable502The requested crypto currency is not available
crypto_estimate_failed502The conversion estimate could not be calculated
crypto_ipn_invalid400The crypto payment webhook signature is invalid

Database

CodeHTTPDescription
db_error500A database operation failed

Fallback

CodeHTTPDescription
internal_error500An unexpected internal error occurred

Handling Errors

Error handling
const response = await fetch("https://api.tryaccess.xyz/api/v1/customers", {
  headers: { "x-api-key": "ak_..." },
});

if (!response.ok) {
  const { error } = await response.json();

  switch (error.code) {
    case "unauthorized":
      // Check or rotate your API key
      break;
    case "not_found":
      // Resource does not exist
      break;
    case "parameter_missing":
      // Check error.param for the missing field
      console.error(`Missing field: ${error.param}`);
      break;
    default:
      console.error(`[${error.code}] ${error.message}`);
      // See error.doc_url for details
  }
}

How is this guide?