Back to Agentic Commerce

x402 Protocol

HTTP 402 Payment Required-based micropayments for pay-per-use energy delegation. Agents pay only for what they consume with automatic USDT settlements.

How x402 Works

Step 1

Request Resource

Agent sends an HTTP request to a paid endpoint.

Step 2

Receive 402

Server responds with HTTP 402 and payment requirements.

Step 3

Create Payment

Agent constructs a USDT payment transaction on TRON.

Step 4

Submit with Proof

Agent retries the request with X-PAYMENT header containing the signed tx.

Step 5

Verify & Fulfill

Server verifies payment on-chain and returns the resource.

Capabilities

Endpoint Reference

GET/api/v1/x402/capabilities
POST/api/v1/x402/verify
POST/api/v1/x402/settle
GET/api/v1/x402/payments/:id

Integration Examples

cURL
# Step 1: Get capabilities
curl https://api.tronenergyhub.com/api/v1/x402/capabilities

# Step 2: Make a paid request (will return 402 with payment requirements)
curl -i https://api.tronenergyhub.com/api/v1/orders/create-paid \
  -H "Content-Type: application/json" \
  -d '{"energyAmount": 65000, "durationHours": 1}'

# Step 3: After signing payment, retry with proof
curl https://api.tronenergyhub.com/api/v1/orders/create-paid \
  -H "X-PAYMENT: <base64-encoded-payment-proof>" \
  -H "Content-Type: application/json" \
  -d '{"energyAmount": 65000, "durationHours": 1}'