Core API
Buy Bandwidth
Purchase bandwidth for a TRON address
POST
Buy Bandwidth
Buy Bandwidth
Delegates bandwidth to the specified TRON address. The cost is deducted from your account balance.Request body
Rental duration, one of:
"1h"— 1 hour"1d"— 24 hours"5m"…"59m"— any whole number of minutes from 5 to 59, at the hourly rate with a discount (see Pricing)
m: "5m", "30m". "05m", "5M",
"60m" or "90m" are rejected with 400 INVALID_DURATION: an hour is "1h", and there is
nothing between "1h" and "1d". Use "1d", not "24h" or numeric hour values.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 Bandwidth. A decimal string such as
"0.58" (a JSON number is accepted too), greater than 0. Without it the order is bought at the
current price, as before.Headers
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.
Retries work as described in
Buy Energy → Timeouts and retries.Response
Order status:
filled, failed, or 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.Charged for activating
target_address on-chain if it was not activated yet, on top of
price_trx. "0" for an address that is already active.Pricing
1h and 1d: price = volume × price_sun / 1,000,000 + fixed fee (0.2 TRX unless your account has
its own fee), where price_sun is
price_sun_1h or price_sun_1d from Get Bandwidth Prices, or
your negotiated rate if your account has one.
5m … 59m: the hourly rate (price_sun_1h, or your negotiated hourly rate) with a discount. The
discount is largest on 5 minutes and falls linearly to zero on 59 minutes:
short_max_discount_pct is in
Get Bandwidth Prices.
You do not need to calculate any of this: Quote Bandwidth returns
the exact amount for your volume, duration and account.
Show the price, then buy at that price
- Call
GET /v1/bandwidth/quotewith yourX-API-Keyand showtotal_trxto your user. - Call
POST /v1/bandwidth/buywithmax_price_trxset to thattotal_trx.
total_trx. If the price changed in between, 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.
Example
Response
Example: quote, then buy for 5 minutes
Values below are an example, with
price_sun_1h of 400 and short_max_discount_pct of 5.Response
max_price_trx — say you sent "0.57" and the order costs 0.58 TRX —
nothing is charged and the response is:
409 PRICE_CHANGED
Errors
A
max_price_trx of 0, a negative number or a non-number is a 422 validation error in the
framework’s own format. Other codes are listed in Errors.