nrg.market API reference Interactive reference

Maintenance

Keeping wallets topped up with energy — auto-refill rules

GET /auto-refill-rules

List auto-refill rules

Authentication: Required — an API key in Authorization: Bearer … (authentication).

Parameters

NameInRequiredTypeDescription
cursorqueryoptionalstring
limitqueryoptionalinteger

Default: 50. Minimum: 1. Maximum: 200.

Responses

200

OK

Content type application/json.

FieldTypeRequiredDescription
dataarray of MaintenanceRulerequired
next_cursorstring or nullrequired

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

POST /auto-refill-rules

Create an auto-refill rule

Authentication: Required — an API key in Authorization: Bearer … (authentication).

"Keep energy on this wallet": after every spend it is topped up, so no separate order per transfer is needed. Idling costs almost nothing — no spend, no top-ups.

The daily budget is mandatory: it is the rule's spending cap per UTC day; a hold for it is placed from the available balance, spending is drawn from the hold, and the remainder is released at the day boundary.

You are charged for every top-up confirmed on-chain, at the GET /tariff price in effect at the moment of confirmation.

The address must be activated and must not be a contract. Only one active rule may exist per (account, address) pair.

201 means the daily hold is in place, not merely that the rule was recorded: a rule without a hold is an unbacked promise to spend.

Request body

Required.

Content type application/json.

Schema: MaintenanceRuleCreate.

FieldTypeRequiredDescription
addressTronAddressrequired

The wallet on which energy is maintained

daily_budget_trxTRXrequired

The rule's spending cap per UTC day. Mandatory. Reserved from the available balance like an order hold; the remainder is released at the day boundary.

No less than the maintenance_price_trx.double rate from GET /tariff — the rule's first top-up is charged at that rate and would not fit into a smaller budget — and no more than 1,000,000 TRX.

Example: wallet
{
  "address": "TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9",
  "daily_budget_trx": "20.000000"
}

Responses

201

Rule created, daily hold placed

Content type application/json.

Schema: MaintenanceRule.

400

Malformed request

Content type application/json.

Schema: Error.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

402

Available balance does not cover the daily budget

Content type application/json.

Schema: Error.

409

An active rule for this address already exists

Content type application/json.

Schema: Error.

422

