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

# Currency Conversion

With a single endpoint, you can convert between any two available currencies.

| Header        | Value              |
| ------------- | ------------------ |
| Authorization | Bearer SECRET\_KEY |
| Content-Type  | `application/json` |

The secret key can be gotten from the 'Settings' page on your Startbutton dashboard.

See [Authentication](/startbutton-product-api/getting-started/authentication.md).

**Endpoint**

POST: `{{baseurl}}/transaction`

| Param                                           | Required? | Description                                                             |
| ----------------------------------------------- | --------- | ----------------------------------------------------------------------- |
| "`fromCurrency`"                                | Yes       | <p>This is the currency you want to convert "<code>from</code>"<br></p> |
| `"fromAmount"`                                  | Yes       | This is the amount you want to convert "`from`"                         |
| <p><code>"fromWalletType"</code></p><p><br></p> | Yes       | This could be either "`payout`" or "`collection`"                       |
| `"toCurrency"`                                  | Yes       | This is the currency you want to convert "`to`"                         |

#### Sample code

**Required Param**

```json
{
    "fromAmount": 2,
    "toCurrency": "NGN",
    "fromCurrency": "USD",
    "fromWalletType": "payout"
}
```

#### Sample responses

{% tabs %}
{% tab title="Success" %}

```json
{
    "success": true,
    "message": "new transaction initialized",
    "data": {
        "transactionReference": "f6e3efcxxx7",
        "conversionTimeInHours": 24
    }
}
```

{% endtab %}

{% tab title="Insufficient balance" %}

```json
{ 
"success": false, 
"message": "User has insufficient balance.", 
"data": {} 
}
```

{% endtab %}
{% endtabs %}

## Webhook for Conversions

To learn how webhooks work, see [Conversion Events](/startbutton-product-api/webhooks/conversion-events.md).
