# Creating a payout

**POST** `https://api.heleket.com/v1/payout`

The payouts through API are made only from your business wallets balances.

Payouts can be made in different ways:

1.  You can choose to receive the payout in a specific cryptocurrency and the payout will then be automatically processed in that specific cryptocurrency. To do so, ensure that you have sufficient balance in that particular currency to cover all associated fees.
2.  Alternatively, you have the option to specify the payout amount in a fiat currency. In this case, the amount will be automatically converted to a specific cryptocurrency from your available balance. For instance, if you request a payout of 20 USD in LTC, the equivalent value will be deducted from your LTC balance. It is important to have enough funds in the corresponding cryptocurrency to cover all applicable fees.
3.  Another possibility is to specify the payout amount in a fiat currency, which will be automatically converted to a specific cryptocurrency using your USDT balance. This option is particularly useful when you have autoconvert enabled, as funds from your invoices are automatically converted to USDT. For example, if you want to make a payout of 20 USD in LTC but only have a balance in USDT, make sure you have sufficient USDT funds to cover all fees.
4.  Additionally, you can choose to specify the payout amount in any cryptocurrency of your preference. The payout will then be automatically processed in that specific cryptocurrency, utilizing your available USDT balance. It is crucial to have enough USDT balance to cover all associated fees.

## Request

### Body parameters (response\_parameters)

| Name | Parameter type | Default value | Definition |
| --- | --- | --- | --- |
| amount (required) | string |  | Payout amount |
| currency (required) | string |  | Currency code for the payout<br>If Currency if fiat, the _to\_currency parameter is required_.|
| order\_id (required) | string<br>min:1<br>max:100<br>alpha\_dash|  | Order ID in your system<br>The parameter should be a string consisting of alphabetic characters, numbers, underscores, and dashes. It should not contain any spaces or special characters.<br>The _order\_id_ must be unique within the merchant payouts<br>When we find an existing payout with _order\_id_, we return its details, a new payout will not be created.|
| address (required) | string |  | The address of the wallet to which the withdrawal will be made |
| is\_subtract (required) | boolean |  | Defines where the withdrawal fee will be deducted<br>true - from your balance<br>false - from payout amount, the payout amount will be decreased|
| network (required) | string |  | Blockchain network code<br>Not required when the _currency/to\_currency_ is a cryptocurrency and has only one network, for example BTC|
| url\_callback | string |  | URL to which webhooks with payout status will be sent |
| to\_currency | string |  | Cryptocurrency code in which the payout will be made. It is used when the _currency_ parameter is fiat. See examples below |
| course\_source | string<br>Available values<br>• Binance<br>• BinanceP2p<br>• Exmo<br>• Kucoin| Value from merchant's settings | The service from which the exchange rates are taken for conversion in the invoice.<br>The parameter is applied only if the currency is fiat, otherwise the default value is taken from the merchant's settings.|
| from\_currency | string | null | Allows to automatically convert the withdrawal amount and use the from\_currency balance. Only USDT is available. |
| priority | string<br>min: 4<br>max: 11<br>Available values<br>• recommended<br>• economy<br>• high<br>• highest| recommended | The parameter for selecting the withdrawal priority. The cost of the withdrawal fee depends on the selected parameter.<br>This parameter is applied only in case of using the BTC, ETH, POLYGON, and BSC networks.|
| memo | string<br>min: 1<br>max: 30|  | Additional identifier for TON, used to specify a particular recipient or target |

### Request example

```
curl https://api.heleket.com/v1/payout \
-X POST \
-H 'merchant: 8b03432e-385b-4670-8d06-064591096795' \
-H 'sign: fe99035f86fa436181717b302b95bacff1' \
-H 'Content-Type: application/json' \
-d '{
    "amount": "5",
    "currency": "USDT",
    "network": "TRON",
    "order_id": "1",
    "address": "TDD97yguPESTpcrJMqU6h2ozZbibv4Vaqm",
    "url_callback": "https://your.site/callback",
    "is_subtract": "1"
}'
```

## Response

### Response parameters

