Errors
The one error envelope, its types and codes.
Every response from the API host with a status outside 2xx has the same JSON body, whatever
went wrong, including an unknown path, a wrong method, a body that is too large or a rate limit.
The one exception is a declined or failed charge: its 402 body is the payment itself (see
Statuses).
{
"error": {
"type": "invalid_request_error",
"code": "validation_failed",
"message": "Invalid value: invalid type: floating point `19.99`, expected i64.",
"param": "amount"
}
}
typeis one of the values below. Branch on it; the set only grows with a changelog entry.codeis a stable, more specific reason, such asnot_foundorrate_limited.messageis for people. Don't parse it.paramnames the request field at fault, when there is one, as a dotted path such ascustomer.countryormetadata.note.payment_idnames the payment the error is about, when there is one: the payment already holding areference, or the payment an operation was refused on.
Types
type | Typical status | Meaning |
|---|---|---|
invalid_request_error | 400, 404, 405, 409, 413, 422 | The request is malformed, names something that doesn't exist, or fails validation. |
authentication_error | 401 | No valid API key or signature. |
permission_error | 403 | The key may not do this (scope), or the merchant or project is suspended. |
idempotency_error | 409, 422 | The Idempotency-Key was used with another amount, currency or endpoint, or its first request is still running. |
rate_limit_error | 429 | Too many requests. Wait for the number of seconds in Retry-After. |
acquirer_error | 502, 504 | The acquirer could not be reached, or did not confirm the operation. |
api_error | 500, 503 | Something failed on our side. Retry with the same Idempotency-Key. |
Codes
| Code | Status | Meaning |
|---|---|---|
bad_request | 400 | The body is not valid JSON, or the request can't be parsed |
idempotency_key_required | 400 | A money request has no Idempotency-Key |
idempotency_key_invalid | 400 | The key is not 1–255 visible ASCII characters |
missing_credentials, invalid_key, key_environment_mismatch, timestamp_out_of_range, invalid_signature, replayed_request | 401 | See Authentication |
insufficient_scope, account_suspended | 403 | See Authentication |
not_found | 404 | No such path, or no such object in this project and environment |
method_not_allowed | 405 | The path takes other methods; see the Allow header |
duplicate_reference | 409 | The reference is used by another payment; payment_id names it |
payment_in_progress | 409 | Another capture, refund or void on this payment is running |
idempotency_key_in_use | 409 | The first request with this key is still running |
payload_too_large | 413 | The body is over 2 MB |
validation_failed | 422 | A field is missing, of the wrong type, too long or out of range; see param |
routing_unavailable | 422 | No payment channel takes this charge (currency, amount, environment). Nothing was created |
invalid_payment_state | 422 | The payment can't take this operation now, such as capturing a declined payment |
operation_declined | 422 | The acquirer declined the capture, refund or void |
idempotency_key_mismatch | 422 | The key was used with a different amount or currency |
idempotency_key_reused | 422 | The key was used on another endpoint |
rate_limited | 429 | See Rate limits |
internal_error | 500 | Our failure; retry with the same Idempotency-Key |
acquirer_unavailable | 502 | The operation never reached the acquirer; nothing changed |
acquirer_outcome_unknown | 502 | The acquirer didn't confirm the operation; check the payment before retrying |
service_unavailable | 503 | The request took too long or we are overloaded; retry with the same key |
A 405 carries an Allow header listing the methods the path accepts. A 429 carries
Retry-After.
Health
GET /v1/health answers {"status": "ok"} without a key. It checks only that the API is up.