The API uses HTTP status codes plus a JSON body of the formDocumentation Index
Fetch the complete documentation index at: https://docs.o1.exchange/llms.txt
Use this file to discover all available pages before exploring further.
{ "error": "<message>" } for every error. This guide covers what each status code means and the right response.
Status code reference
| Status | Meaning | Retry? |
|---|---|---|
200 | Success | n/a |
400 | Validation error or no routes available | No (fix the request) |
401 | Missing or invalid x-api-key | No (fix the key) |
404 | Quote expired (only on /submit) | Yes (re-quote) |
429 | Rate limit exceeded | Yes (backoff) |
5xx | Internal error | Yes (backoff with jitter) |
Common error messages
- 400 examples
- 401 example
- 404 example (only on /submit)
- 429 example
- 5xx (internal)
no routes for pair happens often for a specific token, the token may not have routable on-chain liquidity on Base.On-chain transaction failures
Errors above are HTTP errors. Once you have asubmit response and broadcast the transaction, a separate class of failures can happen on-chain:
| Revert reason | Likely cause | Fix |
|---|---|---|
Slippage | Pool state moved between /quote and inclusion. | Increase slippageBps, or re-quote and resend. |
TRANSFER_FROM_FAILED / INSUFFICIENT_ALLOWANCE | Allowance for tokenIn is below amountIn. | Approve the router for amountIn, or use a permit payload. |
TRANSFER_FROM_FAILED (with sufficient allowance) | The user’s balance is below amountIn. | Validate balance before submitting. |
Permit failed | Permit signature invalid or already consumed. | Re-sign with a fresh nonce; verify the EIP-712 domain matches the token. |
Out of gas | Gas estimate was too low (rare; happens during chain congestion). | Re-broadcast with a higher gas limit, e.g. gasEstimate.gasUnits × 1.5. |
Recommended retry policy
What NOT to do
Don't retry 400 errors
400 means the request itself is malformed or unroutable. Retrying doesn’t help; fix the request.Don't hammer on 429
The rate limit window is per API key. Retrying immediately after a
429 makes the situation worse and burns the rest of your minute. Always back off.Don't surface raw errors to users
Translate
error strings into UI-friendly copy. “no routes for pair” → “Couldn’t find liquidity for this pair, try a different amount or token.”Don't ignore on-chain reverts
Always check
receipt.status === "success" after waitForTransactionReceipt. A 0x tx hash is not the same as a successful swap.