Chuyển đến nội dung chính
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..."
}
Thương lượng và hoàn thành một thanh toán x402 cho URL mục tiêu. AgentWallex đánh giá chính sách của tác nhân, ký thanh toán qua MPC và trả về thông tin thanh toán cần thiết để truy cập tài nguyên trả phí.

Nội dung Yêu cầu

agent_id
string
bắt buộc
Tác nhân có ví sẽ cung cấp thanh toán.
target_url
string
bắt buộc
URL hỗ trợ x402 để thanh toán (ví dụ: https://paid-api.example.com/v1/data).
session_id
string
ID phiên tùy chọn để trừ từ ngân sách phiên hiện có. Xem Phiên x402.
chain
string
Định danh chuỗi CAIP-2 cho thanh toán (ví dụ: eip155:84532). Nếu bỏ qua, chuỗi mặc định của tác nhân được sử dụng.

Phản hồi

Ví dụ

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..."
}

Endpoint Liên quan

EndpointMô tả
POST /x402/checkKiểm tra xem URL có hỗ trợ thương lượng thanh toán x402 không
POST /x402/facilitator/verifyXác minh chữ ký thanh toán (cho nhà cung cấp dịch vụ)
POST /x402/facilitator/settleThanh toán khoản đã xác minh (cho nhà cung cấp dịch vụ)
GET /x402/facilitator/supportedLiệt kê chuỗi được hỗ trợ cho x402
GET /x402/fees/tiersLấy biểu phí theo cấp hiện tại

Ủy quyền

X-API-Key
string
header
bắt buộc

API key authentication. Keys are prefixed with awx_.

Nội dung

application/json
agent_id
string
bắt buộc

The agent whose wallet will fund the payment.

target_url
string<uri>
bắt buộc

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.

Phản hồi

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.

Tùy chọn có sẵn:
completed,
pending,
failed
payment_signature
string

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