Account
Settings, statistics, webhooks
GET /settings
Account settings
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Responses
PATCH /settings
Update settings
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Only the fields you send change. A field left out keeps its
stored value, and an empty body {} is a legal no-op returning the
settings as they are. Nothing is reset by omission.
An omitted field and an explicit null are different requests.
Sending "baseline_price_sun": null clears the baseline price, and
with it the baseline_* fields of GET /stats/savings, which become
null — there is then nothing to compare against. Omitting the field
leaves whatever is stored. This is the only way to remove a baseline
price once set: there is no value that means "unset", and 0 is
rejected (the range is 1 to 100000 sun per unit of energy — a price
outside it is a unit error, not a provider).
balance_low_threshold_trx draws no such distinction, because it does
not need one: "0.000000" is how the balance.low event is switched
off, so null there says nothing beyond "not sent" and is treated as
an omission.
auto_topup follows the same rule one level down. The object is
optional, every field in it is optional, and a null anywhere in it
means "not sent" — there is nothing to clear these to that "0.000000"
does not already say. Switching the policy on requires
max_per_day_trx above zero, and the rule is checked on the
resulting settings: an account that already has a cap may send
enabled by itself, one that has not gets 400 invalid_request
naming the field. The same check refuses an enabled policy whose
target_trx is under balance_low_threshold_trx while both are set
(see AutoTopup.target_trx), and it runs on every PATCH — a body
that only raises the threshold over a standing target is refused too.
The change is written to audit_log together with the previous value.
Request body
Required.
Content type application/json.
| Field | Type | Required | Description |
|---|---|---|---|
baseline_price_sun | integer or null | optional | Your current price with another provider, in sun per unit of energy — not per transfer. Minimum: |
balance_low_threshold_trx | TRX or null | optional | Threshold for the |
auto_topup | AutoTopupPatch or null | optional |
Example: Set your current provider's price for comparison
{
"baseline_price_sun": 40,
"balance_low_threshold_trx": "500.000000"
}
Example: Remove the baseline price — an explicit null, not an omission
{
"baseline_price_sun": null
}
Example: Change the threshold; the baseline price is untouched
{
"balance_low_threshold_trx": "500.000000"
}
Example: Ask us to request top-ups, capped at 500 TRX a day
{
"balance_low_threshold_trx": "50.000000",
"auto_topup": {
"enabled": true,
"target_trx": "200.000000",
"min_trx": "20.000000",
"max_per_day_trx": "500.000000"
}
}
Example: Stop asking; the amounts are kept for when it is turned back on
{
"auto_topup": {
"enabled": false
}
}
Responses
GET /stats/savings
How much you saved
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Two comparisons over a period:
- against burning TRX — if you had not rented energy at all. The
base is
burn_cost_sun, fixed when each order was created; - against your current price — based on
baseline_price_sunfrom settings (or thebaseline_sunparameter). If no baseline price is set, the corresponding fields returnnull.
Counted are the orders you paid for: settled and having delivered
energy. A cancelled order and one still in flight have no charged sum
at all. A failed order does reach settlement — with a zero sum — but
no energy was delivered and nothing was charged, so its burn cost is
not a saving and the order is left out. The same selection stands
behind every field of the response, orders, energy_units and
burn_cost_trx included. Both sides of the comparison are taken per
whole order: burn_cost_sun is not split across items.
Savings are floored at zero per order, and equally so in both
comparisons: an order that came out dearer than burning contributes
zero to saved_vs_burn_trx rather than a negative, and one dearer
than your own price contributes zero to saved_vs_baseline_trx.
Neither eats into the savings of the orders next to it. The floor sits
on the order and not on the period's total — otherwise one figure
would stand for two different facts. The comparison bases are
unchanged by it: burn_cost_trx and baseline_cost_trx remain the
full sums over those same orders.
Percentages are shares of the comparison base, not of what you paid:
saved_vs_burn_pct is a share of burn_cost_trx, and
saved_vs_baseline_pct a share of baseline_cost_trx. Neither is the
mirror of what you paid — because of the per-order floor, "92%" does
not mean "you paid 8% of what burning would have cost". An order
dearer than burning adds to paid_trx without subtracting from
saved_vs_burn_trx, so the two can add up to more than
burn_cost_trx; the same holds for the baseline pair. It is the
savings that are reported honestly rather than the identity that is
kept tidy.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
period | query | optional | string | One of: |
baseline_sun | query | optional | integer | Override the baseline price for this request — sun per unit of energy, not per transfer. At least 1: zero would read as "your provider is free", and the way to say "there is nothing to compare with" is to leave the parameter out and the setting empty. At most 100000 (0.1 TRX per unit), which is some two hundred times the dearest way energy is obtained on TRON at all; a larger number is a price stated per transfer rather than per unit, and it is refused as Minimum: |
Responses
200
OK
Content type application/json.
| Field | Type | Required | Description |
|---|---|---|---|
period | string | required | Example: |
orders | integer | required | How many orders the figures cover — settled and having delivered energy. A failed order settles at zero and is not among them. Example: |
energy_units | integer | required | Energy over the items of those same orders. Example: |
paid_trx | TRX | required | |
burn_cost_trx | TRX | required | What burning would have cost over those same orders. |
saved_vs_burn_trx | TRX | required | Summed per order, each floored at zero. |
saved_vs_burn_pct | number | required | A share of Example: |
baseline_price_sun | integer or null | required | Example: |
baseline_cost_trx | TRX or null | required | All the counted energy at your baseline price — the base of the second comparison, which the per-order floor does not change. |
saved_vs_baseline_trx | TRX or null | required | Savings against your own price, summed per order and each floored at zero — the same floor as |
saved_vs_baseline_pct | number or null | required | A share of Example: |
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.
| Header | Type | Description |
|---|---|---|
Retry-After | integer | Seconds to wait before retrying. |
RateLimit-Limit | integer | Requests per minute in this bucket — per UTC day on
|
RateLimit-Remaining | integer | Requests left in this bucket right now. |
RateLimit-Reset | integer | Seconds until the bucket is full again. |
GET /webhooks
List webhook endpoints
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Your endpoints, oldest first.
The response shape changed on 2026-08-26. It used to be a bare
array; it is now the same {data, next_cursor} envelope as
/orders, /ledger and /auto-refill-rules. The old shape was not
kept behind an alias or a header: an array and an object part company
at parse time, so a generated client fails loudly on the first line
instead of quietly reading the wrong field.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
cursor | query | optional | string | |
limit | query | optional | integer | Default: |
Responses
200
OK
Content type application/json.
| Field | Type | Required | Description |
|---|---|---|---|
data | array of WebhookEndpoint | required | |
next_cursor | string or null | required |
POST /webhooks
Register a webhook
Authentication: Required — an API key in Authorization: Bearer … (authentication).
The signing secret is returned only once, on creation.
The url must be https, carry no credentials, resolve to a public
host, and hold no ASCII control character — \x00–\x1f (tab,
newline and carriage return among them) and \x7f — anywhere in the
string. A control character is refused with 400 invalid_request and
details = {position}, the offset of the first one: the character is
invisible, and the offset is the only way you will find it in your own
configuration. It usually arrives as a trailing \n read out of a file
or a command's output.
An account may hold at most 5 active endpoints. One more is
refused with 400 invalid_request, carrying
details = {active_webhooks, limit}. Deliveries are sent one after
another with a five-second budget per attempt, so the endpoints of one
account queue up in front of everybody else's events. Only active ones
count: an endpoint switched off by the failure rule, and a deleted
one, hold no slot. Free a slot with DELETE /v1/webhooks/{id}.
Request body
Required.
Content type application/json.
| Field | Type | Required | Description |
|---|---|---|---|
url | string (uri) | required | |
events | array of WebhookEvent | required |
Example: basic
{
"url": "https://example.com/hooks/nrg",
"events": [
"order.ready",
"order.completed",
"order.failed",
"deposit.credited"
]
}
Responses
201
Created
Content type application/json.
Every field of WebhookEndpoint, and the fields below.
| Field | Type | Required | Description |
|---|---|---|---|
secret | string | required | Shown only once |
PATCH /webhooks/{webhook_id}
Change a webhook
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Change the address, the subscription, or both. The signing secret does not change and is not returned here — that is what this request is for.
Without it an edit meant DELETE + POST: a new endpoint id and a
new secret, which you have to deploy on your side before the next
event arrives, because the old one is never shown twice. Adding one
event to a subscription cost a release.
Send either of url and events, or both; an omitted field is left
as it is. An empty body is 400 rather than a quiet "nothing
changed".
url is checked exactly as at registration: https only, no
credentials in the address, a public host only, and no ASCII control
character anywhere in the string. A check that stands only at
registration is a check the second request walks past.
A switched-off endpoint (status: disabled) is not edited: 400 with
details.reason = endpoint_disabled. You cannot switch it back on
yourself; we do, and we decide by reading disabled_at and
disabled_reason against the address the endpoint carries — an edit
would change the address without clearing the cause. Write to support
and name the new address in the same message. A deleted endpoint, like
somebody else's, is 404.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
webhook_id | path | required | string |
Request body
Required.
Content type application/json.
| Field | Type | Required | Description |
|---|---|---|---|
url | string (uri) or null | optional | |
events | array of WebhookEvent or null | optional |
Example: The receiver moved to another address
{
"url": "https://example.com/hooks/nrg-v2"
}
Example: One more event, same address, same secret
{
"events": [
"order.ready",
"order.completed",
"order.failed",
"deposit.credited"
]
}
Responses
DELETE /webhooks/{webhook_id}
Delete a webhook
Authentication: Required — an API key in Authorization: Bearer … (authentication).
The endpoint stops receiving events and disappears from the list.
The history of deliveries already sent to it is retained on our
side. Deleting again returns 404: a deleted endpoint is
indistinguishable from one that never existed.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
webhook_id | path | required | string |
Responses
204
Deleted
No body.
GET /webhooks/{webhook_id}/deliveries
Delivery log
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Every attempt made against this endpoint, newest first: the event,
its event_id, the status, the number of attempts, the status code
the receiver answered with and the error text.
This is the answer to "why did the event not arrive". An empty
response_status means there was no answer at all — a timeout, DNS,
a dropped connection; that is a separate fact, not a zero.
event_id is the same value that went out in the body and in the
X-NRG-Event-Id header, so a row here lines up with a row in your
own log without guessing by timestamp.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
webhook_id | path | required | string | |
cursor | query | optional | string | |
limit | query | optional | integer | Default: |
Responses
200
OK
Content type application/json.
| Field | Type | Required | Description |
|---|---|---|---|
data | array of WebhookDelivery | required | |
next_cursor | string or null | required |
POST /webhooks/{webhook_id}/deliveries/{delivery_id}/retry
Replay a delivery
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Puts the delivery back in the queue — and resets the attempt counter: the retry schedule is computed from it, so without the reset a replayed delivery would get one attempt instead of five.
event_id does not change. The copy arrives carrying the same
identifier as the original, so a receiver that already processed the
event recognises it and drops the duplicate.
The sending is done by the delivery worker, not by this request: the
next pass picks the row up. 204 means "queued", not "delivered" —
read the outcome from the delivery log.
A delivery the receiver already accepted is not replayed (400):
that is not "send it again", it is a duplicate broadcast on one
request.
A webhook.test row is not replayed either (400). A probe has no
retry ladder, so "the full five attempts" is not a thing that can be
restored for one, and a queued copy would answer nothing to whoever
pressed the button. Ask the receiver again with
POST /webhooks/{webhook_id}/test, which waits for the answer and
hands it back.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
webhook_id | path | required | string | |
delivery_id | path | required | string |
Responses
204
Queued
No body.
POST /webhooks/{webhook_id}/test
Send a test event
Authentication: Required — an API key in Authorization: Bearer … (authentication).
Sends the endpoint a webhook.test event and answers with what came
of it: whether the receiver accepted it, what status code it
answered with, what got in the way. No order is created and no money
moves.
It is the real delivery path, not a rehearsal of one: the same
secret, the same signature, the same headers, the same event_id
taken from the same table, the same 5-second budget for your answer,
and the row stays in the delivery log beside the rest. A probe that
waited less than a real delivery does would report a receiver as
failed while your live events were reaching it.
No subscription is needed: the probe goes to the endpoint named in
the path whatever its events are — a receiver that does not work
yet has nothing to subscribe to. For the same reason webhook.test
cannot be subscribed to: it is not in the event list, so a handler
that switches on the event name cannot mistake a probe for a real
event.
Exactly one attempt is made — a probe answers "does it accept right now", and there is no retry ladder for it. Its failures neither count towards the automatic disabling of the endpoint nor trigger the check, and the row it leaves cannot be replayed: ask again with this same call.
A disabled endpoint is refused (400) and nothing is sent. We
deliver nothing to such an endpoint, so there is no question about
your receiver to answer; GET /webhooks is where that state shows.
A probe that could not leave us at all is a 500 for the same
reason, and leaves no row: delivered: false means your receiver
was asked and did not accept, never that we failed to ask.
If the request is cut short — you disconnect, or we restart mid-trip
— the row is left failed with last_error: probe_result_unknown.
Your receiver may or may not have been called; nobody found out, and
nothing will retry it. Ask again with this same call.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
webhook_id | path | required | string |
Responses
200
The probe was attempted; the body says how it went
Content type application/json.
Schema: WebhookTestResult.
Example: accepted
{
"delivery_id": "1841",
"event_id": "0f0f6b1e-4a1e-4a5f-9b8a-2f5f0d9c1a77",
"event": "webhook.test",
"delivered": true,
"response_status": 200,
"error": null
}
Example: refused
{
"delivery_id": "1842",
"event_id": "6d2f1c0a-7e3b-4f4e-b1a4-9c0e2d3f5a10",
"event": "webhook.test",
"delivered": false,
"response_status": 502,
"error": "HTTP 502"
}
500
The probe never left us — a fault on our side, and nothing about your receiver. No row is written and nothing was sent.
Content type application/json.
Schema: Error.