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

  1. Check the request format — required parameters present and correctly typed.
  2. Check authentication — correct keys, in the right headers, right environment.
  3. Inspect the message — the <code>message</code> field specifies the cause.
  4. Check the environment — a TEST key does not work in LIVE and vice versa.
  5. Re-read your logs — they often contain the context of the faulty request.
  6. 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?