Skip to main content
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 is failed, the full price is back on your balance, and the Idempotency-Key is free again.
  • unknown — the delivery confirmation was lost. The order is failed (partial for 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 same Idempotency-Key returns 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 is filled and charged; txid is empty.

Show the price, then buy at that price

  1. Call GET /v1/energy/quote with your X-API-Key and show total_trx to your user.
  2. Call POST /v1/energy/buy with max_price_trx set to that total_trx.
The quote is rounded to the SUN exactly as the order is charged, so while the price is unchanged the order costs exactly 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.
max_price_trx covers the energy order only. If target_address is not activated on-chain yet, the activation is charged on top (activation_cost_trx) and is not checked against max_price_trx.

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:
  1. Create one Idempotency-Key per purchase on your side (your own order ID works) and save it before the call.
  2. On a timeout, a connection error or a 5xx response, 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.
  3. On 409 IDEMPOTENT_REQUEST_IN_PROGRESS, wait a few seconds and retry with the same key.
Never switch to a new key while the outcome is unclear: a new key is a new purchase. If retries keep getting 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
65,000 energy covers one USDT transfer to an address that already holds USDT. Use 131,000 for first-time USDT recipients (new storage slot creation).
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.