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": {
"type": "invalid_request_error",
"code": "not_found",
"message": "Customer not found.",
"doc_url": "https://docs.tryaccess.xyz/docs/errors/not_found"
}
}| Field | Type | Description |
|---|---|---|
type | string | Top-level error category |
code | string | Machine-readable error code |
message | string | Human-readable description |
param | string | Present when a specific request field caused the error |
doc_url | string | Link to the documentation for this error code |
Error Types
| Type | HTTP Range | Description |
|---|---|---|
invalid_request_error | 4xx | Bad input, missing fields, wrong types, resource not found |
authentication_error | 401 / 403 | Missing or invalid API key |
verification_error | 4xx | Payment receipt verification failed |
upstream_error | 502 / 503 | Bank or PSP service failure |
api_error | 5xx | Unexpected internal failure |
Error Codes
Input / Validation
| Code | HTTP | Description |
|---|---|---|
parameter_missing | 400 | A required field was not provided |
parameter_invalid | 400 | A field value failed validation |
parameter_unknown | 400 | An unrecognised field was sent |
invalid_psp | 400 | The specified PSP is not recognised |
Resource State
| Code | HTTP | Description |
|---|---|---|
not_found | 404 | The requested resource does not exist |
duplicate | 409 | A resource with the same identifier already exists |
invalid_state | 400 | The action is not allowed in the current resource state |
already_paid | 400 | The invoice is already marked as paid |
already_voided | 400 | The invoice has already been voided |
subscription_already_canceled | 400 | The subscription is already canceled or scheduled to cancel |
Auth
| Code | HTTP | Description |
|---|---|---|
unauthorized | 401 | API key is missing or invalid |
forbidden | 403 | API key does not have permission for this action |
key_generation_failed | 500 | Failed to generate an API key |
Verification Pipeline
| Code | HTTP | Description |
|---|---|---|
verification_failed | 400 | Payment could not be verified |
tx_ref_not_found | 404 | Transaction reference not found at the PSP |
image_fetch_failed | 400 | Could not retrieve the receipt image |
image_extraction_failed | 400 | Could not extract data from the receipt image |
extraction_failed | 400 | Data extraction from the receipt failed |
date_parse_failed | 400 | Could not parse the date from the receipt |
empty_input | 400 | No input was provided for verification |
Upstream / PSP
| Code | HTTP | Description |
|---|---|---|
bank_fetch_failed | 502 | Failed to fetch transaction data from the bank or PSP |
bank_url_build_failed | 500 | Could not construct the request URL for the PSP |
unsupported_psp | 400 | The specified PSP is not supported |
Upstream / Crypto
| Code | HTTP | Description |
|---|---|---|
crypto_payment_failed | 502 | A crypto payment operation could not be completed |
crypto_payout_failed | 502 | A crypto payout could not be processed |
crypto_currency_unavailable | 502 | The requested crypto currency is not available |
crypto_estimate_failed | 502 | The conversion estimate could not be calculated |
crypto_ipn_invalid | 400 | The crypto payment webhook signature is invalid |
Database
| Code | HTTP | Description |
|---|---|---|
db_error | 500 | A database operation failed |
Fallback
| Code | HTTP | Description |
|---|---|---|
internal_error | 500 | An unexpected internal error occurred |
Handling Errors
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?