Errors
Handle Paybytoken API errors, retries and request correlation safely.
Paybytoken uses HTTP status codes and a machine-readable error type. Most rejected API requests return:
{
"error": {
"code": 400,
"type": "validation_error",
"message": "currency is required"
}
}Treat the HTTP status as authoritative. Error messages are for diagnosis and may change; branch on
the status and type instead of matching message text.
Status codes
| Status | Meaning | Recommended handling |
|---|---|---|
400 | Invalid request or validation failure | Correct the request before retrying. |
401 | Missing or invalid credential | Check the bearer key and its test/live mode. |
402 | Payment required or insufficient balance | Show an actionable payment or balance state. |
403 | Permission or scope denied | Use a key with the required merchant permission. |
404 | Resource not found | Verify the resource ID and key mode. |
409 | Conflicting resource state | Retrieve current state before deciding the next action. |
410 | Session or credential expired | Create a new Checkout Session. |
422 | Request is valid JSON but cannot be processed | Correct the semantic input. |
429 | Rate limit exceeded | Back off before retrying. |
5xx | Paybytoken or an upstream service failed | Retry transient reads with bounded backoff. |
Retry safely
Use exponential backoff with jitter for 429, transient 5xx responses and network timeouts.
Cap the number of attempts and keep the customer informed.
Reads are safe to retry. For a mutation that accepts or requires Idempotency-Key, reuse the exact
same key only with the exact same logical request; the Node SDK exposes this as
{ idempotencyKey }. Do not blindly repeat other writes after a timeout because the original
request may have completed. Retrieve the related resource before deciding whether another action
is safe.
Webhook delivery is asynchronous and can repeat. Store each event ID with a unique constraint and make fulfillment idempotent.
Log useful context
Record:
- the response
X-Request-Id; - the HTTP method and path;
- the status and error type; and
- your own order or correlation ID.
Never record merchant API keys, chk_client_... values, webhook secrets, signatures or complete
one-time payment addresses.
For embedded browser failures, also see Checkout troubleshooting.
Did this page answer your question?
Your feedback helps us improve the integration path.