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

# Conversion API

API specs for conversion workflow, for web portal access, please see [here](/features/crypto-conversion.md).

## Get conversions

<mark style="color:blue;">`GET`</mark> `https://api.aquanow.io/payment/v1/conversion`

Get conversion history by ID or time range.

#### Query Parameters

| Name                                        | Type   | Description                               |
| ------------------------------------------- | ------ | ----------------------------------------- |
| invoiceId<mark style="color:red;">\*</mark> | String |                                           |
| startTime<mark style="color:red;">\*</mark> | String | ISO 8601 format                           |
| endTime                                     | String | ISO 8601 format. Default to request time. |

{% tabs %}
{% tab title="200: OK " %}

```javascript
[
    {
        "quantity": 54.692493,
        "baseSymbol": "USDC",
        "status": "CANCELLED",
        "created": "2022-06-24T23:50:23.486Z",
        "items": [
            {
                "txId": "f473123d-a0c1-4a25-a713-2c5ecab27bfa",
                "address": "0x0aE90a043419DAe46774Ba067263202c1a0F60FF",
                "quantity": 52.461662,
                "subaccount": "usdc-5"
            },
            {
                "txId": "948bf813-e055-4e24-be26-5ead961f1fd2",
                "address": "0x1e4622932738763107E949e011167176F14C5327",
                "quantity": 2.230831,
                "subaccount": "usdc-4"
            }
        ],
        "quoteSymbol": "CAD",
        "username": "jeffen",
        "side": "SELL",
        "invoiceId": "f81123c8-2edd-4f29-88e7-6da5f855e48c",
        "type": "CONVERSION"
    }
]
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="404: Not Found Only for invoiceId response" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Create a conversion

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/payment/v1/conversion`

Create a conversion invoice by passing conversion info and conversion items(addresses of bills)

#### Request Body

| Name                                          | Type                       | Description                                                                                                        |
| --------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| baseSymbol<mark style="color:red;">\*</mark>  | String                     | Crypto to convert                                                                                                  |
| quoteSymbol<mark style="color:red;">\*</mark> | String                     | Fiat to receive                                                                                                    |
| quantity<mark style="color:red;">\*</mark>    | Number                     | Total crypto quantity to convert                                                                                   |
| items<mark style="color:red;">\*</mark>       | Array<{paymentId: string}> | An array of object that contains `paymentId` of each bills. They must have the same `baseSymbol` and `quoteSymbol` |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "invoiceId": "1663abe9-509c-4e0a-ab0a-aa340cbe7340",
    "status": "CREATED",
    "items": [
        {
            "txId": "72302a49-6948-4217-9131-534bec20cc4c",
            "quantity": 52.461662,
            "subaccount": "aq-3578-usdc-5",
            "address": "0x11182D6C867B17c6BCE7a2d5711C33a0B61621C9"
        },
        {
            "txId": "fcfdc253-cc05-4121-a2be-ab3e77323128",
            "quantity": 2.230831,
            "subaccount": "aq-3578-usdc-4",
            "address": "0x693eDfb2352FE1e3a6D1ce95291c30FCc4b5990C"
        }
    ],
    "username": "jeffen",
    "baseSymbol": "USDC",
    "quoteSymbol": "CAD",
    "side": "SELL",
    "quantity": 54.692493
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Cancel a conversion

<mark style="color:red;">`DELETE`</mark> `https://api.aquanow.io/payment/v1/conversion`

#### Request Body

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| invoiceId<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Quote a conversion

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/payment/v1/conversion/quote`

#### Request Body

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| invoiceId<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "quoteId": "768b49f3-5359-471d-812f-398c0544e646",
    "quoteTime": 1656191311136,
    "expireTime": 1656191319136,
    "symbol": "USDC-CAD",
    "side": "sell",
    "receiveCurrency": "CAD",
    "receiveQuantity": 70.4001769896,
    "deliverCurrency": "USDC",
    "deliverQuantity": 54.692493,
    "price": 1.2872
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Execute a conversion

<mark style="color:green;">`POST`</mark> `https://api.aquanow.io/payment/v1/conversion/execute`

#### Request Body

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| invoiceId<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "invoiceId": "1663abe9-509c-4e0a-ab0a-aa340cbe7340"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}


---

# 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.aquapay.io/api-endpoints/conversion-api.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.
