# Create auto-swap

The method create auto-swap request

Amount limits apply to creation:

* the amount must be **more than $20 in equivalent**
* the amount must be **twice the commission of the network of the final coin/network** (*see the method of obtaining available coins*)

## Description of the request parameters

| Parameter     | Type      | Required | Description                                           |
| ------------- | --------- | -------- | ----------------------------------------------------- |
| `address`     | `string`  | yes      | Destination address                                   |
| `currency`    | `string`  | yes      | The coin you want to receive                          |
| `network`     | `string`  | yes      | The network where you want to receive coins           |
| `amountFrom`  | `string`  | no       | Outgoing amount                                       |
| `amountTo`    | `string`  | no       | The final amount                                      |
| `feeInAmount` | `boolean` | no       | Include the network commission in the swap amount     |
| `webhookUrl`  | `string`  | no       | URL for sending notifications when the status changes |

> It is necessary to send one of the parameters: `amountFrom` or `amountTo`\
> When specifying two parameters, the priority will be `amountFrom`

### Include the network's commission in the swap amount

By specifying the `feeInAmount` parameter in the value `true`, the specified **amount + network** commission will be debited from the address

* If you specify `amountFrom`, the final amount `amountTo` may slip (it may differ from the one specified after the creation request)
* If you specify `amountTo`, the estimated amount of the debit from the address will be blocked + a percentage to cover the insurance of slippage. After the exchange is completed, the amount will be corrected to the amount that was spent for the swap.\
  \&#xNAN;*There may be a slight slippage (≈ 0.1%) of the final amount due to the imposition of swap filters on the amount to be received*

## Description of the response parameters

| Parameter              | Type     | Description                                                                                          |
| ---------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
| `id`                   | `string` | Auto-swap ID                                                                                         |
| `organizationId`       | `string` | Organization ID                                                                                      |
| `status`               | `enum`   | Status                                                                                               |
| `currencyFrom`         | `string` | Outgoing coin of the address selected for auto-swap                                                  |
| `networkFrom`          | `string` | Outgoing network of the address selected for auto-swap                                               |
| `currencyTo`           | `string` | The final coin to be sent to the client                                                              |
| `networkTo`            | `string` | The final network to be sent to the client                                                           |
| `amountFrom`           | `string` | The amount spent for the operation                                                                   |
| `amountFromUSD`        | `string` | The amount spent for the operation in terms of USD                                                   |
| `amountTo`             | `string` | The final amount after the swap                                                                      |
| `amountToUSD`          | `string` | The final amount after the swap in terms of USD                                                      |
| `amountToReceive`      | `string` | The amount that the client will receive                                                              |
| `rate`                 | `string` | Swap rate                                                                                            |
| `blockchainFeeFrom`    | `string` | The network's commission for sending coins to the provider for making a swap                         |
| `blockchainFeeFromUSD` | `string` | The network's commission for sending coins to the provider for making a swap in terms of USD         |
| `blockchainFeeTo`      | `string` | The network's commission for sending coins from the provider to the client's address                 |
| `blockchainFeeToUSD`   | `string` | The network's commission for sending coins from the provider to the client's address in terms of USD |
| `serviceFee`           | `string` | Service commission for the operation                                                                 |
| `webhookUrl`           | `string` | URL for sending status change notification                                                           |
| `createdAt`            | `string` | Date of creation of the auto-exchange                                                                |
| `updatedAt`            | `string` | Date of the last update of the change                                                                |

Statuses:

| Status        | Description                                   |
| ------------- | --------------------------------------------- |
| `PENDING`     | In processing                                 |
| `WITHDRAWING` | Waiting to be sent to the destination address |
| `PROCESSED`   | Successfully                                  |
| `REJECTED`    | Rejected                                      |
| `ERROR`       | Processing error                              |

{% openapi src="/files/sW3pCSavW8K5JCHRyMVw" path="/api-gateway/auto-swaps/create" method="post" %}
[openapi.json](https://199856430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy7yrGizyjjV5OmCw3DcE%2Fuploads%2Fgit-blob-c16b91898f63e16257eb0e0b6bb8d49e7f547d73%2Fopenapi.json?alt=media)
{% endopenapi %}


---

# Agent Instructions: 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:

```
GET https://docs.onchainpay.io/api-reference/auto-swaps/post_create.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
