# Creating a Payout Request

This resource allows users to submit cryptocurrency payouts to active recipients. It caters to various use cases such as offering cryptocurrency withdrawals to clients, facilitating payouts for marketplaces or affiliate networks, or managing payroll by creating multiple payouts at a time.

**Endpoint**

<mark style="color:green;">**`POST`**</mark>`https://api.tylt.money/transactions/merchant/createPayoutRequest`

**Request Headers**

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

<table data-full-width="true"><thead><tr><th width="133">Name</th><th width="79">Type</th><th width="167">Example</th><th>Description</th></tr></thead><tbody><tr><td>X-TLP-APIKEY</td><td>string</td><td>93ee3c5e133697251b5362bcf9cc8532476785t8768075616f58d88</td><td>Your Tylt API Key, used to identify your account in API requests.</td></tr><tr><td>X-TLP-SIGNATURE</td><td>string</td><td>d0afef3853dfc8489c8b9affa5825171fdd7y7685675e4966a05f66ed2b3eaf9462b3c9c0</td><td>HMAC SHA-256 signature generated using the API Secret Key to secure the request.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
When using the API, ensure to include your API Key and generate the signature for the request payload using your API Secret. The tables provided above contain example values for illustration purposes only. Please refer to the code snippets for detailed instructions on how to sign the request and generate the signature properly.
{% endhint %}

**Request Body**

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

<table data-header-hidden><thead><tr><th width="172"></th><th width="136"></th><th></th></tr></thead><tbody><tr><td><strong>Field Name</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td>baseAmount</td><td>number</td><td>The amount of currency to be sent.</td></tr><tr><td>baseCurrency</td><td>string</td><td><strong>Optional:</strong> To be used if the amount into crypto to be sent is expressed as FIAT. The baseCurrency symbol must be of the FIAT currency. Check supporting baseCurrency API for more details.</td></tr><tr><td>address</td><td>string</td><td>The recipient's address for the payout.</td></tr><tr><td>settledCurrency</td><td>string</td><td>The currency in which the payout will be made (symbol).</td></tr><tr><td>networkSymbol</td><td>string</td><td>The network to be used for the payout (e.g., BSC).</td></tr><tr><td>customerName</td><td>string</td><td>Optional: Customer's name for the transaction.</td></tr><tr><td>comments</td><td>string</td><td>Optional: Comments for additional context.</td></tr><tr><td>callBackUrl</td><td>string</td><td>Optional: URL for the callback after transaction completion.</td></tr><tr><td>redirectUrl</td><td>string</td><td>Optional: URL for the redirection after transaction completion.</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>
{% endtab %}
{% endtabs %}

**Code Snippet**

{% tabs %}
{% tab title="Node JS" %}

```javascript
const axios = require('axios');
const crypto = require('crypto');

// Replace with your API Key and Secret
const apiKey = 'your-api-key';
const apiSecret = 'your-api-secret';

// Request body
// In this example we are sending USDT worth INR 10000 to the web3 address
const requestBody = {
    baseAmount: 10000,
    baseCurrency: "INR"
    address: "0xd2AF4B117EfE474B66Fc79E6A8E1938D41a60F4c",
    settledCurrency: "USDT",
    networkSymbol: "BSC",
    callBackUrl:"www.callback.com",
    redirectUrl:"www.redirect.com"
};

// Convert request body to JSON
const raw = JSON.stringify(requestBody);

// Function to create HMAC SHA-256 signature
const createSignature = (secret, data) => {
    return crypto.createHmac('sha256', secret)
                 .update(data)
                 .digest('hex');
};

// Generate signature
const signature = createSignature(apiSecret, raw);

// Define headers
const headers = {
    "Content-Type": "application/json",
    "X-TLP-APIKEY": apiKey,
    "X-TLP-SIGNATURE": signature
};

// Function to send the request
const sendRequest = async (url, headers, body) => {
    const response = await axios.post(url, body, { headers: headers });
    return response.data;
};

// Send the request
sendRequest("https://api.tylt.money/transactions/merchant/createPayoutRequest", headers, raw)
    .then(result => console.log("Success:", result))
    .catch(error => console.error("Error:", error));

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import hmac
import hashlib
import json

# Replace with your API Key and Secret
api_key = 'your-api-key'
api_secret = 'your-api-secret'

# Request body
request_body = {
    "baseAmount": 10000,
    "baseCurrency": "INR"
    "address": "0xd2AF4B117EfE474B66Fc79E6A8E1938D41a60F4c",
    "settledCurrency": "USDT",
    "networkSymbol": "BSC",
    "callBackUrl":"www.callback.com",
    "redirectUrl":"www.redirect.com"
}

# Convert request body to JSON
raw = json.dumps(request_body, separators=(',', ':'), ensure_ascii=False)

# Function to create HMAC SHA-256 signature
def create_signature(secret, data):
    return hmac.new(secret.encode(), data.encode(), hashlib.sha256).hexdigest()

# Generate signature
signature = create_signature(api_secret, raw)

# Define headers
headers = {
    "Content-Type": "application/json",
    "X-TLP-APIKEY": api_key,
    "X-TLP-SIGNATURE": signature
}

# Send the request
response = requests.post("https://api.tylt.money/transactions/merchant/createPayoutRequest", headers=headers, data=raw)

# Print the response
print("Success:", response.json())

```

