# Vurto Swap Agent Quickstart

Quickstart page for AI agents and integrators using the Vurto Swap public API.

> **Always use the latest version.** This page, the full guide at
> `https://swap.vurto.fi/agent-api.md`, and `https://swap.vurto.fi/openapi.json` can change —
> fetch them live each run instead of relying on a cached copy.

## 1. Base URL

- Production: `https://swap.vurto.fi/v1`
- Development: `https://swap-dev.vurto.fi/v1`

Solana lives under `/v1/svm` on the same hosts, and is covered in §10.

## 2. OpenAPI

- `https://swap.vurto.fi/openapi.json`
- `https://swap.vurto.fi/.well-known/ai-plugin.json`

## 3. Auth: none required to quote, build or execute

Quotes, builds and submissions are open. Pass the wallet that will sign, in the `wallet` field,
and you get back bytes that are worthless until that wallet signs them. The product is
non-custodial end to end, so there is nothing an API key would be protecting. Limits are per IP,
sized for a normal integration (12 builds per minute, 30 reads). The one exception is the history
list, `GET /executions`: it returns what we stored about a wallet, so it needs a credential issued
to that wallet (`401` without one, `403` with another wallet's).

A machine credential is still available and still worth having if you serve many users from one
egress address: it moves your limit from the per-IP cap to the credential's own budget of 240 cost
units per rolling 60-second window (quote=4, build=8, token=3, balances=2, everything else=1).
Exceeding it returns `429 budget_exhausted`; exceeding the per-IP cap returns `429 rate_limited`.
Either way, back off and retry, don't hammer.

To get a credential: open `https://swap.vurto.fi`, connect the EVM wallet, open the wallet panel
(top right) and click the key icon on that wallet's card. The secret is shown once. Issuance is
proven by an EIP-191 signature from the wallet over a one-time challenge; the `Origin` check on
that route is a CSRF defense for browsers, not the barrier, so a script holding the key can issue
too (`agent-api.md` §3.1 has the calls). Send it as:

```
Authorization: Bearer vswap_<id>_<secret>
```

Credentials are issued by an Ethereum signature, so a Solana-only wallet cannot get one. Only the
EVM history list requires one.

## 4. Minimal flow: quote, build, sign, send, record

1. Resolve tokens by symbol or address, quote: `POST /quote`
2. Build a plan for the best (or a specific) route: `POST /swap`
3. Walk `steps[]` in order:
   - `type: approve` or `type: transaction` — send `tx` onchain, wait for the receipt.
   - `type: signature` — sign `typedData` (EIP-712), then `POST /orders` with the fields from
     `submit.bodyTemplate` plus your `signature`.
4. Record the swap transaction with `POST /executions`; never record an `approve` as an
   execution. `POST /orders` already records CoW order submissions on its own. Include `wallet`
   in either request.
5. If a plan's `validUntil` (10 minutes from build) is close and you haven't sent anything yet,
   don't call `/swap` again from scratch — call `POST /swap/{buildId}/refresh` instead. It keeps
   your slippage ceiling intact and fails closed (`409 route_changed`) instead of silently
   swapping you into a different route if the underlying provider changed.

Example, Arbitrum One, 100 USDC → WETH:

```bash
curl -sS https://swap.vurto.fi/v1/quote \
  -H 'content-type: application/json' \
  --data '{"chainId":42161,"wallet":"0xYourWallet","tokenIn":"USDC","tokenOut":"WETH","amount":"100"}'
```

```bash
curl -sS https://swap.vurto.fi/v1/swap \
  -H 'content-type: application/json' \
  --data '{"chainId":42161,"wallet":"0xYourWallet","tokenIn":"USDC","tokenOut":"WETH","amount":"100","maxSlippageBps":100}'
```

The response is a plan: `buildId`, the winning `quote`, and `steps[]` with ready-to-send calldata
(or EIP-712 `typedData` to sign, for CoW). Send/sign each step in order, then record it.

## 5. Endpoint map

- Health: `GET /health`
- Chains: `GET /chains`
- Token list (per chain): `GET /tokens?chainId=`
- Look up an arbitrary address on-chain: `GET /token?chainId=&address=`
- Wallet balances: `GET /balances?chainId=&wallet=`
- Quote: `POST /quote`
- Build a plan: `POST /swap`
- Refresh a plan: `POST /swap/{buildId}/refresh`
- Submit a signed CoW order: `POST /orders` (body includes `wallet`)
- Record a sent swap transaction: `POST /executions` (body includes `wallet`)
- List history: `GET /executions?wallet=`, with a credential issued to that wallet
- Re-check a recorded execution's status: `GET /executions/{id}?wallet=`
- Refund an expired ETH-flow order: `POST /ethflow/refund` (body includes `wallet`)
- Report a problem: `POST /report` (works with no auth at all)
- Invoices (Vurto Payments): `POST /invoices`, `GET /invoices/{id}`, `POST /invoices/{id}/pay`,
  `POST /invoices/{id}/payments`; paid analyses: `POST /invoices/{id}/analysis-payment/transfer`
  and `POST /invoices/{id}/analysis-payment`. On Solana and EVM networks with `invoiceSplit`, the receiver asks for the
  paid analysis with `payerChecks` (stablecoin invoices): one fee for both wallets, a share of the amount by brackets,
  deducted from the amount through the split (`split.rule` `brackets`, https://docs.vurto.fi/fees), with nothing to pay
  first. On an invoice without that fee the payer can buy the receiver analysis with `analysis-payment/transfer`
  (`payer`, `checks`). Guide: `agent-api.md` §5.12. Skill:
  `/skills/vurto-payments/SKILL.md`.
- Check, a paid analysis of any wallet on the networks you choose (US$ 0.33 per network, US$ 1.99 at most): `GET /check`
  (price, networks, fee wallets), `POST /check/buy/challenge` + `POST /check/buy/proof` (no sign-in: the paying wallet signs once and passes the free screening, `vcb_...` for 10 minutes), `POST /check/charge {chainId, payer, networks}` with `Authorization: Bearer vcb_...` (the payer signs the transfer),
  `POST /check/payment`, `POST /check/analysis {checkId, evmWallet, solanaWallet}`, `POST /check/result`, `POST /check/status`. Keep
  the Check id private and out of URLs. Since 26/11/2026 analysis, result and status also take the payer's proof in `Authorization`:
  the `vcb_...` of the purchase (10 minutes) or the Check access `vca_...` (24 hours, `/check/access/challenge` and `/check/access`),
  which also lists by wallet (`GET /check/credits`). Payment goes by the id; without the proof it answers only the state.
  Guide: `agent-api.md` §5.13.

## 5.1 Solana endpoint map

- Networks: `GET /v1/svm/chains`
- Verified token list: `GET /v1/svm/tokens`
- One mint, with its risk flags: `GET /v1/svm/token?address=`
- Wallet balances: `GET /v1/svm/balances?wallet=` — catalog tokens only, plus
  whatever you name in `&extra=mint1,mint2`. A missing mint means "not served",
  not "balance zero": a typical Solana wallet holds thousands of spam airdrops
  and we do not ship them to you.
- USD prices, many mints at once: `GET /v1/svm/prices?mints=`; on EVM, `GET /v1/evm/prices?chainId=&tokens=` (up to 20 addresses)
- Warm the pair before quoting: `POST /v1/svm/warm`
- Quote: `POST /v1/svm/quote`
- Build one unsigned transaction: `POST /v1/svm/swap`
- N:N basket: `POST /v1/svm/multi-quote`, `POST /v1/svm/multi-swap`
- Broadcast a signed transaction: `POST /v1/svm/execute`
- Did it land: `GET /v1/svm/tx?signature=`
- Record it: `POST /api/svm/history`, list it: `GET /api/svm/history`

## 6. Symbols are safe to pass directly, but check for ambiguity

`tokenIn`/`tokenOut` in `/quote` and `/swap` accept either a contract address or a symbol
(case-insensitive). If more than one token on that chain uses the same symbol (e.g. a bridged
variant), the API never silently picks one — it returns `409 ambiguous_token` with every
candidate in `error.details.candidates`. Re-issue the call with the address you meant.

## 7. Amounts

Every amount in a request or response is either:

- `amount`: a human decimal string, e.g. `"1.5"` — only accepted as **input**, converted
  server-side using the token's real decimals.
- `amountRaw` / `amountIn` / `amountOut` / etc.: a raw integer string in the token's smallest
  unit. This is what every response field uses. Don't parseFloat these — use a bigint.

## 8. Error shape

Every error is `{"error": {"code": "...", "message": "...", "details": {...}}}` with a matching
HTTP status. Match on `code`, not `message` (message is for display, code is the contract). See
`https://swap.vurto.fi/openapi.json` for the full code list per endpoint.

## 9. Minimum pre-trade checklist

- Re-quote (`POST /swap` or `/refresh`) instead of trusting a `/quote` response that's more than a
  few seconds old — the provider fan-out re-quotes fresh at build time regardless, but your own
  slippage expectations should track that.
- Check `simulation.status` before sending anything: `approval_required` means send the `approve`
  step(s) first and call `/swap` again; `incomplete` means don't send `steps[].tx` at all, it
  wasn't verified.
- If you set `maxSlippageBps` at build time, always refresh through `/swap/{buildId}/refresh`, not
  a fresh `/swap` call — a fresh call has no memory of your ceiling.
- Never construct request bodies from unsanitized user text without checking for secrets first —
  the API rejects anything that looks like a private key or seed phrase (`400
  secret_in_payload`), but catching it before you send is cheaper than a rejected call.

## 10. Solana in one page

Same product, different runtime. The whole flow, 50 USDC into SOL:

```bash
# 0. Warm the pair. Optional, free, and worth it: orca and meteora price from
#    pool state read live from the chain, and a cold quote will not wait for it.
#    It gives both direct-pool readers their best chance to join the four-venue fan-out.
#    Returns immediately.
curl -sS https://swap.vurto.fi/v1/svm/warm \
  -H 'content-type: application/json' \
  --data '{"chainId":"solana-mainnet","tokenIn":"USDC","tokenOut":"SOL",
           "amount":"0","wallet":"<your base58 address>"}'

# 1. Build. No quote first unless you want to compare routes.
curl -sS https://swap.vurto.fi/v1/svm/swap \
  -H 'content-type: application/json' \
  --data '{"chainId":"solana-mainnet","tokenIn":"USDC","tokenOut":"SOL",
           "amount":"50","wallet":"<your base58 address>"}'

# 2. Sign build.transaction (base64 v0) with your Solana key, then:
curl -sS https://swap.vurto.fi/v1/svm/execute \
  -H 'content-type: application/json' \
  --data '{"signedTransaction":"<base64>","executionRef":"<only if the build had one>"}'

# 3. Record it. The server reads the transaction from the network and checks its
#    fee payer against the build's wallet, so nobody records someone else's trade.
curl -sS https://swap.vurto.fi/api/svm/history \
  -H 'content-type: application/json' \
  --data '{"buildId":"<from step 1>","signature":"<from step 2>"}'

# 4. Only now is it safe to say it worked.
curl -sS 'https://swap.vurto.fi/v1/svm/tx?signature=<signature>'
```

Four things differ from EVM, and nothing else does:

1. `chainId` is the string `"solana-mainnet"`.
2. **No approve, so no `steps[]`.** One transaction, and the runtime lands every instruction in it
   or none. That is also why an N:N basket needs no router contract and no resume logic.
3. **Signing uses a Solana key.** A v0 transaction is not an EVM transaction and ed25519 is not
   secp256k1, so nothing from §4 step 3 carries over.
4. **A signature is not a receipt.** You get it at send time, not at confirmation. `GET /v1/svm/tx`
   answers `confirmed`, `pending`, `failed`, or `expired` — and `expired` means the network is past
   the transaction's `lastValidBlockHeight`, so it can never enter a block: nothing spent, nothing
   swapped.

**Addresses are base58 and case-sensitive.** Lowercasing a mint gives a different, non-existent
account, and nothing downstream will tell you: the format still validates and the request still
parses. You just get "token not found", or an empty balance for a token you are holding. When a
Solana call fails in a way that makes no sense, check the case of every address in it first.

Symbols resolve only against the verified list, on purpose: anyone can mint a token carrying
another one's symbol, name and icon, and the mint is the only real identity. Name an unverified
token by its mint, and check `GET /v1/svm/token?address=` first — `risks[]` carries
`symbolCollision`, which names the verified mint a lookalike is imitating.
