# Start a swap

> POST /v0/swap/orders. Create the order for a swap quote. Manual mode needs `recipient` and `refundTo` and returns the deposit address, exact amount and expiry. Wallet mode needs `sender` and returns the steps to sign.


`POST /v0/swap/orders`

Create the order for a swap quote. Manual mode needs `recipient` and `refundTo` and returns the deposit address, exact amount and expiry. Wallet mode needs `sender` and returns the steps to sign.

## Authentication

None. Intents Swap is public: it runs in the browser with no key, and is rate-limited per IP.

## Body parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `quoteId` | string | yes |  |
| `recipient` | string | no | Where the swapped funds go, on the destination network. Required in manual mode |
| `refundTo` | string | no | Where a refund goes, on the source network. Required in manual mode; defaults to `sender` in wallet mode |
| `sender` | string | no | Wallet mode: the connected wallet that signs. Required there |
| `context` | object | no | Where the swap started, for analytics (SPEC-swap §8). Never an address. |
| `context.landingUrl` | string | no |  |
| `context.ref` | string | no |  |
| `context.pageType` | string | no |  |

## Responses

| Status | Means |
|---|---|
| `200` | The existing order for this quote |
| `201` | Order created |
| `400` | Invalid request (`INVALID_REQUEST`, `UNSUPPORTED_ASSET`) |
| `403` | `SWAP_REFUSED`: we can't route this swap (no reason is given) |
| `404` | `NOT_FOUND`, `NO_ROUTE` |
| `409` | `QUOTE_DRIFT`: the price moved; `details.quote` is the new quote |
| `410` | `QUOTE_EXPIRED` |
| `422` | `TRANSFER_MODE_UNAVAILABLE`, `SWAP_PRICE_IMPACT_TOO_HIGH` |
| `429` | `RATE_LIMITED` |
| `503` | `SWAP_UNAVAILABLE`: swap is not configured on this deployment |


## Request



```bash title="curl"
curl https://api.intents.fi/v0/swap/orders \
  -X POST \
  -H 'content-type: application/json' \
  -d '{
       "quoteId": "q_Hn4tQ8vLmZ2kR7wXc9bJpD3s",
       "recipient": "bc1qszaek42mdc0056apvpa8xs69v8vwhp3hydnq8s",
       "refundTo": "0x15AAB9098125C5A728CA818B31620a902C25f764"
     }'
```

```ts title="TypeScript"
const response = await fetch("https://api.intents.fi/v0/swap/orders", {
  method: "POST",
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "quoteId": "q_Hn4tQ8vLmZ2kR7wXc9bJpD3s",
    "recipient": "bc1qszaek42mdc0056apvpa8xs69v8vwhp3hydnq8s",
    "refundTo": "0x15AAB9098125C5A728CA818B31620a902C25f764"
  }),
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.code}: ${error.message}`);
}
const data = await response.json();
```

```python title="Python"
import httpx

response = httpx.post(
    "https://api.intents.fi/v0/swap/orders",
    json={
        "quoteId": "q_Hn4tQ8vLmZ2kR7wXc9bJpD3s",
        "recipient": "bc1qszaek42mdc0056apvpa8xs69v8vwhp3hydnq8s",
        "refundTo": "0x15AAB9098125C5A728CA818B31620a902C25f764"
    },
)
response.raise_for_status()
data = response.json()
```



## Errors

```json
{ "error": { "code": "INVOICE_EXPIRED", "message": "This invoice has expired" } }
```

Switch on `code`, not on the message: every code has a page under [Error codes](/docs/errors/). Base URL `https://api.intents.fi`; the whole reference is on [one page](/docs/api).

---

Source: https://intents.fi/docs/api/post-swap-orders · The whole corpus: https://intents.fi/docs/llms-full.txt