| Name | Definition |
| --- | --- |
| uuid | uuid of the payout |
| amount | Payout amount in _currency_ |
| currency | Currency code for the payout |
| network | The code of the blockchain network in which the payment is made |
| address | The address of the wallet to which the payment is made |
| txid | Transaction ID in the blockchain |
| status | Payout status [See all available statuses](https://doc.heleket.com/methods/payouts/payout-statuses.md) |
| is\_final | Whether the payout is finalized<br>The payout process is considered finalized once it has been successfully paid or if it has failed. In the event of a payout failure, the funds will be returned to your balance, requiring you to initiate the payout process again.|
| balance | The remaining funds on the merchant's balance. |
| payer\_currency | Cryptocurrency code in which the payout will be actually made. The payout address will receive the payout currency. |
| payer\_amount | Amount in payer\_currency of the payout |
| commission | Service commission |
| merchant\_amount | The amount debited from the balance, taking into account all fees |
| convert | Conversion information. The conversion is from from\_currency to to\_currency.<br>The convert field will not exist if you do not pass from\_currency or it is the same as to\_currency<br>[Structure](https://doc.heleket.com/methods/payouts/creating-payout.md#convert) |

### Structure of _convert_

| Name | Definition |
| --- | --- |
| to\_currency | The code of the currency into which the payment will be swapped |
| from\_currency | The currency from which the payment is swapped |
| commission | Conversion fee |
| rate | Conversion rate |
| from\_amount | The amount swapped to from\_currency that was debited from the balance, minus all fees. |

### Response example

```
{
    "state": 0,
    "result": {
        "uuid": "a7c0caec-a594-4aaa-b1c4-77d511857594",
        "amount": "3",
        "currency": "USDT",
        "commission": "0.001",
        "merchant_amount": "3.001",
        "network": "TRON",
        "address": "TJ...",
        "txid": null,
        "status": "process",
        "is_final": false,
        "balance": 129,
        "payer_currency": "USDT",
        "payer_amount": 3
    }
}
```

## Possible errors

### Validation errors

code : 422

example responses:

```
{
	"state": 1,
	"errors": {
		"amount": ["validation.required"]
	}
}
```

If the payout is blocked on your merchant or user, you will receive this error message. This happens, for example, when you change your password and payouts are blocked for 24 hours.

```
{
    "state": 1,
    "message": "You are forbidden"
}
```

If we don’t support the currency code you provided in currency parameter, you will receive this error message:

```
{
    "state": 1,
    "message": "The currency was not found"
}
```

If we can not find the service for executing payout, you will receive this error message. You have to make sure that the cryptocurrency is supported. Check the correctness of the entered values in. currency, network, from\_currency, to\_currency:

```
{
    "state": 1,
    "message": "The service was not found"
}
```

If the withdrawal amount is too small, you will receive this error message:

```
{
    "state": 1,
    "message": "The withdrawal amount is too small"
}
```

If you will not have an active merchant wallet with a cryptocurrency of the payout, you will receive this error:

```
{
    "state": 1,
    "message": "Wallet not found"
}
```

If the payout amount, including all commissions, is more than your balance, you will receive this error message:

```
{
    "state": 1,
    "message": "Not enough funds"
}
```

If we don’t find the payout service of the currency that was passed in to\_currency parameter, you will receive this error message:

```
{
    "state": 1,
    "message": "Not found service to_currency"
}
```

If accidentally something happens when swapping to to\_currency, you will receive this error message:

```
{
    "state": 1,
    "message": "Error convert to_currency"
}
```

If the payout amount is less than the minimum supported amount for cryptocurrency, you will receive this error message:

```
{
    "state": 1,
    "message": "Minimum amount 0.5 USDT"
}
```

If the payout amount is greater than the maximum supported amount for cryptocurrency, you will receive this error message:

```
{
    "state": 1,
    "message": "Maximum amount 10000000 USDT"
}
```

If you don’t have enough funds to make a payout, you will receive this error message:

```
{
    "state": 1,
    "message": "Not enough funds"
}
```

If you don't have enough funds to swap the payout amount from from\_currency, you will receive this error message:

```
{
    "state": 1,
    "message": "Not enough balance for convert USDT to LTC"
}
```

If technical work occurs and the payout is temporarily unavailable, you will receive this error message

```
{
    "state": 1,
    "message": "The terminal was not found"
}
```

### Internal server error

code : 500

example responses:

```
{
	"message": "Server error, #1",
	"code": 500,
	"error": null
}
```
