# Errors, limits and retries

> The Wagyu API error envelope, every error code and what to do about it, rate limits and Retry-After, and a safe retry policy for reads, quotes and order creation.

## The error envelope

Every error has the same shape. Branch on `code`; the `error` text is for humans and can change.

```json
{ "code": "no_route", "error": "No route is currently available." }
```

| Field | When present |
| --- | --- |
| `code` | Always. One of the values below. |
| `error` | Always. A human-readable message. |
| `minAmountUsd` | With `amount_below_minimum`: the minimum, in USD. |
| `retryAfter` | With `rate_limited`: seconds to wait (also in the `Retry-After` header). |
| `reason` | On some refusals: a finer reason within `code`, such as `session_retired` or `stale_round`. The list is open: treat a reason you do not know as its `code` alone. |

## Error codes

| code | HTTP status | Meaning | What to do |
| --- | --- | --- | --- |
| `invalid_request` | 400 | The request is malformed, names an unknown field or query parameter, or was refused by policy. The response does not say which. | Fix the named field if there is one. Do not retry unchanged. |
| `unauthorized` | 401 | An integrator key is missing where one is required, invalid, revoked or suspended. | Check the key and that it is sent as a header. |
| `forbidden` | 403 | The credential is valid but not allowed to do this (for example, a public-client key reading reports, or unapproved IP forwarding). | Check the key type and permissions. |
| `not_found` | 404 | The order does not exist, or the session or destination proof is wrong. Both answer the same way on purpose. | Check the order ID and the proof you send. |
| `conflict` | 409 | The action does not fit the order’s current state, or the order is locked and only support can view or change it. | Re-read the order. If the message mentions support, send the order ID to support. |
| `amount_below_minimum` | 400 | The amount is under the minimum; `minAmountUsd` is the minimum, in USD. | Increase the amount and quote again. |
| `no_route` | 400 | No route can fill this pair and amount right now. | Try another amount or token, or quote again later. |
| `paused` | 409 | Wagyu switched this pair, asset, bridge direction or product off. The message names what is paused. It is not a problem with the request. | Show the message and offer another pair, or try again later. Do not retry in a loop. |
| `rate_limited` | 429 | A rate limit was hit. | Wait `Retry-After` seconds (also in `retryAfter`). |
| `unavailable` | 503 · 500 · 504 | A temporary failure on Wagyu’s side: something the request needs did not answer or cannot run right now. | Retry reads and quotes with backoff. Re-read the order before repeating a write. |
| `request_failed` | 400 | An upstream step failed. | Re-read the order before any other action. |
| `integration_not_approved` | 403 | No longer sent. An integration Wagyu has not approved creates orders on its starter limits; going over one is `rate_limited`. | Nothing to do. Keep handling it like `forbidden` if your client already does. |
| `human_check_failed` | 403 | The key is one shipped in a web page, so creating an order needs a solved human check, and the check token was missing, expired or did not verify. | Have the person solve the check again and send the create with the new token. |

### Real error responses

Each of these was produced by the live API when the site was built:

<!-- POST /v2/swaps/quote · 400 -->
```json
{
  "code": "no_route",
  "error": "No route is currently available."
}
```

<!-- POST /v2/swaps/quote · 400 -->
```json
{
  "code": "invalid_request",
  "error": "invalid body/fromAmount: Expected a positive atomic integer amount."
}
```

<!-- POST /v2/swaps/quote · 401 -->
```json
{
  "code": "unauthorized",
  "error": "Authentication required."
}
```

<!-- GET /v2/swaps/terms · 400 -->
```json
{
  "code": "invalid_request",
  "error": "invalid querystring: Unrecognized key: \"apiKey\""
}
```

<!-- GET /v2/swaps/docs-example-0000 · 404 -->
```json
{
  "code": "not_found",
  "error": "Not found."
}
```

### Deliberately vague refusals

A plain `400` `invalid_request` with the message "Invalid request." can mean bad input or a policy refusal, and the response does not say which. Show a neutral message and do not retry the same request. When the message names a field (as in `invalid body/fromAmount: …`), fix that field.

### Refusals before the API

Some requests never reach the API. Requests with Python's default `Python-urllib/3.x` user agent get a `403` page from the network edge, not a JSON error. Set your own `User-Agent` header; curl, `fetch` and Python `requests` are not affected.

## Rate limits

On `429`, wait the number of seconds in `Retry-After` before trying again. It tells you when to check, it does not reserve capacity. `X-RateLimit-Resource` names the limit you hit:

| `X-RateLimit-Resource` | Limit |
| --- | --- |
| `requests` | Requests, for your integration's server keys or the IP |
| `key_requests` | An extra request cap on one key |
| `creation` | Swap and bridge creation attempts |
| `quotes` | Quotes |
| `open_orders` | Unfinished orders |
| `client_requests` | Requests of one forwarded end user |
| `client_creation` | Creation attempts of one forwarded end user |
| `client_open_orders` | Unfinished orders of one forwarded end user |

Upstream refusals may omit the header. With a server key, the `error` also says whose limit it was: the integration's, the key's or one end user's. Every applicable limit must allow a request, and creation attempts count even when they are refused. The default limits are:

| Default limit (anonymous or per IP) | Value | Field in defaultLimits |
| --- | --- | --- |
| Requests per minute | 600 | `requestLimitPerMin` |
| Quotes per minute | 60 | `quoteLimitPerMin` |
| Order creations per minute | 6 | `createLimitPerMin` |
| Unfinished orders at once | 5 | `maxOpenOrders` |
| Window in which an unfinished order counts | 30 minutes | `openOrderWindowMinutes` |

_Live from `GET /v2/swaps/terms`, read when this page was built (4 Dec 2026, 19:24 UTC)._

An approved integration has limits of its own: see [API keys and fees](https://docs.wagyu.xyz/authentication.md#limits).

## Retry policy

| Call | On timeout or 5xx |
| --- | --- |
| Reads (`GET`) and quotes | Retry with exponential backoff and a cap. |
| `POST /v2/swaps`, `POST /v2/bridges` | **Never retry automatically.** There is no idempotency key: the first request may have created an order. |
| Owner actions (refund address, payout address, review, coinflip) | Re-read the order first. Repeat only if the order still asks for it. |
| A WebSocket reconnect | Re-read the order over REST before trusting the screen. |

A `sessionId` you supply at creation groups orders, but it does not deduplicate them.

When retries keep failing, check [status.wagyu.xyz](https://status.wagyu.xyz) or its [JSON](https://docs.wagyu.xyz/public-data.md#service-status) before you alert your users or your own on-call.

## Owner actions

Owner actions need the `X-Session-ID` of the order. The read-only `?verify=` proof and integrator keys cannot perform them. Offer an action only while `customerState.kind` is `action_required` with that `action`: the presence of a field, the status or elapsed time never authorises an action on its own.

| Action | Rules |
| --- | --- |
| Refund address | Only with action `refund_address`. Saves one immutable destination; it does not send the refund by itself. See [Deposits and refunds](https://docs.wagyu.xyz/deposits.md#refund-addresses). |
| Payout address | Only with action `payout_address`. Write-once. |
| Coinflip | Only with action `coinflip`. Send an explicit `accept: true` or `false`. On `409` or `504`, re-read before trying again. |
| Review | Once, after completion: three ratings from 1 to 5 (`ratingSpeed`, `ratingRate`, `ratingExperience`) and an optional comment up to 500 characters. |
| Delete | Permanently removes a completed or refunded order. It cancels nothing and moves no funds. |

---
Source: https://docs.wagyu.xyz/actions-and-retries · Built from the live Wagyu API on 2026-12-04.
