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

# Buyer leas energy

<mark style="color:green;">`POST`</mark> `https://open.tronify.io/api/tronRent/addTronRentRecord`

#### Headers

| Name                                      | Type   | Description                                                                                                       |
| ----------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------- |
| api-key<mark style="color:red;">\*</mark> | String | Access the buyer management platform of tronify.io to obtain it. tradeType must be provided when it is userTrade. |

#### Request Body

| Name                                            | Type   | Description                                                                                                                                  |
| ----------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| fromAddress<mark style="color:red;">\*</mark>   | String | user address(wallet address for buyer)                                                                                                       |
| sourceFlag<mark style="color:red;">\*</mark>    | String | Source channel (Both sides need to agree on a name to represent the channel of the third parties)                                            |
| pledgeNum<mark style="color:red;">\*</mark>     | String | amount of energy                                                                                                                             |
| orderType<mark style="color:red;">\*</mark>     | String | ENERGY                                                                                                                                       |
| pledgeHour<mark style="color:red;">\*</mark>    | String | an integer value should be passed to indicate the number of hours for which the energy is frozen. Currently, only 0, 1, and 3 are supported. |
| pledgeDay<mark style="color:red;">\*</mark>     | String | an integer value should be passed to indicate the number of days for which the energy is frozen (e.g. 0, 1, 2, 3).                           |
| tradeType<mark style="color:red;">\*</mark>     | String | userTrade                                                                                                                                    |
| pledgeAddress<mark style="color:red;">\*</mark> | String | energy/bandwidth receiving address.  multiple addresses can be submitted for bulk leas energy by separating them with commas.                |
| pledgeMinute<mark style="color:red;">\*</mark>  | String | only 0, 10 are supported.                                                                                                                    |

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

```
{
    "resCode": 100,
    "resMsg": "Success",
    "data": {
        "orderId": "16zi4ynw_sdvn_qv8h_ujfc_crfsgyi07zat",
        "fromAddress": "TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k",//wallet address
        "pledgeAddress": "TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k",//energy recieving address
        "pledgeDay": 3,
        "source": "tronLink",
        "orderType": "ENERGY",
        "orderPrice": 110,
        "pledgeNum": 500,
        "pledgeTrxNum": 0.165
    }
}
```

{% endtab %}
{% endtabs %}

### code example

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

```
// example
const params = {
    fromAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeDay: 3,
    pledgeHour: 0,
    pledgeMinute: 0,
    orderType: 'ENERGY',
    pledgeNum: 500,
    sourceFlag: 'tronLink',
    tradeType: 'userTrade'
}
const headers = {
  'api-key': 'your-api-key'
};
 const res = await axios.post('https://open.tronify.io/api/tronRent/addTronRentRecord',params, { headers })
 console.log(res)
 if(res.resCode === '100'){
   //...  
 }
```

{% endtab %}
{% endtabs %}

### Postman example

<figure><img src="/files/pk8G1Vw5VXeghqL9JWXM" alt=""><figcaption></figcaption></figure>
