Answered from live records · 2026-09-15
How do I call Sato Swap from code?
POST /api/swap/quote with a JSON intent, or call the MCP tool onchain_agent_swap — the same module answers both. No key is needed, and a refusal arrives as a 200 carrying its reason, as of 2026-09-15.
Both lanes into Sato Swap, and the four things that surprise people: a refusal is a 200, responses are never cached, a key raises a limit rather than unlocking a feature, and the response can be checked against a published key.
| Lane | How |
|---|---|
| HTTP | POST /api/swap/quote with a JSON body: chain_in, token_in, token_out, amount_in (base units, as a string), taker and mode. Responses are no-store, because a cached quote is a stale price. |
| MCP | onchain_agent_swap over POST /api/mcp, Streamable HTTP. Same module, same refusals, same fee sentence — one implementation behind two transports, so the two lanes cannot disagree. |
| mode | Omit it, or send "recommend", to be told where to go and why with no transaction attached. Send "build-tx" to be handed an unsigned transaction when the gate and the simulation both allowed it. |
| Auth | None required. A Sato API key raises the hourly bound rather than unlocking anything: a key only ever raises a limit. |
| A refusal is a 200 | Gate refusals, policy limits and unsimulatable routes arrive as HTTP 200 with tx null and a withheld object. It is an answer, not a failure — retrying it unchanged refuses again. 4xx is reserved for an unreadable body, auth and rate limits. |
| Verifying the answer | Responses carry an Ed25519 signature in meta.signature and a Sato-Signature header where a signing key is configured, plus Link: rel=describedby pointing at the published schema. Check it against /.well-known/jwks.json. |
| Schemas | swap-quote and swap-receipt, v1, served under /schemas. v1 is additive-only and additionalProperties stays open, so a pinned consumer does not break on a new field. |
How this was answered
The two transports in app/api/swap/quote/route.ts and the onchain_agent_swap registration in lib/mcp/tools.ts, both of which call lib/swap/quoteHandler.ts — one implementation, so the HTTP lane and the MCP lane cannot answer differently.
Every answer on this page is produced by one named function over Sato Hub's live records on the date shown. Nothing is typed by hand, no figure is carried over from a previous day, and an answer with nothing behind it says unknown rather than zero. The Sato Score measures how open, active and verifiable a project is — it is not a safety, quality or returns grade.
Go deeper
More questions
Sources — the projects' own repositories and docs
Cite this page
Sato Hub. "How do I call Sato Swap from code?." Sato Hub, updated 2026-09-15, accessed 2026-09-16. https://satohub.ai/answers/how-do-i-call-sato-swap-from-codeData last refreshed 2026-09-15; this page is rebuilt daily. Citations carry the date so a reader can tell which snapshot a claim came from. Catalog data is licensed CC-BY-4.0 and the machine-readable copy is linked in the page's Dataset metadata.