Errors
Every error uses one JSON envelope with a stable type and code. Branch on code, show message to developers, log request_id.
Successful requests return 2xx. Anything else returns this body:
{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "amount: Too small: expected number to be >0",
"param": "amount",
"request_id": "req_7Gd2nQ0vXk"
}
}| Field | Description |
|---|---|
type | Broad category (below). Stable. |
code | Specific, machine-readable reason. Stable — branch on this. |
message | Human-readable explanation for developers. May change; don't parse it or show it to payers verbatim. |
param | The request field that caused the error, when there is one (e.g. amount, customer.email). |
request_id | Unique ID of the request. Log it, and include it when you contact support. |
Types
type | HTTP | Meaning | Retry? |
|---|---|---|---|
invalid_request_error | 400 | The request is malformed or a parameter is invalid | No — fix the request |
authentication_error | 401 | Missing, invalid or wrong-environment API key | No |
permission_error | 403 | Valid key, but not allowed (scope, account state) | No |
not_found_error | 404 | The object doesn't exist or isn't yours | No |
conflict_error | 409 | The object's current state doesn't allow this action | No — re-read the object |
idempotency_error | 409 / 422 | Idempotency-Key in use or reused with a different body | 409: yes, later · 422: no |
rate_limit_error | 429 | Too many requests | Yes, with backoff |
acquirer_error | 502 | The acquiring bank failed or timed out | Yes, with the same idempotency key |
api_error | 500 / 503 | Something went wrong at ePay | Yes, with the same idempotency key |
Common codes
| HTTP | code | When |
|---|---|---|
| 400 | parameter_invalid | A field failed validation — see param |
| 400 | parameter_missing | A required field is missing — see param |
| 400 | currency_unsupported | The currency isn't enabled for your account |
| 400 | invalid_cursor | The pagination cursor is malformed |
| 400 | idempotency_key_invalid | Idempotency-Key longer than 255 characters |
| 400 | payment_not_refundable | Refunding a payment that isn't succeeded/partially_refunded |
| 400 | refund_exceeds_payment | Refund amount exceeds what's still refundable |
| 401 | api_key_missing | No Bearer token |
| 401 | api_key_invalid | Unknown, revoked, expired or malformed key |
| 401 | api_key_environment_mismatch | sk_test_ key on production or sk_live_ key on sandbox |
| 401 | publishable_key_not_allowed | A pk_… key was used |
| 403 | missing_scope | The key lacks the endpoint's scope |
| 403 | merchant_not_active | Your business isn't active (production verification pending, or suspended) |
| 404 | resource_missing | No such object for your account |
| 409 | payment_not_cancelable | Canceling a payment that isn't requires_payment |
| 409 | idempotency_key_in_use | A request with the same key is still being processed |
| 422 | idempotency_key_reused | Same key, different request body |
| 429 | rate_limited | Slow down; retry with exponential backoff |
| 503 | environment_mismatch | ePay-side configuration safeguard tripped; retry later and contact support if it persists |
Handling errors well
- Retry only what's retryable: network errors,
429,5xx, and409 idempotency_key_in_use. Use exponential backoff with jitter (e.g. 0.5 s, 1 s, 2 s, 4 s … capped) and the sameIdempotency-Key, so a retried create can't double-charge or double-refund. - Don't retry
4xxvalidation errors — they'll fail the same way. - Map
paramto your form fields when the input came from a user (for example a payment-link amount). - Payment declines are not API errors. A declined card doesn't fail any API call: the payment stays
requires_paymentwithfailureset and you receivepayment.failed. See payment statuses.

