Installation
Client Initialization
| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey | string | Required | Your API key (awx_...) |
environment | "sandbox" | "production" | "sandbox" | Target environment |
baseUrl | string | — | Custom base URL (overrides environment) |
timeout | number | 30000 | Request timeout in milliseconds |
Agents
aw.agents.create(params)
Create a new agent with an MPC-secured wallet.
| Field | Type | Description |
|---|---|---|
id | string | Unique agent identifier |
name | string | Agent display name |
wallet.address | string | On-chain wallet address |
wallet.chain | string | CAIP-2 chain identifier |
status | string | "active" or "frozen" |
createdAt | string | ISO 8601 timestamp |
aw.agents.get(agentId)
Retrieve an agent by ID.
aw.agents.list(params?)
List all agents for your account.
aw.agents.freeze(agentId)
Immediately freeze an agent’s wallet, preventing all transactions.
aw.agents.unfreeze(agentId)
Re-enable an agent’s wallet after a freeze (subject to 10-minute cool-down).
Payments
aw.payments.send(params)
Send a direct on-chain payment.
| Field | Type | Description |
|---|---|---|
id | string | Transaction ID |
hash | string | On-chain transaction hash |
status | string | "pending", "confirmed", "failed" |
amount | string | Amount sent |
token | string | Token symbol |
fee | string | Network gas fee paid |
aw.payments.get(transactionId)
Get transaction details and status.
aw.payments.list(params)
List transactions for an agent.
x402 Micropayments
aw.x402.createSession(params)
Create an x402 payment session with a spending budget.
aw.x402.check(params)
Check whether a target URL supports x402 payment negotiation.
aw.x402.pay(params)
Negotiate and complete one x402 payment.
aw.x402.sessionPay(sessionId, params)
Pay using an existing session budget.
aw.x402.httpInterceptor(params)
Create an HTTP fetch wrapper that automatically handles x402 v2 challenges:
- Reads the
PAYMENT-REQUIREDheader from a 402 response - Submits payment via AgentWallex
- Retries the request with the
PAYMENT-SIGNATUREheader
Policies
aw.policies.update(agentId, policies)
Update an agent’s spending policies.
aw.policies.get(agentId)
Get current policies for an agent.
aw.policies.applyTemplate(agentId, templateName)
Apply a policy template to an agent.
aw.policies.createTemplate(name, rules)
Create a reusable policy template.
Webhooks
aw.webhooks.create(params)
Register a webhook endpoint.
Error Handling
The SDK provides typed error classes:| Error Class | When Thrown |
|---|---|
AgentWallexError | Base class for all API errors |
PolicyViolationError | Transaction blocked by policy engine |
AuthenticationError | Invalid or missing API key |
NotFoundError | Resource does not exist |
RateLimitError | Rate limit exceeded |