The address is well-formed, but a rule cannot be created on it, the budget does not cover top-ups, or as many rules already exist as are allowed. The specific reason is in details.reason: inactive_wallet (the wallet is not activated — there is nowhere to delegate energy to), contract_wallet (a contract: its energy consumption works differently), rules_limit_reached (with limit and the current current there), budget_below_topup_price (the daily budget is below the double rate — even the rule's first top-up would not fit into it; the minimum is in details.min_daily_budget_trx).

Content type application/json.

Schema: Error.

429

Rate limit exceeded (rate_limited), or too many failed authorizations from this credential (too_many_auth_failures). Both are 429 and both carry Retry-After; they differ in what you should do about it, which is why they differ in code and not only in message. rate_limited also carries the RateLimit-* state of the bucket it came from; too_many_auth_failures does not, because the counter behind it is not a bucket. See "Rate limits" and "Repeated authorization failures" above.

On POST /orders a rate_limited may also carry details.reason = bulk_volume_cap: not requests per minute but energy per window — a mode c order whose volumes would take your account past the bulk allowance. details carries cap_units (the allowance), spent_units (your volume already inside the window), requested_units (what this order asked for) and window_s (the width of the window, 3600). Retry-After is the first instant at which this body can be accepted: enough of your counted volume has to leave the window to make room for requested_units, which is not in general the moment the oldest position leaves — one departure frees only that position's units. An order whose own volume is larger than the whole allowance is not answered here at all: no waiting would help it, and it is 400 invalid_request with details.reason = bulk_order_over_cap. It is a pace limit like the others, so it is the same code: the order is not wrong, and the same body sent later is accepted. It carries no RateLimit-* headers: those describe a bucket of requests per minute, and this allowance is energy per hour — details above is its whole state.

Content type application/json.

Schema: Error.

HeaderTypeDescription
Retry-Afterinteger

Seconds to wait before retrying.

RateLimit-Limitinteger

Requests per minute in this bucket — per UTC day on POST /sandbox/deposit, the one allowance in this API that is not counted per minute. Absent in exactly three cases, and in none is a number invented for it: the limiter could not read the bucket state (the request is let through then), the answer is too_many_auth_failures, which is counted by the authorization-failure counter and not by a bucket — see "Repeated authorization failures" — or it is the volume allowance (details.reason = bulk_volume_cap), which is energy per hour rather than requests per minute.

RateLimit-Remaininginteger

Requests left in this bucket right now.

RateLimit-Resetinteger

Seconds until the bucket is full again.

GET /auto-refill-rules/{rule_id}

Get a rule

Authentication: Required — an API key in Authorization: Bearer … (authentication).

Parameters

NameInRequiredTypeDescription
rule_idpathrequiredstring

Responses

200

OK

Content type application/json.

Schema: MaintenanceRule.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

404

Not found

Content type application/json.

Schema: Error.

PATCH /auto-refill-rules/{rule_id}

Update a rule

Authentication: Required — an API key in Authorization: Bearer … (authentication).

status (active ↔ paused) and the daily budget can be changed. A rule stopped due to insufficient_balance is resumed only by this request — it never turns back on silently.

Both changes account for what is already spent today: the hold is re-placed for budget − spent, not the full budget — otherwise a pause and resume would reset the daily cap. A budget lowered below what is already spent closes the hold: the rule spends nothing until the end of the UTC day.

A pause returns the rest of the daily hold a few minutes later rather than at once. The rule stops at once, but when it has a live daily hold and its wallet is connected, the hold stays until the network has been read past the moment of the pause (typically 4–5 minutes, at most an hour). A top-up delivered before the pause, or in the seconds right after it for a spend made while the rule was running, is charged from that hold like any other — a charge in GET /ledger and a maintenance.topup event; nothing delivered later is charged to the paused rule. A pause never charges for connecting the wallet. Resumed before the hold comes back, the rule carries on with the same hold; deleted while it waits, the wait goes on under the deletion's rules, from the moment of the pause.

Budget bounds are the same as at creation: below the price of a single top-up — 422 with details.reason = budget_below_topup_price.

Parameters

NameInRequiredTypeDescription
rule_idpathrequiredstring

Request body

Required.

Content type application/json.

Schema: MaintenanceRulePatch.

FieldTypeRequiredDescription
statusMaintenanceRuleStatus or nulloptional
daily_budget_trxTRX or nulloptional

Responses

200

OK

Content type application/json.

Schema: MaintenanceRule.

400

Malformed request

Content type application/json.

Schema: Error.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

402

Resuming requires the daily hold, and the balance does not cover it

Content type application/json.

Schema: Error.

404

Not found

Content type application/json.

Schema: Error.

422

The daily budget is below the double rate (details.reason = budget_below_topup_price; the minimum is in details.min_daily_budget_trx).

Content type application/json.

Schema: Error.

DELETE /auto-refill-rules/{rule_id}

Delete a rule

Authentication: Required — an API key in Authorization: Bearer … (authentication).

The rule stops operating, and the remainder of the daily hold is released. The charge history is retained. Deleting again returns 404.

The remainder may come back a few minutes later rather than at once. The rule is deleted immediately — 404 from then on, gone from the list, its address free for a new rule. But when it still has a live daily hold and its wallet is connected, the hold stays until the network has been read past the moment of deletion (typically 4–5 minutes, at most an hour). A top-up delivered before the deletion, or in the seconds right after it for a spend made while the rule was running, is charged from that hold like any other — a charge in GET /ledger and a maintenance.topup event with the deleted rule's rule_id; nothing delivered later is charged to it. Then the rest is released. A rule whose hold for the day is used up, or a paused rule whose hold has already come back, has nothing to wait with and is settled at once, but for a supplier prepayment still in progress (below); a paused rule whose hold still waits keeps waiting, from the moment of the pause. If what the rule still owes for connecting the wallet (below) is more than that hold, the difference is reserved from the available balance at the DELETE — the hold is released and placed again, larger by it; when the available balance cannot cover it, the deletion is refused with 402 insufficient_balance and nothing changes.

A rule deleted before charges have covered what the supplier was paid for its wallet pays the difference. The first pass that finds the wallet short of a full top-up connects it with the supplier, paid for up front; a wallet that already holds a full top-up is connected after its first spend. The difference is the supplier cost paid under this rule less what this rule was charged, but no more than the supplier cost paid for the wallet less what all rules of the wallet were charged (costs and charges from 2026-11-06 on). A prepayment for the rule that is still in progress at the DELETE counts at its expected cost, in the 402 check too, and that much stays held after the DELETE until the supplier answers: its actual cost is then charged from it and the rest released, or all of it is released if the prepayment did not go through. The difference is charged before the rest of the hold is released: from the rule's daily hold first, then from the available balance. When the two together do not cover it, the deletion is refused with 402 insufficient_balance and the rule stays as it was; details.required_trx is the part due from the available balance. It shows in GET /ledger as a charge (from the available balance, with a hold of the same amount) and is not refundable. Pausing a rule charges nothing by itself.

Parameters

NameInRequiredTypeDescription
rule_idpathrequiredstring

Responses

204

Deleted

No body.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

402

The rule's supplier cost is not yet covered by its charges, and its daily hold plus the available balance do not cover the difference — a supplier prepayment still in progress counting at its expected cost. Nothing is charged and the rule stays as it was; details.required_trx is the part due from the available balance.

Content type application/json.

Schema: Error.

404

Not found

Content type application/json.

Schema: Error.

GET /maintenance-rules

List auto-refill rules (deprecated path)

Deprecated.

Authentication: Required — an API key in Authorization: Bearer … (authentication).

Deprecated path. The canonical one is /auto-refill-rules; this alias responds identically and works until 2026-12-01, marking successful responses with Deprecation and Sunset headers.

Parameters

NameInRequiredTypeDescription
cursorqueryoptionalstring
limitqueryoptionalinteger

Default: 50. Minimum: 1. Maximum: 200.

Responses

200

OK

Content type application/json.

FieldTypeRequiredDescription
dataarray of MaintenanceRulerequired
next_cursorstring or nullrequired

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

POST /maintenance-rules

Create an auto-refill rule (deprecated path)

Deprecated.

Authentication: Required — an API key in Authorization: Bearer … (authentication).

Deprecated path. The canonical one is /auto-refill-rules; this alias responds identically and works until 2026-12-01, marking successful responses with Deprecation and Sunset headers.

Request body

Required.

Content type application/json.

Schema: MaintenanceRuleCreate.

FieldTypeRequiredDescription
addressTronAddressrequired

The wallet on which energy is maintained

daily_budget_trxTRXrequired

The rule's spending cap per UTC day. Mandatory. Reserved from the available balance like an order hold; the remainder is released at the day boundary.

No less than the maintenance_price_trx.double rate from GET /tariff — the rule's first top-up is charged at that rate and would not fit into a smaller budget — and no more than 1,000,000 TRX.

Responses

201

Rule created, daily hold placed

Content type application/json.

Schema: MaintenanceRule.

400

Malformed request

Content type application/json.

Schema: Error.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

402

Available balance does not cover the daily budget

Content type application/json.

Schema: Error.

409

An active rule for this address already exists

Content type application/json.

Schema: Error.

422

The rule cannot be created; the specific reason is in details.reason

Content type application/json.

Schema: Error.

429

Rate limit exceeded (rate_limited), or too many failed authorizations from this credential (too_many_auth_failures). Both are 429 and both carry Retry-After; they differ in what you should do about it, which is why they differ in code and not only in message. rate_limited also carries the RateLimit-* state of the bucket it came from; too_many_auth_failures does not, because the counter behind it is not a bucket. See "Rate limits" and "Repeated authorization failures" above.

On POST /orders a rate_limited may also carry details.reason = bulk_volume_cap: not requests per minute but energy per window — a mode c order whose volumes would take your account past the bulk allowance. details carries cap_units (the allowance), spent_units (your volume already inside the window), requested_units (what this order asked for) and window_s (the width of the window, 3600). Retry-After is the first instant at which this body can be accepted: enough of your counted volume has to leave the window to make room for requested_units, which is not in general the moment the oldest position leaves — one departure frees only that position's units. An order whose own volume is larger than the whole allowance is not answered here at all: no waiting would help it, and it is 400 invalid_request with details.reason = bulk_order_over_cap. It is a pace limit like the others, so it is the same code: the order is not wrong, and the same body sent later is accepted. It carries no RateLimit-* headers: those describe a bucket of requests per minute, and this allowance is energy per hour — details above is its whole state.

Content type application/json.

Schema: Error.

HeaderTypeDescription
Retry-Afterinteger

Seconds to wait before retrying.

RateLimit-Limitinteger

Requests per minute in this bucket — per UTC day on POST /sandbox/deposit, the one allowance in this API that is not counted per minute. Absent in exactly three cases, and in none is a number invented for it: the limiter could not read the bucket state (the request is let through then), the answer is too_many_auth_failures, which is counted by the authorization-failure counter and not by a bucket — see "Repeated authorization failures" — or it is the volume allowance (details.reason = bulk_volume_cap), which is energy per hour rather than requests per minute.

RateLimit-Remaininginteger

Requests left in this bucket right now.

RateLimit-Resetinteger

Seconds until the bucket is full again.

GET /maintenance-rules/{rule_id}

Get a rule (deprecated path)

Deprecated.

Authentication: Required — an API key in Authorization: Bearer … (authentication).

Deprecated path. The canonical one is /auto-refill-rules/{rule_id}; this alias responds identically and works until 2026-12-01, marking successful responses with Deprecation and Sunset headers.

Parameters

NameInRequiredTypeDescription
rule_idpathrequiredstring

Responses

200

OK

Content type application/json.

Schema: MaintenanceRule.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

404

Not found

Content type application/json.

Schema: Error.

PATCH /maintenance-rules/{rule_id}

Update a rule (deprecated path)

Deprecated.

Authentication: Required — an API key in Authorization: Bearer … (authentication).

Deprecated path. The canonical one is /auto-refill-rules/{rule_id}; this alias responds identically and works until 2026-12-01, marking successful responses with Deprecation and Sunset headers.

Parameters

NameInRequiredTypeDescription
rule_idpathrequiredstring

Request body

Required.

Content type application/json.

Schema: MaintenanceRulePatch.

FieldTypeRequiredDescription
statusMaintenanceRuleStatus or nulloptional
daily_budget_trxTRX or nulloptional

Responses

200

OK

Content type application/json.

Schema: MaintenanceRule.

400

Malformed request

Content type application/json.

Schema: Error.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

402

Resuming requires the daily hold, and the balance does not cover it

Content type application/json.

Schema: Error.

404

Not found

Content type application/json.

Schema: Error.

422

The daily budget is below the double rate

Content type application/json.

Schema: Error.

DELETE /maintenance-rules/{rule_id}

Delete a rule (deprecated path)

Deprecated.

Authentication: Required — an API key in Authorization: Bearer … (authentication).

Deprecated path. The canonical one is /auto-refill-rules/{rule_id}; this alias responds identically and works until 2026-12-01, marking successful responses with Deprecation and Sunset headers.

Parameters

NameInRequiredTypeDescription
rule_idpathrequiredstring

Responses

204

Deleted

No body.

401

Invalid key or IP not allowed

Content type application/json.

Schema: Error.

402

The rule's supplier cost is not yet covered by its charges, and its daily hold plus the available balance do not cover the difference — a supplier prepayment still in progress counting at its expected cost. Nothing is charged and the rule stays as it was; details.required_trx is the part due from the available balance.

Content type application/json.

Schema: Error.

404

Not found

Content type application/json.

Schema: Error.