Skip to content
Last updated

Error handling

HTTP status codes

Every API response includes an HTTP status code that indicates the result of the request.

Success codes

CodeMeaningDescription
200OKRequest succeeded. The response body contains the requested data.
201CreatedA new resource was created successfully.

Client error codes

CodeMeaningDescriptionRetry?
400Bad requestThe request body is malformed or contains invalid data. Check field names, types, and required fields.No — fix the request
401UnauthorizedMissing or invalid API key, or invalid credentials on /v1/auth/keys.No — check credentials
403ForbiddenValid API key but insufficient permissions for the requested resource or action.No — check account role
404Not foundThe requested resource does not exist. Verify the endpoint URL and resource ID.No — check resource ID
409ConflictThe request conflicts with the current resource state (for example, voiding an already-settled transaction).No — check resource state
429Too many requestsRate limit exceeded. Wait and retry with exponential backoff.Yes — back off and retry

Server error codes

CodeMeaningDescriptionRetry?
500Internal server errorUnexpected server error.Yes — retry with backoff
502Bad gatewayGateway received an invalid response from an upstream service.Yes — retry with backoff
503Service unavailableThe service is temporarily overloaded or under maintenance.Yes — retry with backoff
504Gateway timeoutThe upstream service did not respond in time.Yes — retry with backoff

Error response format

When a request fails, the response body contains a structured JSON object with details about the error.

{
  "error": {
    "status": 400,
    "message": "Invalid request body",
    "details": [
      {
        "field": "amount",
        "message": "Amount must be a positive integer"
      }
    ]
  },
  "correlation_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
FieldDescription
error.statusHTTP status code (mirrors the response status)
error.messageHuman-readable summary of the error
error.detailsArray of field-level errors (when applicable)
error.details[].fieldThe request field that caused the error
error.details[].messageDescription of the validation failure
correlation_idUUID for tracing; include this when contacting support

Transaction response codes

Transaction responses include processor-level codes in addition to HTTP status codes. A 200 OK response does not necessarily mean the payment was approved — check the response_status and response_code fields.

{
  "id": "TRANSACTION-01JMRSPCK7XVNP3KS8F2W4T6Y",
  "transaction_state": "authorized",
  "response_status": "Approved",
  "response_code": "00",
  "response_message": "The API request is approved.",
  "correlation_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
FieldDescription
transaction_stateCurrent state of the transaction (for example, authorized, declined)
response_statusHuman-readable result: Approved, Declined, Error
response_codeProcessor result code (for example, 00 for approved)
response_messageDetailed explanation of the result

Common processor error codes

TSYS (credit card processor)

CodeMeaning
00Approved
01Refer to card issuer
02Refer to card issuer, special condition
05Do not honor
12Invalid transaction
14Invalid card number
51Insufficient funds
54Expired card

Vericheck (ACH processor)

ACH transactions may also return ACH return codes after settlement, which indicate issues discovered during clearing (for example, insufficient funds, account closed). These returns can arrive up to 60 days after the original transaction.

Handling errors in your application

Check the response status code first

image

Best practices

  • Always check response_status on 200 OK transaction responses. A successful HTTP response does not guarantee payment approval.
  • Log the correlation_id from every response. Include it in support requests so the team can trace the request.
  • Map processor codes to person-friendly messages. Do not display raw codes like 05 or 51 to persons. Instead, map them to clear messages like "Your card was declined. Please try a different payment method."
  • Implement retry logic for 429 and 5xx errors using exponential backoff with jitter. Always include an Idempotency-Key header on retries to prevent duplicate transactions.
  • Do not retry 4xx errors (except 429). These indicate a problem with the request that must be fixed before retrying.

For retry implementation details, see About best practices for integration.

Further reading