---
title: "Buy energy"
method: POST
path: "/api/v2/agent/buy-energy"
tags: ["Orders"]
---

# Buy energy

`POST /api/v2/agent/buy-energy`

## Request

- Base URL: `https://powersun.vip`
- URL: `https://powersun.vip/api/v2/agent/buy-energy`
- Auth: one of:
  - API key in header `X-API-Key`
  - none

Purchase TRON Energy for a target address.

Three modes:
1. **X-API-Key header**: deducts from TRX balance → 200 + order
2. **PAYMENT-SIGNATURE header**: x402 v2 USDC on Base → 200 final result or 202 pending confirmation. Poll the same intent; do not pay again. Late confirmed payments credit the account with order: null.
3. **No auth headers**: returns 402 with TRX instructions and, when available, a two-minute x402 quote. Copy resource and accepts[0] into the signed payload unchanged.

## Headers

- `PAYMENT-SIGNATURE` string
- `X-PAYMENT-INTENT-ID` string

## Request body

- object
  - `targetAddress` string, required: TRON address to delegate energy to
  - `txCount` integer, required
  - `txType` 'trc20_transfer' | 'trc20_transfer_new' | 'trc10_transfer' | 'contract_call'
  - `durationMinutes` integer
  - `maxPriceTrx` number: Maximum acceptable total price in TRX
  - `resourceType` 'ENERGY' | 'BANDWIDTH'
  - `x402IntentId` string: Optional compatibility hint; must match accepted.extra.intentId in PAYMENT-SIGNATURE

## Response `200`

Order created, or final x402 result. A late confirmed x402 payment credits the account and returns order: null with paymentStage: credited.

- object
  - `pending` false
  - `intentId` string
  - `paymentStage` 'completed' | 'credited'
  - `order` Order
    - `orderId` string, uuid
    - `status` 'pending' | 'active' | 'processing' | 'completed' | 'failed' | 'cancelled' | 'expired'
    - `resourceType` 'ENERGY' | 'BANDWIDTH'
    - `energyDelegated` integer
    - `targetAddress` string
    - `durationMinutes` integer
    - `totalCostTrx` number
    - `createdAt` string, date-time
  - `settlement` object
    - `network` string
    - `usdcPaid` number
    - `baseTxHash` string

## Other responses

- `202`: Payment outcome is pending. Poll checkStatusUrl using the same intent ID; do not sign a new payment or pay again.
- `402`: Payment required — dual-scheme options (TRX on TRON + USDC on Base)

---

[API](https://skmtc.dev/powersun/apis/powersun-agent-api.md) · [All operations](https://skmtc.dev/powersun/apis/powersun-agent-api/llms.txt) · [OpenAPI document](https://skmtc.dev/powersun/apis/powersun-agent-api/revisions/169cc1ebfd26?raw)
