Core API
Buy Energy
Purchase energy for a TRON address
POST
Buy Energy
Buy Energy
Delegates energy to the specified TRON address. The cost is deducted from your account balance.Request body
string
required
Target TRON address (T… format, 34 characters)
number
required
Amount of energy to delegate (min 1, max 5,000,000)
string
required
Rental duration:
"1h" (1 hour only)string
Optional. The most you agree to pay for this order, in TRX — rental and fixed fee together. If the
order would cost more, it is refused with
409 PRICE_CHANGED and nothing is charged. Pass the
total_trx from Quote Price. A decimal string such as
"2.15" (a JSON number is accepted too), greater than 0. Without it the order is bought at the
current price, as before.Headers
string
Optional, up to 64 characters. A retry with the same key and the same body returns the original
order instead of buying again. After a successful order, the same key with a different body —
a different
max_price_trx included — returns 422 IDEMPOTENCY_KEY_REUSED. After a refusal that
charged nothing, such as 409 PRICE_CHANGED or 402 INSUFFICIENT_BALANCE, the key is free again:
retry with it and the new price.While the first request with the key is still running, a retry gets
409 IDEMPOTENT_REQUEST_IN_PROGRESS: wait a few seconds and retry with the same key. If the key
cannot be checked, the request is refused with 503 IDEMPOTENCY_UNAVAILABLE before anything is
bought: retry with the same key. A key is kept for 24 hours; after that it starts a new purchase.
See Timeouts and retries.Response
number
Unique order identifier
string
Order status. Orders up to 1,000,000 energy normally come back final:
filled or failed.
Larger orders are delivered in parts and may come back as processing, then end as filled,
partial or failed. Orders under 32,000 may come back as submitted_unknown (see the note
below). All statuses: Get Order.string | null
On-chain transaction id once the delegation is broadcast. Empty when
provider_outcome is
unknown_delivered.string
Total cost charged from your balance, in TRX
string | null
ISO 8601 timestamp when the bandwidth rental is reclaimed (energy is reclaimed automatically by the provider)
string
Address activation cost in TRX (
"0" if the recipient is already activated)string | null
null for an ordinary result. Otherwise it explains a result that was not a plain success:rejected— delivery definitely did not happen. The order isfailed, the full price is back on your balance, and theIdempotency-Keyis free again.unknown— the delivery confirmation was lost. The order isfailed(partialfor a large order) and the unconfirmed part is refunded, but that energy may still reach the address within minutes. If it does, you are not charged for it. A retry with the sameIdempotency-Keyreturns this same result; a new key buys again, and the address may then receive energy twice.unknown_delivered— the confirmation was lost, but the delegation was found on-chain. The order isfilledand charged;txidis empty.
Show the price, then buy at that price
- Call
GET /v1/energy/quotewith yourX-API-Keyand showtotal_trxto your user. - Call
POST /v1/energy/buywithmax_price_trxset to thattotal_trx.
total_trx. The energy price follows the market and can move between the
quote and the purchase: then the purchase is refused with 409 PRICE_CHANGED before anything is
charged — get a new quote, show it, and retry, with the same Idempotency-Key if you use one.
Timeouts and retries
Once your request reaches us, it is processed to the end even if your connection drops: an order can be created and charged although you never saw the response. To retry safely:- Create one
Idempotency-Keyper purchase on your side (your own order ID works) and save it before the call. - On a timeout, a connection error or a
5xxresponse, send the same request again with the same key, with a short pause. You get the original order; if the first request never reached us, this one makes the purchase. - On
409 IDEMPOTENT_REQUEST_IN_PROGRESS, wait a few seconds and retry with the same key.
409 IDEMPOTENT_REQUEST_IN_PROGRESS for more than a minute, the first request ended in an
unexpected state on our side — find it in List Orders or
contact support before buying again. Without a key, a retry is always a new purchase.
These answers are final — nothing was charged, and the request will never be processed later: any
4xx error except 409 IDEMPOTENT_REQUEST_IN_PROGRESS and 422 IDEMPOTENCY_KEY_REUSED, and a 503
with code POOL_EXHAUSTED or IDEMPOTENCY_UNAVAILABLE. 422 IDEMPOTENCY_KEY_REUSED means this
request bought nothing, but an earlier request with the same key may have. Read the code as
described in Errors.
Example
Response
Orders under 32,000 energy are delivered from our own pool. If it cannot serve this address right now, the request fails with
503 POOL_EXHAUSTED and nothing is charged — retry later or order 32,000 or more. While a previous order under 32,000 for the same address is still active, a new one is refused the same way.Such an order may come back as submitted_unknown: the delegation is broadcast but not yet confirmed in a block. It settles to filled, or to failed with a full refund, within minutes — poll Get Order.