delegate-bandwidth - TRON energy
Example code for the delegate-bandwidth TRON Energy API endpoint
This is used to purchase and delegate TRON Bandwidth to a target address. Unlike Energy, Bandwidth orders are confirmed asynchronously: the API returns 202 with status "accepted", and no charge is applied until on-chain delivery is confirmed. Poll orders/{order_id} with the returned orderId until the status becomes "charged".
Body Parameter
target_address
string
Yes
TRON wallet address (starts with T, 34 characters)
volume
integer
Yes
Bandwidth amount: 1,000 — 50,000
duration
string
Yes
"1h", "3d", "7d", "14d"
Idempotency
This endpoint charges your balance and places an on-chain order. To make retries safe, send a unique Idempotency-Key header with each intent:
Idempotency-Key: 6f9c2a1e-3b7d-4c08-9f21-2e5a7c0b1d44A UUID is recommended. Generate a new key for each purchase, and reuse the same key when retrying the exact same purchase.
Same key + same body
The original response is replayed with the same orderId. No second charge, no second order.
Same key + different body
422 — Idempotency-Key was previously used with a different request body. Generate a fresh key per distinct request.
Same key on a different endpoint
409 — Idempotency-Key was already used on a different endpoint (delegate-energy). Generate a fresh key per distinct intent.
Duplicate sent while the first is still in flight
409 with Retry-After: 2 — A request with this Idempotency-Key is already in progress. Retry shortly.
Request Sample
curl -X POST https://services.getblock.io/v1/tron-energy/delegate-bandwidth \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f9c2a1e-3b7d-4c08-9f21-2e5a7c0b1d44" \
-d '{
"target_address": "TUo8pycbvje9w2XYsNnnzw67bpPs4GLFyD",
"volume": 1000,
"duration": "1h"
}'import axios from 'axios';
const response = await axios.post(
'https://services.getblock.io/v1/tron-energy/delegate-bandwidth',
{
"target_address": "TUo8pycbvje9w2XYsNnnzw67bpPs4GLFyD",
"volume": 1000,
"duration": "1h"
},
{
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer YOUR_API_KEY',
'Idempotency-Key': '6f9c2a1e-3b7d-4c08-9f21-2e5a7c0b1d44',
},
}
);
console.log(response.data);Response Sample
price_usd and txid are empty until delivery is confirmed. A retry with the same Idempotency-Key replays the same 202 — it does not create a second order.
GET /orders/22133650-7b1f-4793-8609-3c5f5481805c a few seconds later:
Last updated
Was this helpful?