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

# Swaps

Crosschain swap is the exchange of one asset for another.

To carry out an asset swap, you need to make sure that this service is available in the networks you have chosen. To do this, request [list of available coins](#e4658fd5-5daf-4689-b845-663f8ed93470), find the coin you need, it will have a list of `networks` networks, make sure that the network of the asset you want to swap the `allowCrosschainSwapFrom` flag is wound `true`, and the network of the asset you want to receive has `allowCrosschainSwapTo` equal to `true`.

For example:\
You have **ETH** in the **Ethereum** network, in the list of available coins you should find the **ETH** coin, then in the list of `networks` find the `ethereum` network it should have `"allowCrosschainSwapFrom ": true`

```json
{
  "success": true,
  "response": [
    ...
    {
      "currency": "ETH",
      ...
      "networks": [
        ...
        {
          "name": "ethereum",
          ...
          "allowCrosschainSwapFrom": true,
          ...
        }
        ...
      ]
    },
    ...
  ]
}

```

You want to swap it for **USDT** on the **Tron** network, in the list of available coins you should find the **USDT** coin, then in the `networks` list, find the `tron` network, it should have `"allowCrosschainSwapTo": true`

```json
{
  "success": true,
  "response": [
    ...
    {
      "currency": "USDT",
      ...
      "networks": [
        ...
        {
          "name": "tron",
          ...
          "allowCrosschainSwapTo": true,
          ...
        }
        ...
      ]
    },
    ...
  ]
}

```

Find out the [allowable limit](#ebafca69-7149-4387-824d-3af906b37628) for the transaction amount. Please note that the limit amounts are indicated in **USD**, the rates of such stablecoins as **USDT**, **BUSD** etc do not differ significantly from the rate of **USD**, and if you want to exchange another coin, then you will need to get the exchange rate to **USD** to make sure that your amount meets the specified limits.

Request [fee preview](#1eb19a91-5101-4113-9bbd-e8b91467e181) to get a `token`, it will need to be specified when [requesting transaction creation](#75929dd7-c7f5-44b7-b830-018c2e0a0efe) as `feeToken`.

The operation is not executed immediately after the request, you must wait 1-3 minutes. You can [find out the operation execution status](#f1272a4a-fa54-4bb9-b627-43eafb81a6b8) yourself, or you can specify the URL to receive the [webhook](#webhooks) in the `webhookUrl` field when creating.

Available statuses

| **Status** | **Description**        |
| ---------- | ---------------------- |
| CREATED    | Request registered     |
| PENDING    | Processing             |
| ERROR      | Error during execution |
| REJECTED   | Request rejected       |
| PROCESSED  | Success                |

## API Interaction Scheme

{% @mermaid/diagram content="sequenceDiagram
Merchant ->> Onchainpay: Request fee token
Onchainpay ->> Merchant: Fee token
Merchant ->> Onchainpay: Creating operation
Onchainpay ->> Merchant: Operation body

```
Note over Onchainpay: Processing operation

Onchainpay -->> Merchant: Operation result webhook" %}
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.onchainpay.io/api-reference/09crosschain_swaps.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
