> 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/recovered-energy.md).

# 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>
