Error response format
All errors follow the same envelope:Common errors
| HTTP Status | Error | Cause | Fix |
|---|---|---|---|
400 | invalid inputMint | Mint address is not valid base58 | Check the token mint address |
400 | invalid amount | Amount is not a valid number or is zero | Use string representation of the amount in smallest units |
400 | invalid swapMode | Must be ExactIn or ExactOut | Check the swapMode parameter |
404 | no route found | No liquidity path exists for this pair/amount | Try a smaller amount, different slippage, or check if the token is supported |
404 | no pool found | No pool exists for one of the hops | The token may not have any listed pools |
400 | insufficient liquidity | Pools exist but don’t have enough liquidity for this amount | Reduce the swap amount |
500 | simulation failed | Transaction simulation failed on-chain | Check simulation logs, ensure wallet has sufficient balance |
429 | (rate limit) | Too many requests | Back off and retry with exponential delay |
Handling errors in code
Simulation errors
WhenskipSimulation is false (default), the swap endpoint simulates the transaction before returning it. Check the simulation field in the response:
| Field | Meaning |
|---|---|
insufficientFunds | Wallet doesn’t have enough tokens for the swap + transaction fees |
slippageExceeded | Price moved beyond the slippage tolerance between quote and transaction build |
On-chain transaction errors
Even after a successful simulation, the transaction can fail on-chain if conditions change between simulation and confirmation.| Error | Cause | Fix |
|---|---|---|
SlippageExceeded | Price moved after submission | Increase slippageBps or retry quickly |
InsufficientFunds | Balance changed between simulation and execution | Re-check balance before submitting |
BlockhashExpired | Transaction took too long to confirm | Rebuild the transaction and resubmit |
Retry strategy
| Error category | Action |
|---|---|
| Quote failures (404) | Retry after 1-2 seconds. Liquidity can appear as pools rebalance. |
| Rate limits (429) | Exponential backoff: 1s, 2s, 4s, 8s. Max 3 retries. |
| Simulation failures (500) | Re-fetch a fresh quote and rebuild. Don’t retry the same transaction. |
| On-chain failures | Get a new quote (prices have likely changed) and rebuild from scratch. |