Skip to main content
Every error has a code and a message. Use code to decide what to do next. Show message to your user: it’s written for them.

Error shape

Every response includes requestId, except a 401 for a missing or malformed API key and a 429 rate_limited. Those carry only success and error.

Codes you don’t recognize

New codes may be added. When you get a code you don’t handle yet:
  • On a 409, get a new quote.
  • On a 5xx from POST /v1/execute, send the same request again. Never sign a new quote: the order may already have been sent.

When a route gives no quote

A missing quote isn’t an error. POST /v1/quotes answers 200 with the quotes it found, and lists each route that gave none in unavailableRoutes, with why:
routeName is absent when no route was asked, for example for a token Sunrise doesn’t trade. The most common codes: A route can also report any other code from this page. Its message is always safe to show your user.

Request errors

Don’t retry a 4xx other than 429 unchanged: the same request gets the same answer.

Order errors

These come from POST /v1/execute. A 409 means the order was refused before it was sent. A 422 means the order can’t go through as signed.

Server errors

On any 5xx from POST /v1/execute, the order may already have been sent. Send the same request, with the same signed transaction, until data.done is true or it returns another error. Sending it again is safe: a signed transaction is executed at most once. Never sign a new quote: that can place the order twice.
See Swap with the API for an execute loop that follows these rules.