Skip to main content
POST
Buy Bandwidth

Buy Bandwidth

Delegates bandwidth 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 bandwidth to delegate (min 1, max 100,000)
string
required
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)
Write minutes as a number without a leading zero, followed by a lowercase 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.
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 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

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. Retries work as described in Buy Energy → Timeouts and retries.

Response

number
Unique order identifier
string
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.
string | null
On-chain transaction id once the delegation is broadcast
string
Total cost of the order charged from your balance, in TRX — rental and fixed fee
string | null
ISO 8601 timestamp when the bandwidth rental is reclaimed
string
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:
The discount applies to the rental only — the fixed fee is the same for every duration. The rental of a minute term is rounded to the nearest SUN (0.000001 TRX), halves up. The current 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

  1. Call GET /v1/bandwidth/quote with your X-API-Key and show total_trx to your user.
  2. Call POST /v1/bandwidth/buy with max_price_trx set to that total_trx.
The quote is calculated by the same code that charges the order, so while the price is unchanged the order costs exactly 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.
max_price_trx covers the bandwidth 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.

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
If the order costs more than 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.
350 bandwidth covers one USDT TRC-20 transfer when free daily bandwidth is exhausted.