Swap API for AI agents
Speaks MCP? Connect in one line at /mcp. Otherwise call the key-less HTTPS API below: quote, create and track an XMR/USDC swap end to end.
https://xmrtousdc.xyz/mcp
Setup for Claude, ChatGPT, Cursor, VS Code, Codex, Gemini CLI and more, plus tools, prompts and a full transcript: MCP server guide.
Discovery
/mcp- MCP setup for every client, tools, prompts, safety model./llms-full.txt- everything an LLM needs to run a swap, in one file./openapi.json- OpenAPI 3.1 spec (basehttps://xmrtousdc.xyz/api/v1)./api/v1/agent/quickstart- signed quickstart JSON./.well-known/api-catalog(RFC 9727),/.well-known/ai-catalog.json,/.well-known/agent.json,/.well-known/mcp/server-card.json,/.well-known/ai-plugin.json,/.well-known/jwks.json
MCP in one line
Public endpoint https://xmrtousdc.xyz/mcp (Streamable HTTP, stateless, no auth, no API key). In Claude Code:
claude mcp add --transport http swapper https://xmrtousdc.xyz/mcp
Tools: get_quote, create_swap, get_swap_status, get_funding_options, list_swaps, plan_swap, get_capabilities, create_support_ticket, get_support_ticket, request_agent_key, submit_feedback. Prompts: swap_usdc_to_xmr, swap_xmr_to_usdc, get_xmr_for_goal. Every other client: MCP setup.
REST endpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /api/v1/agent/quickstart | Discovery, trust metadata, example calls (always reachable). |
| GET | /api/v1/agent/capabilities | Directions, live chains, defaults, validation rules, limits, funding pointer. |
| GET | /api/v1/agent/funding | Funding guide: ?direction=u2x (default) or x2u. What the sender needs before quoting. |
| POST | /api/v1/agent/swap/plan | Validate partial intent; returns state + guidance.questionsToAsk. |
| POST | /api/v1/agent/swap/quote | Estimate a swap: {direction, amount | receiveAmount, to?, chain?}, or {requoteOf} to re-quote; returns quoteId + terms (an estimate, not guaranteed; no published minimum), valid 300 s. |
| POST | /api/v1/agent/swap/create | {quoteId} (+ to if the quote had none) and a required idempotency-key. Returns payable, deposit (payment only while payable), destination, origin, trackUrl; 202 state queued while the provider's order limits are reached (send the same create again). |
| POST | /api/v1/agent/swap/execute | Deprecated alias of create (same body and key rules); use create. |
| POST | /api/v1/agent/swap/payment-check | {orderId, payment}: checks an UNSIGNED payment (tx JSON, URI, calldata or unsigned raw tx) against the order's deposit; send only if data.paymentCheck.safeToSend is true. |
| GET | /api/v1/agent/swap/status/{orderId} | Live order state, payable, evidence, attention and next; ?waitSec=0..25&sinceState= long-polls for the next change. |
| GET | /api/v1/agent/swap/orders | Find my swaps: ?idempotencyKey= (the create key) or ?sessionId= (addresses redacted). |
| GET | /api/v1/agent/swap/queue | The order line: the provider's room now and, with ?idempotencyKey=, a queued create's place. |
| POST | /api/v1/agent/support/tickets | Open a support ticket: {message, orderId?, category?, sessionId?, walletAddress?}; returns ticketId and replyToken. |
| GET | /api/v1/agent/support/tickets/{ticketId} | Read Support's replies (x-reply-token header). |
| POST | /api/v1/agent/feedback | Optional, after a swap: {rating 1-5, comment?, orderId?, publishable?}. |
| GET | /api/v1/agent/feedback-summary | Average rating of completed Swapper orders (one rating per order) and approved comments, marked untrusted. |
| GET | /api/v1/agent/key | Agent key terms: whether keys are offered and the fee a keyed quote carries. |
| GET | /api/v1/chains | Chain list incl. minSwapUsd per chain (the provider minimum recent quotes reported; null when none is known). |
| GET | /api/v1/health | Service health (status ok | degraded). |
Inputs: direction is x2u (XMR→USDC) or u2x (USDC→XMR); amount is a decimal string in send-asset units (digits and one dot); on quote you may pass receiveAmount (receive-asset units) instead; to is an EVM address on Arbitrum One for x2u or a Monero mainnet address for u2x (both checked, including checksums); chain is optional (auto-filled to Arbitrum One while it is the only live chain).
0. Funding (USDC senders)
curl -sS "https://xmrtousdc.xyz/api/v1/agent/funding?direction=u2x"
Returns the shared funding guide: native USDC contract, ETH for gas on Arbitrum One, pitfalls and routes. Human version: Get USDC on Arbitrum One.
1. Plan
curl -sS https://xmrtousdc.xyz/api/v1/agent/swap/plan \
-H "content-type: application/json" \
-d '{"direction":"x2u","amount":"0.8"}'
Returns state (needs_input, needs_destination, invalid_input, ready_to_execute) and data.guidance.questionsToAsk.
2. Quote
curl -sS https://xmrtousdc.xyz/api/v1/agent/swap/quote \
-H "content-type: application/json" \
-d '{"direction":"x2u","amount":"0.8","to":"0xYOUR_ARBITRUM_ADDRESS"}'
Returns data.quoteId, data.expiresAt and data.expiresInSec (the 300-second acceptance window, not a price lock) and data.terms with the estimated receive amount. It is an estimate, not a guarantee: the provider publishes no minimum receive amount (terms.receive.minimum is null), so the final amount is set when the swap runs. Fees are included in the rate and itemized only when the provider reports them (terms.fees). Create the order while the quote is valid; whether to show the terms to the user first follows the user's and the client's policy.
Know what the user wants to receive? Pass receiveAmount instead of amount (with direction; the estimate is the target: basis: "minimum" is refused while the provider publishes no minimum); Swapper finds the send amount and adds data.target (see reverse quotes):
curl -sS https://xmrtousdc.xyz/api/v1/agent/swap/quote \
-H "content-type: application/json" \
-d '{"direction":"u2x","receiveAmount":"1","to":"YOUR_MONERO_ADDRESS"}'
To re-quote the same inputs later (expired quote, price check, the user just funded), send {"requoteOf":"QUOTE_ID"} alone; the new quote adds data.delta.
3. Create
KEY=$(uuidgen) # a new random key per order; reuse it only to retry this create
curl -sS https://xmrtousdc.xyz/api/v1/agent/swap/create \
-H "content-type: application/json" \
-H "idempotency-key: $KEY" \
-d '{"quoteId":"QUOTE_ID"}'
The body is the quoteId (plus to if the quote had none); the idempotency-key header is required, a new random value per order. Each quote opens at most one order (409 quote_already_used under another key). Returns state: "waiting_for_funding", data.order.orderId, data.origin (agent_quote), data.destination (the payout address recorded with the order: show it), data.payable and data.payableReason, data.deposit (address, exact amount, tokenSymbol, expiresAt, payment, attestation), data.trackUrl and data.next.statusUrl. Creating an order moves no funds; a deposit is sent by a wallet (the user's own, or an agent's acting for the user), only while payable is true and only if data.destination is the user's own address (an order created any other way is never payable: unverified_origin). deposit.payment is a wallet-ready transfer (Monero URI, or EIP-681 link plus an unsigned ERC-20 transaction {to, value, data, chainId}): see agent wallets.
Retries: the same key and body replay the same order with its live state (top-level replayed: true; payment only if it is still payable); a different body with the same key returns 409 idempotency_conflict with the existing order in details. Retry network errors, timeouts and 503 order_outcome_unknown with the same key until it resolves (details.resolvesAt). An expired quote returns 410 quote_expired: re-quote (requoteOf) and create from the new quote.
4. Long-poll status
curl -sS "https://xmrtousdc.xyz/api/v1/agent/swap/status/ORDER_ID?waitSec=25&sinceState=waiting_for_funding"
With waitSec (0-25) the call returns as soon as the state differs from sinceState, or when the wait ends; data.waited reports it. Without it, poll every data.next.pollIntervalSec. Read data.payable here before showing a deposit again. data.next.action says what to do: contact_support (the provider needs an action Swapper cannot take, see data.attention) or requote_and_create_new_order (reconfirm_required: this order can never be funded). data.evidence holds the deposit and payout transactions the provider reports: its statements, not chain checks.
| state | Meaning |
|---|---|
waiting_for_funding | Order open, waiting for the exact deposit before expiresAt. Pay only while payable is true; never send a second deposit. |
deposit_detected | Deposit seen on-chain, waiting for confirmations. |
swap_processing | Deposit confirmed; swap executing. |
refunding | The provider is refunding the deposit. |
completed | Terminal: the provider reports the payout sent to the destination. evidence.payout is the payout transaction it reports; when that is null, check the wallet before treating the funds as received. |
terminal_failure | Terminal: outcome failed, expired or refunded. failed/expired can still change (mayChange) if funds arrived late. Open a support ticket if funds were sent. |
unknown | Unrecognized provider status, or the provider needs an action on the order (data.attention action_required, next.action contact_support). Keep polling; contact support if it persists. |
5. Find my swaps
curl -sS "https://xmrtousdc.xyz/api/v1/agent/swap/orders?idempotencyKey=$KEY"
Finds the order created under that idempotency key, over REST or MCP (or, with ?sessionId=, a session's orders): orderId, state, send amount, createdAt and trackUrl; addresses redacted to the destination's last 6 characters. Use it to recover a lost orderId, then read the order's status: a list never offers a payment (data.payable is false).
Full loop (JavaScript)
const API = "https://xmrtousdc.xyz/api/v1/agent";
const sleep = (s) => new Promise((ok) => setTimeout(ok, s * 1000));
async function call(method, path, body, headers = {}) {
const r = await fetch(API + path, {
method,
headers: { "content-type": "application/json", ...headers },
body: body ? JSON.stringify(body) : undefined,
signal: AbortSignal.timeout(45_000)
});
const json = await r.json().catch(() => ({}));
if (!r.ok) throw Object.assign(new Error(json.error?.code || String(r.status)), { status: r.status, error: json.error || {} });
return json;
}
// 1) quote by what the user wants to receive (or {direction, amount} = what they send)
const q = await call("POST", "/swap/quote", { direction: "u2x", receiveAmount: "1", to: "YOUR_MONERO_ADDRESS" });
// 2) check q.data.terms (estimates, not guaranteed) and q.data.prerequisites against
// the request and your limits (and confirm with the user if your policy says so).
// Create before q.data.expiresAt.
// 3) create from the quote alone with a new random key. Retry network errors,
// timeouts and retryable errors with the SAME key, never a new one.
const key = crypto.randomUUID();
let ex;
for (let i = 1; ; i++) {
try {
ex = await call("POST", "/swap/create", { quoteId: q.data.quoteId }, { "idempotency-key": key });
if (ex.state !== "queued") break;
// 202 queued: the provider's order limits are reached; send the same create again.
await sleep(ex.data.next.retryAfterSec);
i = 0;
} catch (e) {
if ((e.status && e.error.retryable !== true) || i === 5) throw e;
await sleep(e.error?.retryAfterSec ?? 2 ** i);
}
}
// 4) fund only while payable, once: your wallet signs ex.data.deposit.payment.tx
// {to, value, data, chainId} after the checks in /guides/agent-wallets
// (data.destination must be the user's own address)
if (!ex.data.payable) throw new Error("do not send a deposit: " + ex.data.payableReason);
const { orderId } = ex.data.order;
const pc = await call("POST", "/swap/payment-check", { orderId, payment: ex.data.deposit.payment.tx }); // unsigned
if (pc.data.paymentCheck.safeToSend !== true) throw new Error("payment check failed: do not send");
// 5) long-poll: each call returns on the next state change or after 25 s
let state = ex.state, st = null;
do {
try {
st = await call("GET", `/swap/status/${orderId}?waitSec=25&sinceState=${state}`);
state = st.state;
} catch (e) {
if (e.status && e.error.retryable !== true) throw e;
await sleep(e.error?.retryAfterSec ?? 30);
}
} while (!st?.terminal);
System prompt for your agent
You execute XMR<->USDC swaps via the Swapper Agent API (https://xmrtousdc.xyz/api/v1/agent).
1) Sending USDC (u2x)? GET /funding?direction=u2x: the user needs native USDC plus a little ETH for gas on Arbitrum One. If they must fund first, quote first to learn how much.
2) POST /swap/quote with {direction, amount} (what the user sends) or {direction, receiveAmount} (what they want; buying XMR is u2x). Show data.terms: the receive amount is an estimate, not guaranteed (the provider publishes no minimum), valid for data.expiresInSec seconds.
3) POST /swap/create with {quoteId} and an idempotency-key header (a new random UUID per order) while the quote is valid. Creating an order moves no funds; whether to confirm with the user first follows the user's and the client's policy. Funds move only when the user's wallet signs. Retry failures with the SAME key. HTTP 202 state queued: send the same create again after Retry-After. Each quote opens at most one order.
4) Fund only if data.payable is true, exactly once: data.destination must be the user's own payout address, POST /swap/payment-check {orderId, payment: the unsigned data.deposit.payment.tx or URI} must return data.paymentCheck.safeToSend true, and your wallet signs data.deposit.payment unchanged. Without a wallet, show data.deposit exactly as returned.
5) Before showing a deposit again (retry, replay, new conversation), GET /swap/status/{orderId}: if payable is false, never ask for another deposit.
6) GET /swap/status/{orderId}?waitSec=25&sinceState=<last state> until terminal (completed | terminal_failure). Follow data.next.action: contact_support (open a ticket: the provider needs an action Swapper cannot take), requote_and_create_new_order (this order can't be funded: re-quote and create a new order).
7) On terminal_failure, POST /support/tickets with the orderId. Lost the orderId? GET /swap/orders?idempotencyKey=<the create key>.
On 503 order_outcome_unknown retry create with the same idempotency-key until it resolves. On quote_expired, re-quote ({"requoteOf": quoteId}) and create from the new quote.
Amounts are digits and one dot. Never invent or guess addresses or amounts. Never ask for seed phrases or private keys. Never ask the user to fund before data.deposit exists.
Rules and limits
- No API key. Rate limited per IP: honor
429+Retry-Afterwith exponential backoff. - Restricted regions (including the US) get
451on trading endpoints; quickstart stays reachable. - Creating an order moves no funds; whether to confirm with the user first follows the user's and the client's policy. Funds move only when the user's wallet signs. Fund
data.deposit.paymentonce, only whiledata.payableis true, only ifdata.destinationis the user's own address and only ifPOST /api/v1/agent/swap/payment-checkreturnsdata.paymentCheck.safeToSend: true. Never ask for seed phrases or private keys. - Every error response is
{ ok: false, error: { code, message, details, retryable, requestId } }; a POST body that is not JSON answers415 unsupported_media_type. - Idempotency keys must be random (a UUID per order): anyone who knows one can look its order up. Never derive them from user names or dates.
- Integration help: agent@xmrtousdc.xyz.
New here? The Monero swap API overview covers the same flow in three calls, with MCP setup for every client.