> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tronrental.com/llms.txt
> Use this file to discover all available pages before exploring further.

# एनर्जी नियम बनाएं

> जब भी किसी एड्रेस पर एनर्जी थ्रेशोल्ड से नीचे गिरे, उसे टॉप-अप करें

## एनर्जी नियम बनाएं

एक एड्रेस के लिए ऑटो रिफिल नियम बनाता है। अगली जाँच से, जब भी एड्रेस पर उपलब्ध एनर्जी `threshold_energy` से कम होती है, हम एक घंटे के लिए `add_volume` एनर्जी खरीदते हैं और आपके बैलेंस से शुल्क लेते हैं। जाँच, लागत और स्थितियाँ कैसे काम करती हैं, यह जानने के लिए [अवलोकन](/hi/api-reference/auto-refill/overview) देखें।

अनुरोध केवल नियम बनाता है — यह स्वयं कुछ नहीं खरीदता। `buy_energy` स्कोप आवश्यक है। पहले एक रिफिल की कीमत देखने के लिए [एनर्जी रिफिल मूल्य अनुमान](/hi/api-reference/auto-refill/quote-energy-refill) का उपयोग करें।

### अनुरोध बॉडी

**target\_address** `string` *required*

वह TRON एड्रेस जिस पर आपूर्ति बनाए रखनी है (T... प्रारूप, 34 अक्षर)। कॉन्ट्रैक्ट एड्रेस अस्वीकार किए जाते हैं।

**threshold\_energy** `number` *required*

जब एड्रेस पर उपलब्ध एनर्जी इससे कम हो, तब खरीदें। 1 से 50,000,000 तक।

**add\_volume** `number` *required*