{% endtab %}
{% endtabs %}

**Response**

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

```json
{
    "data": {
        "orderId": "1deecabb-79b8-11ef-8277-02d8461243e9",
        "merchantOrderId": "1deecabb-79b8-11ef-8277-02d8461243e9",
        "settledCurrency": "USDT",
        "settledAmountRequested": 0.1,
        "settledAmountDebited": 0,
        "settledAmountSent": 0,
        "commission": 0,
        "network": "BSC",
        "toAddress": "0xh22kbbq3hbth4bjwh433adgda",
        "status": "Pending",
        "insufficientBalance": 0,
        "paymentURL": "",
        "callBackURL": "",
        "transactions": [],
        "createdAt": "2024-09-23T14:28:35Z",
        "expiresAt": "2024-09-23T14:28:35Z",
        "updatedAt": "2024-09-23T14:28:35Z",
        "isFinal": 0,
        "isDebited": 0,
        "customerName": "",
        "comments": ""
    },
    "msg": "Withdrawal request accepted"
}
```

{% endtab %}

{% tab title="Response Fields" %}

| **Field Name**           | **Type** | **Description**                                                                   |
| ------------------------ | -------- | --------------------------------------------------------------------------------- |
| `orderId`                | String   | The order ID generated by TL Pay, used as a global identifier.                    |
| `merchantOrderId`        | String   | The merchant's local order ID for reference (optional).                           |
| `settledCurrency`        | String   | The cryptocurrency or token used for payout.                                      |
| `settledAmountRequested` | Number   | The amount of cryptocurrency or token requested to be paid out.                   |
| `settledAmountDebited`   | Number   | The amount of cryptocurrency debited from your merchant balance.                  |
| `settledAmountSent`      | Number   | The total amount of cryptocurrency sent to the recipient.                         |
| `commission`             | Number   | The commission deducted from the payout transaction.                              |
| `network`                | String   | The blockchain network over which the payout is made (e.g., "BSC").               |
| `toAddress`              | String   | The recipient's wallet address where the payout will be sent.                     |
| `status`                 | String   | The status of the payout (e.g., "Pending", "Completed", "Failed").                |
| `insufficientBalance`    | Number   | Indicates if there is insufficient balance for the transaction (1 = Yes, 0 = No). |
| `paymentURL`             | String   | The URL where the customer can make the payment (if applicable).                  |
| `callBackURL`            | String   | The callback URL specified by the merchant (optional).                            |
| `transactions`           | Array    | Details of any individual transactions linked to this payout (if applicable).     |
| `createdAt`              | String   | The timestamp when the payout request was created.                                |
| `expiresAt`              | String   | The timestamp when the payout request will expire.                                |
| `updatedAt`              | String   | The timestamp when the payout request was last updated.                           |
| `isFinal`                | Number   | Indicates if the transaction is final (`1` for completed, `0` for pending).       |
| `isDebited`              | Number   | Indicates if the payout amount has been debited from your merchant account.       |
| `customerName`           | String   | The name of the customer associated with the transaction (optional).              |
| `comments`               | String   | Any comments or notes provided by the merchant (optional).                        |
| {% endtab %}             |          |                                                                                   |
| {% endtabs %}            |          |                                                                                   |
