Overview
A production-quality integration needs to handle every possible failure case. This guide covers strategies for dealing with API errors, network issues, rate limits, and edge cases.Error response format
All errors follow a consistent structure:Retry strategy
Not all errors should be retried. Here is how to decide:| Status Code | Action | Retry? |
|---|---|---|
400 Bad Request | Fix the request payload | No |
401 Unauthorized | Check your API key | No |
403 Forbidden | Check permissions | No |
404 Not Found | Check the resource ID | No |
409 Conflict | Check resource state | No |
422 Validation | Fix the validation error | No |
429 Rate Limited | Wait and retry | Yes — respect Retry-After |
500 Server Error | Retry with backoff | Yes |
502 Bad Gateway | Retry with backoff | Yes |
503 Unavailable | Retry with backoff | Yes |
Rate limit handling
The API enforces per-merchant rate limits (1,000 requests/minute). When you exceed the limit, the API returns429 Too Many Requests with a Retry-After header indicating how many seconds to wait.
- Read the
Retry-Afterheader value (in seconds) - Wait for that duration before retrying
- If you are consistently hitting rate limits, reduce your request frequency or batch operations where possible
Exponential backoff
For retryable errors (5xx and network failures), use exponential backoff with jitter:Payout-specific error handling
Insufficient balance
- Check your current balance via the Balances API
- Wait for pending payouts to complete (releasing held funds)
- Fund your account if needed
- Then retry the payout
Duplicate idempotency key
Invalid payee
Invalid state transition
Circuit breaker pattern
If you are making many API calls, implement a circuit breaker to fail fast when the API is having issues:Testing error scenarios
In sandbox, you can trigger specific error conditions to test your error handling:| Scenario | How to trigger |
|---|---|
| Insufficient balance | Create a payout larger than your sandbox balance |
| Invalid payee | Use a non-existent payee ID (e.g., pye_invalid) |
| Invalid instrument | Use a non-existent instrument ID |
| Validation error | Omit required fields or use invalid values |
| Rate limiting | Send many requests rapidly from the same API key |
| Idempotency conflict | Reuse an idempotency key with a different payload |