प्रति रिफिल खरीदी जाने वाली एनर्जी। 32,000 से 5,000,000 तक। इसे `threshold_energy` के बराबर या उससे ऊपर रखें — देखें [अवलोकन में चेतावनी](/hi/api-reference/auto-refill/overview#संख्याएँ-कैसे-चुनें)।

**duration** `string` (default: 1h)

हर रिफिल के किराये की अवधि। केवल `"1h"` स्वीकार किया जाता है; कोई अन्य मान `422` लौटाता है।

**label** `string`

नियम के लिए आपका अपना नाम, अधिकतम 100 अक्षर। वैकल्पिक।

### रिस्पॉन्स

नया नियम — वही फ़ील्ड जो [एनर्जी नियमों की सूची](/hi/api-reference/auto-refill/list-energy-rules) में हैं — और साथ में इस समय के एड्रेस के बारे में दो फ़ील्ड:

**current\_energy** `number | null`

नियम बनाए जाने के समय एड्रेस पर उपलब्ध एनर्जी। यदि इसे पढ़ा नहीं जा सका तो `null`; नियम हर हाल में बन जाता है।

**will\_refill\_now** `boolean`

`true` यदि `current_energy` पहले से थ्रेशोल्ड से नीचे है, यानी अगली जाँच — आमतौर पर एक मिनट के भीतर — खरीदेगी। `false` यदि एड्रेस पर पर्याप्त है, या स्तर पढ़ा नहीं जा सका।

### उदाहरण

```bash cURL theme={null}
curl -X POST https://api.tronrental.com/v1/energy/auto-refill \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "target_address": "TYourRecipientAddress1234567890abc",
    "threshold_energy": 65000,
    "add_volume": 131000,
    "duration": "1h",
    "label": "Hot wallet"
  }'
```

```python Python theme={null}
import requests

resp = requests.post(
    "https://api.tronrental.com/v1/energy/auto-refill",
    headers={"X-API-Key": "your_api_key"},
    json={
        "target_address": "TYourRecipientAddress1234567890abc",
        "threshold_energy": 65000,
        "add_volume": 131000,
        "duration": "1h",
        "label": "Hot wallet",
    },
)
print(resp.json())
```

```javascript JavaScript theme={null}
const resp = await fetch("https://api.tronrental.com/v1/energy/auto-refill", {
  method: "POST",
  headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" },
  body: JSON.stringify({
    target_address: "TYourRecipientAddress1234567890abc",
    threshold_energy: 65000,
    add_volume: 131000,
    duration: "1h",
    label: "Hot wallet",
  }),
});
console.log(await resp.json());
```

```json Response theme={null}
{
  "id": 12,
  "target_address": "TYourRecipientAddress1234567890abc",
  "label": "Hot wallet",
  "threshold_energy": 65000,
  "add_volume": 131000,
  "duration": "1h",
  "status": "active",
  "stopped_reason": null,
  "consecutive_failures": 0,
  "last_checked_at": null,
  "last_available_energy": null,
  "last_read_error_at": null,
  "last_refill_at": null,
  "refill_count": 0,
  "total_spent_trx": "0.000000",
  "created_at": "2026-10-14T08:12:05Z",
  "estimated_cost_per_refill_trx": "2.618000",
  "volume_below_threshold": false,
  "current_energy": 0,
  "will_refill_now": true
}
```

### त्रुटियाँ

| स्थिति | कोड | कब |
| - | - | - |
| `400` | `INVALID_ADDRESS` | `target_address` मान्य TRON एड्रेस नहीं है |
| `400` | `CONTRACT_ADDRESS_NOT_SUPPORTED` | `target_address` एक स्मार्ट कॉन्ट्रैक्ट है |
| `403` | `FORBIDDEN` | API कुंजी के पास `buy_energy` स्कोप नहीं है |
| `409` | `AUTOREFILL_ADDRESS_TAKEN` | आपके खाते में इस एड्रेस के लिए पहले से एक एनर्जी नियम है — उसी को बदलें |
| `409` | `AUTOREFILL_LIMIT_REACHED` | आपके खाते में पहले से 20 एनर्जी नियम हैं; सीमा `error.limit` में भी दी जाती है |
| `422` | — | कोई फ़ील्ड गायब है या सीमा से बाहर है, या `duration` `"1h"` नहीं है |
| `429` | `RATE_LIMIT_EXCEEDED` | एक मिनट में नियम बनाने के 10 से अधिक अनुरोध |
| `503` | `AUTOREFILL_DISABLED` | एनर्जी के लिए ऑटो रिफिल अस्थायी रूप से बंद है; कोई नियम नहीं बना — कुछ देर बाद पुनः प्रयास करें |

```json theme={null}
{
  "detail": {
    "error": {
      "code": "AUTOREFILL_LIMIT_REACHED",
      "message": "You already hold the maximum of auto-refill rules: 20 for energy and 20 for bandwidth, counted separately. Delete one to add another.",
      "limit": 20
    }
  }
}
```

```json theme={null}
{
  "detail": {
    "error": {
      "code": "AUTOREFILL_ADDRESS_TAKEN",
      "message": "Auto-refill for this address already exists"
    }
  }
}
```

```json theme={null}
{
  "detail": {
    "error": {
      "code": "AUTOREFILL_DISABLED",
      "message": "Auto-refill is temporarily unavailable; please try again later"
    }
  }
}
```

सत्यापन त्रुटि फ्रेमवर्क के प्रारूप में आती है, जिसमें `detail` एक ऐरे होता है:

```json theme={null}
{
  "detail": [
    {
      "type": "literal_error",
      "loc": ["body", "duration"],
      "msg": "Input should be '1h'",
      "input": "1d",
      "ctx": {"expected": "'1h'"}
    }
  ]
}
```

> [!TIP]
>
> टाइमआउट के बाद नियम बनाने का अनुरोध दोबारा भेजना सुरक्षित है। यदि पहला अनुरोध सफल हो गया था, तो दोबारा भेजा गया अनुरोध दूसरा नियम बनाने के बजाय `409 AUTOREFILL_ADDRESS_TAKEN` लौटाता है; उसका `id` पाने के लिए [अपने नियमों की सूची देखें](/hi/api-reference/auto-refill/list-energy-rules)।


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.