Reference

Error Handling

CamelPay returns consistent error responses with HTTP status codes and machine-readable error details.

HTTP Status Codes

CodeMeaningAction
200SuccessProcess response
201CreatedResource created
400Bad RequestCheck request body and parameters
401UnauthorizedVerify API key or JWT token
402Payment RequiredInsufficient wallet balance
403ForbiddenMissing scope on your API key, or account not KYC-verified
404Not FoundResource doesn't exist
409ConflictDuplicate idempotency key or resource
422Unprocessable EntityValidation failed — check errors array
429Too Many RequestsRate limit exceeded — implement backoff
500Server ErrorRetry with exponential backoff
503Service UnavailableA feature flag is temporarily disabled

Error Response Format

json
{
  "success": false,
  "data": null,
  "message": "Validation failed",
  "errors": [
    {
      "field": "phone_number",
      "message": "invalid format"
    }
  ]
}

Retry Strategy

For 5xx errors and network failures, use exponential backoff:

async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      if (error.status >= 500 || !error.status) {
        await new Promise(r => setTimeout(r, Math.pow(2, i) * 1000));
      } else {
        throw error; // Don't retry client errors
      }
    }
  }
}

Error Code Reference

CodeFieldMessageFix
400slugpayment page not foundVerify slug exists
400amountmust be >= 500Increase amount
401—missing X-API-Key headerAdd API key header
401—invalid or expired API KeyCheck key validity
402—insufficient wallet balanceTop up wallet
403—insufficient scopesGrant the required scope to this key
403—KYC verification requiredComplete verification before creating pages/payouts
409—duplicate idempotency keyUse a new key
422phone_numberinvalid formatUse E.164 format
429—rate limit exceededImplement backoff