Skip to main content

Agent Wallet

The Anima Agent Wallet provides budget management and payment capabilities for AI agents. It combines spending guardrails with the x402 payment protocol so agents can transact autonomously within defined boundaries.

Core Concepts

  • Budget Guards — Configurable limits that prevent agents from overspending
  • x402 Payments — HTTP-native payment protocol for agent-to-agent and agent-to-service payments
  • Balance Tracking — Real-time tracking of agent spending across all payment methods

Setting Up a Wallet

import { Anima } from "@anima-labs/sdk";

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

// Create a wallet for an agent
const wallet = await anima.wallet.create({
  agentId: "ag_8f3k2m9x1n4p7q6r",
  currency: "usd",
  budgetGuards: {
    dailyLimitCents: 500_00,
    monthlyLimitCents: 5000_00,
    perTransactionLimitCents: 100_00,
    requireApprovalAboveCents: 50_00,
  },
});

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

Budget Guards

Budget guards enforce spending policies at the wallet level. When a payment request exceeds a guard threshold, it is either declined or routed for human approval.
GuardDescription
dailyLimitCentsMaximum total spend per calendar day
monthlyLimitCentsMaximum total spend per calendar month
perTransactionLimitCentsMaximum single transaction amount
requireApprovalAboveCentsTransactions above this amount require human approval
allowedMerchantCategoriesRestrict payments to specific MCC codes
blockedMerchantCategoriesBlock payments to specific MCC codes

Updating Budget Guards

await anima.wallet.updateBudgetGuards("wlt_abc123", {
  dailyLimitCents: 1000_00,
  requireApprovalAboveCents: 200_00,
});

x402 Payments

Anima wallets natively support the x402 payment protocol, enabling agents to pay for HTTP resources by including payment headers.
// Make an x402 payment to access a paid API
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}`);

Checking Balance and History

// 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 transactions
const txns = await anima.wallet.listTransactions("wlt_abc123", {
  limit: 20,
  startDate: "2026-03-01",
});

API Reference

EndpointMethodDescription
https://api.useanima.sh/api/walletPOSTCreate a wallet
https://api.useanima.sh/api/wallet/:idGETGet wallet details and balance
https://api.useanima.sh/api/wallet/:id/budget-guardsPUTUpdate budget guards
https://api.useanima.sh/api/wallet/:id/payPOSTInitiate a payment
https://api.useanima.sh/api/wallet/:id/transactionsGETList transactions
https://api.useanima.sh/api/wallet/:id/x402POSTMake an x402 payment

Configuration

VariableDefaultDescription
ANIMA_WALLET_DEFAULT_CURRENCYusdDefault currency for new wallets
ANIMA_WALLET_X402_ENABLEDtrueEnable x402 payment protocol support
ANIMA_WALLET_APPROVAL_WEBHOOKWebhook URL for approval-required payments

Next Steps

  • A2A Protocol — Agent-to-agent payments and task delegation
  • Audit Log — Track all wallet transactions