# recovered energy

### Endpoint usage

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

The fields with \* are required, and the fields without \* are optional\
related parameters can be got from Query selling records by address

#### Request Body

| Name                                            | Type   | Description                                                                                       |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| saleAddress<mark style="color:red;">\*</mark>   | String | user address (wallet address)                                                                     |
| 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) |
| orderType<mark style="color:red;">\*</mark>     | String | order type(ENERGY/BANDWIDTH)                                                                      |
| pledgeAddress<mark style="color:red;">\*</mark> | String | target address for selling energy                                                                 |
| payTrxNum<mark style="color:red;">\*</mark>     | String | amount of recovered trx                                                                           |

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

```javascript
{
    "resCode": 100,
    "resMsg": "Success",
    "data": {
        "visible": false,
        "txID": "b20aeb61595643ce60f50b34d839a81ad426f6a93ddf2c4ea3a5b727d6ae75cb",
        "raw_data": {
            "contract": [
                {
                    "parameter": {
                        "value": {
                            "balance": 301000000,
                            "resource": "ENERGY",
                            "receiver_address": "416a91f86fc9b7e98b01a9d9141db61aed6f389b9e",
                            "owner_address": "41dcf5a07cfac1534c2410714d6ba6576f49c4a6d7"
                        },
                        "type_url": "type.googleapis.com/protocol.UnDelegateResourceContract"
                    },
                    "type": "UnDelegateResourceContract"
                }
            ],
            "ref_block_bytes": "698e",
            "ref_block_hash": "f8c19af47b0e65d3",
            "expiration": 1682476032000,
            "timestamp": 1682475972451
        },
        "raw_data_hex": "0a02698e2208f8c19af47b0e65d34080c08bdbfb305a75083a12710a37747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e556e44656c65676174655265736f75726365436f6e747261637412360a1541dcf5a07cfac1534c2410714d6ba6576f49c4a6d7100118c0cac38f012215416a91f86fc9b7e98b01a9d9141db61aed6f389b9e70e3ee87dbfb30"
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

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

{% endtab %}
{% endtabs %}

### code example

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

```
// example
const params = {
    saleAddress: 'TKghVbeEzvrV8GLK3YE1gRrjVHSf8rGB6k',
    pledgeAddress: 'TW7XuicuiQSHCcodUkyjMfdWxnWsbZmiSS',
    orderType: 'ENERGY',
    payTrxNum: 111,
    sourceFlag: 'tronLink'
}
 const res = await axios.post('https://open.tronify.io/api/tronRent/undelegateresource',params)
 console.log(res)
 if(res.resCode === '100'){
    const signedTx = await tronWeb.trx.sign(res.data)
    const broastTx = await tronWeb.trx.sendRawTransaction(signedTx)
    return broastTx.txid 
 }
```

{% endtab %}
{% endtabs %}

### Postman example

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


---

# Agent Instructions: 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:

```
GET https://docs-tron.en.tronify.io/tron-api/recovered-energy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
