跳轉到主要內容
POST
/
api
/
v1
/
x402
/
pay
x402 Pay
curl --request POST \
  --url https://api.agentwallex.com/api/v1/x402/pay \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "agent_id": "agent_abc123",
  "target_url": "https://paid-api.example.com/v1/data",
  "session_id": "sess_xyz789",
  "chain": "eip155:84532"
}
'
{
  "ledger_id": "ldg_abc123",
  "amount": "0.10",
  "fee_amount": "0.002",
  "fee_rate": "2.0",
  "token": "USDC",
  "chain": "eip155:84532",
  "status": "completed",
  "payment_signature": "base64_encoded_signature..."
}
為目標 URL 協商並完成一筆 x402 付款。AgentWallex 會評估代理的策略,透過 MPC 簽署付款,並回傳存取付費資源所需的付款資訊。

請求主體

agent_id
string
必填
將資助付款的代理。
target_url
string
必填
要支付的 x402 啟用 URL(例如 https://paid-api.example.com/v1/data)。
session_id
string
可選的工作階段 ID,從現有工作階段預算中扣除。請參閱 x402 Sessions
chain
string
用於付款結算的 CAIP-2 鏈識別碼(例如 eip155:84532)。若省略,則使用代理的預設區塊鏈。

回應

範例

curl -X POST https://api.agentwallex.com/api/v1/x402/pay \
  -H "X-API-Key: awx_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent_abc123",
    "target_url": "https://paid-api.example.com/v1/data",
    "session_id": "sess_xyz789",
    "chain": "eip155:84532"
  }'
Response
{
  "ledger_id": "ldg_abc123",
  "amount": "0.10",
  "fee_amount": "0.002",
  "fee_rate": "2.0",
  "token": "USDC",
  "chain": "eip155:84532",
  "status": "completed",
  "payment_signature": "base64_encoded_signature..."
}

相關端點

端點說明
POST /x402/check檢查 URL 是否支援 x402 付款協商
POST /x402/facilitator/verify驗證付款簽名(供服務供應商使用)
POST /x402/facilitator/settle結算已驗證的付款(供服務供應商使用)
GET /x402/facilitator/supported列出 x402 支援的區塊鏈
GET /x402/fees/tiers取得當前費率層級表

授權

X-API-Key
string
header
必填

API key authentication. Keys are prefixed with awx_.

主體

application/json
agent_id
string
必填

The agent whose wallet will fund the payment.

target_url
string<uri>
必填

The x402-enabled URL to pay for (e.g., https://paid-api.example.com/v1/data).

session_id
string

Optional session ID to deduct from an existing session budget.

chain
string

CAIP-2 chain identifier for payment settlement (e.g., eip155:84532). If omitted, the agent's default chain is used.

回應

Payment completed successfully.

Result of an x402 payment negotiation.

ledger_id
string

Internal ledger entry ID for this payment.

amount
string

Payment amount.

fee_amount
string

Platform fee deducted.

fee_rate
string

Fee percentage applied (based on tiered pricing).

token
string

Token used for payment (e.g., USDC).

chain
string

Chain used for settlement.

status
enum<string>

Payment status.

可用選項:
completed,
pending,
failed
payment_signature
string

The PAYMENT-SIGNATURE value to include in the retry request to the target URL.