Errors
How the API reports what went wrong, and what to do about it.
The API uses HTTP status codes to say what kind of failure happened, and a JSON body to say which one:
{
"success": false,
"error": {
"code": "BAD_REQUEST",
"message": "return_url must be one of the client's registered redirect URIs",
"details": { "return_url": "not a registered redirect URI for this client" }
}
}message is written to be read by a person: log it, and show it where it helps.
details, when present, names the fields at fault. Branch on the HTTP status
and code, never on the message text, which may change.
| Status | code | Means | What to do |
|---|---|---|---|
| 400 | BAD_REQUEST | The request is invalid, or not allowed in the payment's current state, e.g. capturing a payment nobody approved. | Fix the request. Retrying it unchanged will fail again. |
| 401 | UNAUTHORIZED | The access token is missing, expired or revoked. | Get a new access token. |
| 403 | FORBIDDEN | Your token is valid but lacks the scope, or the app can't do this (e.g. it isn't registered to a business). | Check the app's scopes and setup. |
| 404 | NOT_FOUND | It doesn't exist, or belongs to another app. | Check the reference. |
| 409 | CONFLICT | Something else changed the payment at the same moment, e.g. two captures at once. | Read the payment again, then decide. |
| 400 | IDEMPOTENCY_KEY_REQUIRED | The request moves money and carried no Idempotency-Key. | Send one. See Idempotency. |
| 409 | IDEMPOTENT_REQUEST_IN_FLIGHT | A request with this Idempotency-Key is still running. | Wait a moment, retry with the same key. |
| 422 | IDEMPOTENCY_KEY_REUSED | An Idempotency-Key was reused for a different request. | Use a new key. See Idempotency. |
| 429 | Too many requests. | Wait, then retry. See Rate limits. | |
| 503 | IDEMPOTENCY_UNAVAILABLE | We couldn't check the request for duplicates, so nothing ran. | Retry with the same Idempotency-Key after Retry-After. |
| 500 | INTERNAL_SERVER_ERROR, DATABASE_ERROR | Something went wrong on our side. | Retry with the same Idempotency-Key. |
Other shapes
A few responses come from layers in front of the endpoints and are shaped differently. Check the status first and you can handle them the same way:
- Missing or expired token,
401:{ "error": "unauthorized" } - Rate limited,
429:{ "error": "Too many requests. Please try again later.", "retry_after": 60 } - The OAuth endpoints (
/oauth/token,/oauth/revoke,/oauth/introspect) use the standard OAuth error shape,{ "error": "invalid_client", "error_description": "…" }, so OAuth libraries can read them. See Authentication.
Retrying safely
Retry 429 and 5xx responses, and network failures where you never got a
response, after a short wait that grows with each attempt. For anything that
creates or changes something, send an Idempotency-Key so a retry can't do it
twice. Don't retry other 4xx responses unchanged.