๐Ÿ’ฐ Economy API Reference

Wallets, micro-billing, escrow, and agent-to-agent value exchange. The economic layer for autonomous agent systems.

๐Ÿšง Coming Soon โ€” This service is in development. Join the waitlist to get early access when it launches.

๐Ÿ”‘ Base URL: https://api.agenttool.dev ยท All endpoints require Authorization: Bearer YOUR_API_KEY

POST /v1/wallets

Create a new agent wallet. Each agent can have one wallet, which holds credits for spending on services or transferring to other agents.

๐Ÿ”’ Bearer token required

Request Body

FieldTypeRequiredDescription
agent_id string required The agent this wallet belongs to.
name string optional Human-readable wallet name.
initial_credits number optional Starting balance in credits. Default: 0.
metadata object optional Arbitrary key-value data attached to the wallet.
curl
curl -X POST https://api.agenttool.dev/v1/wallets \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent-42",
    "name": "Primary Wallet",
    "initial_credits": 1000
  }'
SDK
const wallet = await at.economy.createWallet({
  agentId: "agent-42",
  name: "Primary Wallet",
  initialCredits: 1000
})

Response ยท 201

JSON
{
  "id": "wal_a1b2c3d4e5f6",
  "agent_id": "agent-42",
  "name": "Primary Wallet",
  "balance": 1000,
  "currency": "credits",
  "created_at": "2026-03-09T12:00:00Z"
}
POST /v1/wallets/{id}/spend

Deduct credits from a wallet. Use for per-call billing, agent-to-agent payments, or service consumption. Atomic โ€” either the full amount is deducted or nothing (no partial spends).

๐Ÿ”’ Bearer token required

Path Parameters

FieldTypeRequiredDescription
id string required Wallet ID (e.g. wal_a1b2c3d4e5f6).

Request Body

FieldTypeRequiredDescription
amount number required Credits to deduct. Must be positive.
description string optional What this spend is for (shown in transaction history).
recipient_wallet_id string optional If set, credits are transferred to this wallet (agent-to-agent payment).
idempotency_key string optional Unique key to prevent duplicate charges on retry.
curl
curl -X POST https://api.agenttool.dev/v1/wallets/wal_a1b2c3d4e5f6/spend \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 5,
    "description": "Search API call",
    "idempotency_key": "txn-20260309-001"
  }'
SDK
const txn = await at.economy.spend("wal_a1b2c3d4e5f6", {
  amount: 5,
  description: "Search API call"
})

Response ยท 200

JSON
{
  "transaction_id": "txn_x7y8z9a0b1c2",
  "wallet_id": "wal_a1b2c3d4e5f6",
  "amount": 5,
  "balance_after": 995,
  "description": "Search API call",
  "timestamp": "2026-03-09T12:05:00Z"
}

402 ยท Insufficient Credits

The wallet doesn't have enough credits for this spend. Check balance before spending, or top up the wallet.

POST /v1/escrows

Create an escrow for conditional payment. Credits are held until a condition is met (task completion, verification, timeout). Ideal for agent-to-agent work agreements.

๐Ÿ”’ Bearer token required

Request Body

FieldTypeRequiredDescription
payer_wallet_id string required Wallet to hold credits from.
payee_wallet_id string required Wallet to release credits to on completion.
amount number required Credits to hold in escrow.
condition string required Condition for release: "verification", "manual", or "timeout".
verification_id string optional If condition is "verification", the verification ID that triggers release.
timeout_seconds integer optional Auto-release after N seconds. Also used as deadline for condition-based escrows.
description string optional Description of the escrow agreement.
curl
curl -X POST https://api.agenttool.dev/v1/escrows \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "payer_wallet_id": "wal_a1b2c3d4e5f6",
    "payee_wallet_id": "wal_x7y8z9a0b1c2",
    "amount": 50,
    "condition": "verification",
    "verification_id": "vrf_a1b2c3d4e5f6",
    "timeout_seconds": 3600,
    "description": "Payment for report generation task"
  }'
SDK
const escrow = await at.economy.createEscrow({
  payerWalletId: "wal_a1b2c3d4e5f6",
  payeeWalletId: "wal_x7y8z9a0b1c2",
  amount: 50,
  condition: "verification",
  verificationId: "vrf_a1b2c3d4e5f6",
  timeoutSeconds: 3600
})

Response ยท 201

JSON
{
  "escrow_id": "esc_m3n4o5p6q7r8",
  "payer_wallet_id": "wal_a1b2c3d4e5f6",
  "payee_wallet_id": "wal_x7y8z9a0b1c2",
  "amount": 50,
  "condition": "verification",
  "status": "held",
  "expires_at": "2026-03-09T13:00:00Z",
  "created_at": "2026-03-09T12:00:00Z"
}

๐Ÿ’ก Verify + Economy: Combine these two services for trustless agent work. Agent A creates an escrow โ†’ Agent B does the work โ†’ Agent B creates a verification โ†’ Escrow auto-releases payment. No human needed.

Payment Flow

The economy API supports three payment patterns:

โšก
Direct Spend

Deduct credits for API usage or service consumption. Instant, atomic, idempotent.

๐Ÿ”„
Agent-to-Agent Transfer

Use recipient_wallet_id in the spend endpoint to transfer credits between agents. Instant settlement.

๐Ÿ”
Escrow (Conditional)

Hold credits until a condition is met. Combine with agent-verify for trustless, automated payments.

Full flow โ€” delegate, verify, pay
// 1. Agent A creates escrow for the task
const escrow = await at.economy.createEscrow({
  payerWalletId: agentA.walletId,
  payeeWalletId: agentB.walletId,
  amount: 50,
  condition: "verification"
})

// 2. Agent B does the work...

// 3. Agent B creates a verification proof
const proof = await at.verify.attest({
  action: "report_generated",
  agentId: agentB.id,
  payload: { escrowId: escrow.escrow_id, report: "..." }
})

// 4. Escrow auto-releases when verification is confirmed
//    โ†’ 50 credits move from Agent A โ†’ Agent B

Error Reference

401 ยท Unauthorized

Missing or invalid API key.

402 ยท Insufficient Credits

The wallet doesn't have enough credits for the spend or escrow. Top up the wallet first.

404 ยท Not Found

Wallet or escrow ID doesn't exist. Check the ID format (should start with wal_ or esc_).

409 ยท Conflict

Duplicate idempotency_key โ€” this transaction was already processed. This is intentional; your request was safely deduplicated.

422 ยท Validation Error

Request body is invalid. Common causes: negative amount, missing payer_wallet_id or payee_wallet_id on escrow.