Skip to main content

Agent Wallet

The Anima Agent Wallet gives each agent a dedicated balance with configurable spending guards and native support for the x402 payment protocol. Agents can transact autonomously within the boundaries you define, and any payment above your approval threshold is routed for human review before it clears.

Create a wallet

Provide an agentId, a currency, and an initial set of budget guards.
import { Anima } from "@anima-labs/sdk";

const anima = new Anima({ apiKey: "ak_..." });

const wallet = await anima.wallet.create({
  agentId: "ag_8f3k2m9x1n4p7q6r",
  currency: "usd",
  budgetGuards: {
    dailyLimitCents: 50000,          // $500.00
    monthlyLimitCents: 500000,       // $5,000.00
    perTransactionLimitCents: 10000, // $100.00
    requireApprovalAboveCents: 5000, // $50.00
  },
});

console.log(`Wallet: ${wallet.id}, Balance: ${wallet.balanceCents}`);

Budget guards

Budget guards enforce spending policy at the wallet level. When a payment would exceed a guard threshold, it is either declined automatically or held for human approval.
GuardTypeDescription
dailyLimitCentsnumberMaximum total spend per calendar day
monthlyLimitCentsnumberMaximum total spend per calendar month
perTransactionLimitCentsnumberMaximum amount for a single transaction
requireApprovalAboveCentsnumberTransactions above this amount require human approval before clearing
allowedMerchantCategoriesstring[]Restrict payments to specific MCC codes; all others are blocked
blockedMerchantCategoriesstring[]Block payments to specific MCC codes regardless of other limits

Update budget guards

Update one or more guards on an existing wallet at any time.
await anima.wallet.updateBudgetGuards("wlt_abc123", {
  dailyLimitCents: 100000,
  requireApprovalAboveCents: 20000,
});

x402 payments

Anima wallets natively support the x402 payment protocol, which lets agents pay for HTTP resources by including payment headers in the request. Use payAndFetch to make a request to a paid API endpoint — Anima handles the payment negotiation automatically.
const response = await anima.wallet.payAndFetch({
  walletId: "wlt_abc123",
  url: "https://data-provider.example/api/report",
  maxPaymentCents: 500,
});

console.log(`Paid: ${response.paymentCents} cents`);
console.log(`Data: ${response.body}`);
maxPaymentCents sets a ceiling on what your agent will pay for the resource. If the provider requests more, the transaction is declined and payAndFetch raises an error.

Check balance and transactions

// Check current balance
const balance = await anima.wallet.getBalance("wlt_abc123");
console.log(`Available: $${(balance.availableCents / 100).toFixed(2)}`);
console.log(`Spent today: $${(balance.spentTodayCents / 100).toFixed(2)}`);

// List recent transactions
const txns = await anima.wallet.listTransactions("wlt_abc123", {
  limit: 20,
  startDate: "2026-03-01",
});

Next steps