# Intents Route quickstart

> Quote a cross-chain swap across every protocol, have the user's wallet execute it, and track it to completion.

> Coding agent setting this up end to end? Follow https://intents.fi/docs/agent-setup/route.md instead: it is the same integration as one step-by-step prompt.

Four things: keep your key on the server behind a small proxy, quote, let the user's wallet run the
plan, and follow the order to the end. Route has no test mode — quotes are real — but nothing moves
until the user's wallet signs, so try it with a small amount.

No account yet? [Sign up](https://dashboard.intents.fi/signup?product=route) and make a secret key on the
[keys page](https://dashboard.intents.fi/keys). See [account and API keys](/docs/get-started).

## 1. Install the SDK

```bash
npm install @intents-fi/sdk viem            # viem for EVM wallets
npm install @solana/web3.js                 # only if you execute on Solana
```

## 2. Keep the key on the server

A browser app never holds the secret key. Proxy the five endpoints a swap needs through your own
backend and add the key there. In Next.js, `app/api/intents/[...path]/route.ts`:

```ts
const ALLOWED = [/^v0\/quotes$/, /^v0\/orders$/, /^v0\/orders\/[\w-]+(\/submit)?$/, /^v0\/chains$/, /^v0\/assets$/];

async function proxy(req: Request, ctx: { params: Promise<{ path: string[] }> }) {
  const path = (await ctx.params).path.join("/");
  if (!ALLOWED.some((re) => re.test(path))) {
    return Response.json({ error: { code: "NOT_FOUND", message: "Not proxied" } }, { status: 404 });
  }
  const url = new URL(`https://api.intents.fi/${path}`);
  url.search = new URL(req.url).search;
  const res = await fetch(url, {
    method: req.method,
    headers: { "content-type": "application/json", authorization: `Bearer ${process.env.INTENTS_API_KEY}` },
    ...(req.method !== "GET" && { body: await req.text() }),
  });
  return new Response(res.body, { status: res.status, headers: { "content-type": "application/json" } });
}

export const GET = proxy;
export const POST = proxy;
```

Then, in the browser:

```ts
import { createClient } from "@intents-fi/sdk";

export const client = createClient({ apiKey: "proxied", baseUrl: `${location.origin}/api/intents` });
```

## 3. Quote every protocol



```bash title="curl"
curl https://api.intents.fi/v0/quotes \
  -X POST \
  -H 'authorization: Bearer $INTENTS_SECRET_KEY' \
  -H 'content-type: application/json' \
  -d '{
       "from": {
         "asset": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
         "amount": "100000000"
       },
       "to": {
         "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
       },
       "sender": "0x15AAB9098125C5A728CA818B31620a902C25f764",
       "recipient": "0x9b3c1f4A6D2E5b70CA18F4D3e9B2A7C641FD8E05",
       "refundTo": "0x15AAB9098125C5A728CA818B31620a902C25f764"
     }'
