Skip to content
Intents Route

Intents Route quickstart

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

Fastest way in

Set up Route with your AI agent

Paste this into Claude Code, Cursor, Codex or any coding agent, at your app's root:

Read https://intents.fi/docs/agent-setup/route.md and follow it.

Adds a key-safe API proxy, a quote list and wallet execution with live status, then checks it with real quotes. Nothing moves until your wallet signs.

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 and make a secret key on the keys page. See account and API keys.

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

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:

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:

import { createClient } from "@intents-fi/sdk";
export const client = createClient({ apiKey: "proxied", baseUrl: `${location.origin}/api/intents` });
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"
}'
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
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.

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:

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).

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.

curl
curl https://api.intents.fi/v0/orders/inv_3QkR7mVt9zLpXdB2hJn6Yw \
-H 'authorization: Bearer $INTENTS_SECRET_KEY'
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
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 and follow data.status.