跳转到主要内容
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 会话
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.