Chuyển đến nội dung chính
POST
/
api
/
v1
/
x402
/
sessions
Create x402 Session
curl --request POST \
  --url https://api.agentwallex.com/api/v1/x402/sessions \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "agent_id": "agent_abc123",
  "budget_limit": "100.00",
  "chain": "eip155:84532",
  "ttl_seconds": 3600,
  "allowed_urls": [
    "https://paid-api.example.com/v1/data"
  ]
}
'
{
  "id": "sess_xyz789",
  "agent_id": "agent_abc123",
  "budget_limit": "100.00",
  "budget_spent": "0.00",
  "budget_remaining": "100.00",
  "chain": "eip155:84532",
  "status": "active",
  "expires_at": "2025-06-15T15:30:00Z",
  "created_at": "2025-06-15T14:30:00Z"
}
Phiên cho phép bạn ủy quyền trước ngân sách chi tiêu cho các lệnh gọi API x402 lặp lại. Các khoản thanh toán trong phiên được trừ từ ngân sách phiên mà không cần phê duyệt riêng cho từng lệnh gọi.

Nội dung yêu cầu

agent_id
string
bắt buộc
Agent cung cấp vốn cho phiên.
budget_limit
string
bắt buộc
Tổng số tiền tối đa phiên có thể chi tiêu (ví dụ: "100.00").
chain
string
bắt buộc
Mã định danh chuỗi CAIP-2 để thanh toán (ví dụ: eip155:84532).
ttl_seconds
integer
bắt buộc
Thời gian tồn tại của phiên tính bằng giây. Phiên sẽ hết hạn sau khoảng thời gian này.
allowed_urls
string[]
Danh sách URL mà phiên này được phép thanh toán (tùy chọn). Nếu bỏ qua, tất cả URL hỗ trợ x402 đều được phép.

Ví dụ

curl -X POST https://api.agentwallex.com/api/v1/x402/sessions \
  -H "X-API-Key: awx_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent_abc123",
    "budget_limit": "100.00",
    "chain": "eip155:84532",
    "ttl_seconds": 3600,
    "allowed_urls": ["https://paid-api.example.com/v1/data"]
  }'
Response
{
  "id": "sess_xyz789",
  "agent_id": "agent_abc123",
  "budget_limit": "100.00",
  "budget_spent": "0.00",
  "budget_remaining": "100.00",
  "chain": "eip155:84532",
  "status": "active",
  "expires_at": "2025-06-15T15:30:00Z",
  "created_at": "2025-06-15T14:30:00Z"
}

Ủ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 funds the session.

budget_limit
string
bắt buộc

Maximum total amount the session can spend (e.g., "100.00").

chain
string
bắt buộc

CAIP-2 chain identifier for settlement (e.g., eip155:84532).

ttl_seconds
integer
bắt buộc

Session time-to-live in seconds. The session expires after this duration.

allowed_urls
string<uri>[]

Optional list of URLs this session is authorized to pay. If omitted, all x402-enabled URLs are allowed.

Phản hồi

Session created successfully.

An x402 payment session with a pre-authorized spending budget.

id
string

Unique session identifier (e.g., sess_xyz789).

agent_id
string

Agent whose wallet funds the session.

budget_limit
string

Maximum total amount the session can spend.

budget_spent
string

Total amount spent so far.

budget_remaining
string

Remaining budget available.

chain
string

CAIP-2 chain identifier for settlement.

status
enum<string>

Session status.

Tùy chọn có sẵn:
active,
expired,
deleted
allowed_urls
string<uri>[]

URLs this session is authorized to pay.

expires_at
string<date-time>

ISO 8601 expiration timestamp.

created_at
string<date-time>

ISO 8601 creation timestamp.