> For the complete documentation index, see [llms.txt](https://docs.catfee.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.catfee.io/en/api-reference/create-order.md).

# Buy Energy

Create resource order

{% openapi src="/files/6qXC6RrOuqtzIYmAmGSc" path="/v1/order" method="post" %}
[api.json](https://4164384423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa332YYkbT2p9snj9atS0%2Fuploads%2Fgit-blob-686dfe3c6ef251a9d69c042fbd858c32a092401d%2Fapi.json?alt=media)
{% endopenapi %}

See [API Error Codes and Handling](/en/getting-started/buy-energy-via-api-on-catfee/api-error-codes.md) for error meanings, common causes, and retry guidance.

#### Key API: Create Order (POST /v1/order)

When creating an order via CatFee.IO’s API, please pay special attention to the following return values:

**`id` (Payment Hash / Order ID):**

* A unique identifier for each order.
* You can retrieve the order details using the `GET /v1/order/{id}` endpoint.

**`status` (Order Status):**

* Reflects the execution progress of the order.
* Normal values are `PAYMENT_SUCCESS` and `DELEGATE_SUCCESS`; treat all other statuses as failure.
* If `status` is `DELEGATE_SUCCESS`, the energy delegation has been successfully submitted to the TRON blockchain.

> Submission is not on-chain confirmation. Check `confirm_status` before treating the delegation as delivered.

**`confirm_status` (On-Chain Confirmation Status):**

* Confirms whether energy has been successfully delivered to the target address.
* Normal values are `UNCONFIRMED` and `DELEGATION_CONFIRMED`; treat all other values as failure.
* If `confirm_status` is `DELEGATION_CONFIRMED`, the energy has been successfully sent and confirmed on-chain.

**`client_order_id` (Client-defined Order ID):**

* For idempotent requests. See: [API Idempotency Support](/en/getting-started/api-supports-idempotent-requests.md)

**`balance` (Current User Balance):**

* An integer in **SUN** (1 TRX = 1,000,000 SUN).
* Included in order creation (including idempotent responses), order details, and early reclaim responses. It represents the user's current balance, not the order amount or a historical balance snapshot.

For time-based rentals, `status` remains `DELEGATE_SUCCESS` during and after reclamation, and reclamation confirmation states are returned as `confirm_status=DELEGATION_CONFIRMED`. These values record successful delegation, not current energy availability. See [Order Details](/en/api-reference/order-detail.md) for the full status values and mapping rules.

***

#### ❓How to Ensure Energy Has Been Successfully Sent?

You can confirm energy delivery through **two methods**:

**1. Query the energy balance of the target address via TRON API:**

Use the official TRON API or wallet tools (e.g., TronLink) to check the energy balance of the target address.

**Sample API Request (TRON Official Endpoint):**

```bash
curl --request POST \
     --url https://api.trongrid.io/wallet/getaccountresource \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
  "visible": true
}'
```

Check fields such as `energy_limit` and `energy_used` in the response.

**2. Check the `confirm_status` of the order:**

Use `GET /v1/order/{id}` to retrieve order details.

If `confirm_status` is `DELEGATION_CONFIRMED`, the energy has been successfully confirmed on-chain.

***

#### Example Workflow

**1. Create Order**

**Request:**

```http
POST /v1/order?count=1&target_address=TRON_ADDRESS&period=1
Host: https://api.catfee.io
Headers:
  Content-Type: application/json
  CF-ACCESS-KEY: {api_key}
  CF-ACCESS-SIGN: {signature}
  CF-ACCESS-TIMESTAMP: {timestamp}
```

**Response:**

```json
{
  "code":0,
  "data":{
    "id": "abcd1234",
    "status": "PAYMENT_SUCCESS",
    "confirm_status": "UNCONFIRMED",
    "balance": 100000000
  }
}
```

**2. Query Order Status**

**Request:**

```http
GET /v1/order/abcd1234
Host: https://api.catfee.io
Headers:
  Content-Type: application/json
  CF-ACCESS-KEY: {api_key}
  CF-ACCESS-SIGN: {signature}
  CF-ACCESS-TIMESTAMP: {timestamp}
```

**Response:**

```json
{
  "code":0,
  "data":{
    "id": "abcd1234",
    "status": "DELEGATE_SUCCESS",
    "confirm_status": "DELEGATION_CONFIRMED",
    "balance": 100000000
  }
}
```

**3. Confirm Successful Energy Transfer**

If `confirm_status` is `DELEGATION_CONFIRMED`, energy has been successfully sent.

You may also use the TRON API to verify the target address’s energy balance.

***

#### FAQs

**Q: Order status is `DELEGATE_SUCCESS` but energy hasn’t arrived?**

* **Reason:** `DELEGATE_SUCCESS` means the transaction was submitted, not necessarily confirmed. Time-based rental orders also retain this value after expiry or reclamation.
* **Solution:** Check `confirm_status`. If delegation is confirmed but no energy is available, also check the expiry time, reclamation details, and on-chain resource balance.

**Q: Energy arrival is delayed?**

* **Reason:** Potential TRON network congestion.
* **Solution:** Ensure `confirm_status` is `DELEGATION_CONFIRMED`. This confirms energy delivery.

***

By tracking the `id` and `confirm_status` values and using on-chain validation, you can ensure energy transfers are reliable.\
If you still have questions, please contact CatFee customer support: [@CatFee\_James](https://t.me/CatFee_James)
