Introduction
API Errors
Understand and diagnose common KPay API errors.
Error response format
All errors follow a consistent envelope. The <code>message</code> field is always present.
Error
{
"statusCode": 400,
"message": "Description lisible de l'erreur",
"error": "Bad Request"
}Common error codes
Payment-specific errors
Withdrawal-specific errors
Troubleshooting tips
- Check the request format — required parameters present and correctly typed.
- Check authentication — correct keys, in the right headers, right environment.
- Inspect the message — the <code>message</code> field specifies the cause.
- Check the environment — a TEST key does not work in LIVE and vice versa.
- Re-read your logs — they often contain the context of the faulty request.
- Contact support with the complete error response and request detail (without the keys).
Error handling best practices
For transient errors (network, <code>429</code>, <code>500</code>), implement retry logic with exponential backoff; present clear messages to the user while logging the detail.
Node.js
async function requestWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const res = await fetch(url, options);
if (res.status === 429) {
const wait = Number(res.headers.get("Retry-After") || 1);
await new Promise((r) => setTimeout(r, wait * 1000));
continue;
}
if (res.status >= 500) {
await new Promise((r) => setTimeout(r, 2 ** attempt * 1000));
continue;
}
return res;
}
throw new Error("Échec après plusieurs tentatives");
}Related resources
Was this page helpful?