```

```ts title="TypeScript"
const response = await fetch("https://api.intents.fi/v0/quotes", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "from": {
      "asset": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
      "amount": "100000000"
    },
    "to": {
      "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
    },
    "sender": "0x15AAB9098125C5A728CA818B31620a902C25f764",
    "recipient": "0x9b3c1f4A6D2E5b70CA18F4D3e9B2A7C641FD8E05",
    "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 os
import httpx

response = httpx.post(
    "https://api.intents.fi/v0/quotes",
    headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"},
    json={
        "from": {
            "asset": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
            "amount": "100000000"
        },
        "to": {
            "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        },
        "sender": "0x15AAB9098125C5A728CA818B31620a902C25f764",
        "recipient": "0x9b3c1f4A6D2E5b70CA18F4D3e9B2A7C641FD8E05",
        "refundTo": "0x15AAB9098125C5A728CA818B31620a902C25f764"
    },
)
response.raise_for_status()
data = response.json()
```



Every protocol that can do the swap answers, ranked; `best` is the ID of the top one, and `errors`
says why each of the others declined. Show the user `output.amountMin` — the least they will
receive — and not only `amountExpected`, and the `fees` and `etaSeconds` of the quote they pick.

A quote lasts until its `expiresAt`, often under a minute. Re-quote rather than hold one.

## 4. Execute in the user's wallet

`swap()` quotes, creates the order from the best quote (or the one `pick` returns), runs each step
in the user's wallet, reports every hash back, and waits for the end:

```ts
import { swap } from "@intents-fi/sdk";

const order = await swap(
  client,
  {
    from: { asset: "arbitrum:0xaf88d065e77c8cc2239327c5edb3a432268e5831", amount: "10000000" }, // 10 USDC
    to: { asset: "base:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" },
    sender: account,
    recipient: account,
  },
  { evm: { walletClient } },          // and/or { solana: { publicKey, signAndSendTransaction, connection } }
  {
    onQuote: (q) => console.log("route", q.provider),
    onStep: (e) => console.log(e.step.kind, e.status, e.txHash),
    onTransferRequired: (t) => showDepositAddress(t),   // for chains the wallet can't send on (BTC…)
    onUpdate: (o) => console.log(o.status),
  },
);
console.log(order.status); // completed, refunded, failed or expired
```

To show the quotes first and let the user choose, call `client.quotes.create()` yourself, then
`swap()` with `pick: (qs) => qs.find((q) => q.id === chosenId)`.

### The same thing without the SDK

`POST /v0/orders` with the `quoteId` returns `execution.steps`, run in order:

| `kind` | What the wallet does | Then |
|---|---|---|
| `evm_tx` | send `tx` on `chainId` (an `approve` comes first when needed) | `POST /v0/orders/{id}/submit` with `txHash` |
| `svm_tx` | sign and send the Solana transaction | submit the `txHash` |
| `eip712_sign` | sign `typedData` | submit the `signature` |
| `transfer` | send exactly `amount` of `asset` to `to`, with `memo` if set | submit the `txHash` |

If the price moved more than `driftToleranceBps` (default 15) since the quote, `POST /v0/orders`
answers `409 QUOTE_DRIFT` with the fresh quote; show it and create the order again if the user
accepts. Never sign or send a transaction for the user, and never ask for a private key.

## 5. Track it to the end



```bash title="curl"
curl https://api.intents.fi/v0/orders/inv_3QkR7mVt9zLpXdB2hJn6Yw \
  -H 'authorization: Bearer $INTENTS_SECRET_KEY'
```

```ts title="TypeScript"
const response = await fetch("https://api.intents.fi/v0/orders/inv_3QkR7mVt9zLpXdB2hJn6Yw", {
  method: "GET",
  headers: {
    authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`,
  },
});

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

```python title="Python"
import os
import httpx

response = httpx.get(
    "https://api.intents.fi/v0/orders/inv_3QkR7mVt9zLpXdB2hJn6Yw",
    headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"},
)
response.raise_for_status()
data = response.json()
```



The status is the same for every protocol:

| Status | Means |
|---|---|
| `awaiting_user` | the plan is out; the wallet hasn't acted yet |
| `submitted` | we have the hash or signature |
| `pending_deposit` | waiting for the deposit to land |
| `processing` | the protocol is filling it |
| `completed` | delivered to `recipient`; `output.amountActual` is what arrived |
| `refunded` | the protocol couldn't fill it and sent the input back |
| `failed` | it failed; `failReason` says why |
| `expired` | nobody acted before the plan expired |

Poll every few seconds, or register a webhook for `order.updated` on the
[webhooks page](/docs/platform/webhooks) and follow `data.status`.

## Next

- [Route overview](/docs/route) — what Route guarantees, and the errors you will meet
- [Route status](/docs/status) — live success rates per protocol
- [API reference](/docs/api) — every field of every endpoint

---

Source: https://intents.fi/docs/route/quickstart · The whole corpus: https://intents.fi/docs/llms-full.txt
