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

# 更新能量规则

> 修改、暂停或恢复能量自动补充规则

## 更新能量规则

修改规则的阈值、数量或标签，或者暂停、恢复规则。只需发送要修改的字段；其他字段保持不变。更改从下一次检查起生效。需要 `buy_energy` 权限。

规则的地址和时长无法修改。要把规则移到另一个地址，请删除它并创建一条新规则。

### 路径参数

**rule\_id** `number` *required*

规则 ID——创建或列出能量规则时返回的 `id`

### 请求体

**threshold\_energy** `number`

新的阈值。范围 1 至 50,000,000。

**add\_volume** `number`

每次补充的新能量数量。范围 32,000 至 5,000,000。

**label** `string`

新的标签，最多 100 个字符。空字符串会移除标签。

**status** `string`

`"paused"` 表示暂停规则，`"active"` 表示恢复规则。恢复时还会清除 `stopped_reason`，并将 `consecutive_failures` 重置为 0。因余额不足而停止的规则会在充值后自行恢复，因此您无需手动恢复；如果在余额仍然不足时恢复，它会在下一次检查时再次停止。`stopped_insufficient_balance` 不能直接设置。

### 响应

更新后的规则，字段与[列出能量规则](/zh/api-reference/auto-refill/list-energy-rules)中的相同。

### 示例

```bash cURL theme={null}
curl -X PATCH https://api.tronrental.com/v1/energy/auto-refill/12 \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"status": "paused"}'
```

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

resp = requests.patch(
    "https://api.tronrental.com/v1/energy/auto-refill/12",
    headers={"X-API-Key": "your_api_key"},
    json={"status": "paused"},
)
print(resp.json())
```

```javascript JavaScript theme={null}
const resp = await fetch("https://api.tronrental.com/v1/energy/auto-refill/12", {
  method: "PATCH",
  headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" },
  body: JSON.stringify({ status: "paused" }),
});
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": "paused",
  "stopped_reason": null,
  "consecutive_failures": 0,
  "last_checked_at": "2026-10-14T09:41:02Z",
  "last_available_energy": 212480,
  "last_read_error_at": null,
  "last_refill_at": "2026-10-14T08:57:40Z",
  "refill_count": 3,
  "total_spent_trx": "7.854000",
  "created_at": "2026-10-14T08:12:05Z",
  "estimated_cost_per_refill_trx": "2.618000",
  "volume_below_threshold": false
}
```

### 错误

| 状态 | 代码 | 触发条件 |
| - | - | - |
| `403` | `FORBIDDEN` | API 密钥缺少 `buy_energy` 权限 |
| `404` | `NOT_FOUND` | 您的账户中没有此 ID 的能量规则（或已被删除） |
| `409` | `AUTOREFILL_IN_PROGRESS` | 该规则的一次补充正在购买中——请一分钟后重试 |
| `422` | — | 数值超出范围，或 `status` 不是 `"active"` 或 `"paused"` |

```json theme={null}
{
  "detail": {
    "error": {
      "code": "AUTOREFILL_IN_PROGRESS",
      "message": "A refill is in progress for this rule; try again in a minute"
    }
  }
}
```


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