> For the complete documentation index, see [llms.txt](https://docs.swap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.swap.io/developer-tools/agent-api-x402.md).

# Agent API (x402)

Paid API for developers and AI agents. There are no accounts, no API keys and no subscriptions: each request is paid for individually with a USDC micropayment over the open [x402 protocol](https://docs.x402.org). If your client speaks x402, you can start using the API immediately; protocol details live in the x402 documentation and are not repeated here.

**Base URL:** `https://hermes.swap.io` (launching soon)

## What you get

Direct access to the swap.io routing engine, which aggregates multiple liquidity providers and returns the best routes:

* `POST /v1/swap/quote` - aggregated multi-provider quote for a token pair.
* `POST /v1/swap/build-tx` - unsigned transaction built from the quote you picked.
* `POST /v1/swap/submit-tx` - broadcast your signed transaction (optional; you can also broadcast it yourself with any Solana RPC).
* `GET /v1/swap/status` - free, check the broadcast status of a transaction by its `transactionHash`.

The full lifecycle is quote -> build-tx -> submit-tx -> status, with submit-tx and status optional: you sign and broadcast the transaction with your own key, so the service is non-custodial and never touches your funds.

Each endpoint is priced separately, so a full swap is two paid calls (quote, build-tx), with a third optional paid call to broadcast (submit-tx) and free polling for confirmation (status). Comparing quotes before committing to one is therefore cheap.

`submit-tx` charges as soon as the network accepts the transaction and returns a `transactionHash`; it does not wait for the transaction to be confirmed or finalized. Use the free `status` endpoint to track confirmation afterward.

## Authentication and payment

None of the usual machinery. Calling an endpoint without payment returns HTTP 402 with the exact price and payment terms for that request; any x402-compatible client pays and retries automatically. Payments are made in USDC on Solana.

Two guarantees on every request:

* you are never charged for a failed request;
* every paid response carries an on-chain settlement receipt in the `X-PAYMENT-RESPONSE` header.

## Discovery

`GET /v1/info` returns a machine-readable description of the API: mounted endpoints, their base prices and the accepted payment options.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.swap.io/developer-tools/agent-api-x402.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
