Documentation
Everything you need to add payments to your AI agents. From first API call to production.
Quickstart~2 min
Get a wallet created and a transfer sent in four steps. You will need a txn.dev account and an API key from the dashboard.
1Install the SDK
npm install @txn-dev/sdk
2Initialize the client
import { Txn } from "@txn-dev/sdk"const txn = new Txn("txn_live_...")
3Create a wallet
const wallet = await txn.wallets.create({name: "my-agent",currency: "usd"})
4Pay another agent
await txn.pay({from: wallet.id,to: "wallet_receiver_id",amount: 0.50,memo: "task completed"})
Authentication
All API requests require a Bearer token in the Authorization header. Create API keys from the dashboard.
curl https://api.txn.dev/wallets \-H "Authorization: Bearer txn_live_..."
live or test mode. Test mode keys only access test wallets and never touch real money. Use them during development.- Keys are shown once at creation. Store them securely.
- All keys are scoped to your organization.
- Revoke compromised keys immediately from the dashboard.
Core Concepts
txn.dev is a ledger for autonomous agents. Understanding a few primitives will help you build on it effectively.
Wallets
Every agent gets its own wallet with a balance denominated in a single currency (USD, EUR, or GBP). Wallets are scoped to your organization and identified by a UUID. Fund them via Stripe, spend from them programmatically.
Transfers
Wallet-to-wallet transfers settle instantly on the internal ledger. Sub-cent precision (up to 8 decimal places) means you can charge exactly what a task costs. A 2.5% platform fee is deducted from each transfer. Include an idempotency key for safe retries.
Modes
Every API key, wallet, and transaction belongs to either live or test mode. The two are completely isolated. Test mode is free and uses Stripe test credentials. You can only transfer between wallets in the same mode.
Idempotency
Pass an idempotency_key with any transfer to safely retry on network failures. If a transfer with the same key has already completed, the existing result is returned instead of creating a duplicate.
Wallets
/walletsCreate a new wallet for your organization.
Request body
{"name": "translation-agent","currency": "usd","metadata": { "agent_version": "2.1" }}
Response
{"wallet": {"id": "w-a1b2c3d4","name": "translation-agent","balance": "0","currency": "usd","created_at": "2026-03-28T12:00:00Z"}}
- name is required and must be 255 characters or less.
- currency defaults to usd. Supported: usd, eur, gbp.
- metadata is optional JSON (max 10KB).
/walletsList all wallets for your organization in the current mode.
Response
{"wallets": [{"id": "w-a1b2c3d4","name": "translation-agent","balance": "150.00","currency": "usd"}]}
Transfers
/payTransfer funds between two wallets. Both wallets must use the same currency and mode.
Request body
{"from": "wallet_sender_id","to": "wallet_receiver_id","amount": 0.003,"memo": "translated 340 words en>fr","idempotency_key": "job_7f3a9c"}
Response
{"transaction": {"id": "txn_x1y2z3","from_wallet_id": "wallet_sender_id","to_wallet_id": "wallet_receiver_id","amount": "0.003","type": "transfer","status": "completed","created_at": "2026-03-28T12:01:00Z"},"fee": {"amount": "0.00007500","net": "0.00292500","rate": "2.5%"}}
- Transfers settle instantly on the internal ledger.
- Sub-cent amounts supported (up to 8 decimal places).
- A 2.5% platform fee is deducted. The fee breakdown is returned in the response.
- Include an idempotency_key for safe retries on unreliable networks.
- You can only send from wallets owned by your organization.
- Source and destination wallets must share the same currency.
Funding
/fundCreate a Stripe checkout session to add funds to a wallet.
Request body
{"wallet_id": "w-a1b2c3d4","amount": 50.00}
Response
{"checkout_url": "https://checkout.stripe.com/...","session_id": "cs_live_..."}
- Minimum funding amount: $20.
- Maximum funding amount: $100,000.
- Funds are credited after Stripe confirms payment via webhook.
- Supported currencies: USD, EUR, GBP.
Error Handling
All errors return a JSON object with an error field.
{"error": "Insufficient balance"}
| Status | Meaning |
|---|---|
| 400 | Bad request. Check your parameters. |
| 401 | Unauthorized. Check your API key. |
| 403 | Forbidden. You don't own that resource. |
| 500 | Server error. Retry with an idempotency key. |
TypeScript SDK
The @txn-dev/sdk package is a zero-dependency client for the txn.dev API. It works in Node.js, Deno, Bun, and any runtime with fetch.
npm install @txn-dev/sdk
import { Txn } from "@txn-dev/sdk"const txn = new Txn("txn_live_...")// Create a walletconst wallet = await txn.wallets.create({name: "my-agent",currency: "usd",})// List walletsconst wallets = await txn.wallets.list()// Get a single walletconst w = await txn.wallets.get("wallet_id")// Transfer fundsconst transfer = await txn.pay({from: "wallet_a",to: "wallet_b",amount: 1.50,memo: "service fee",})// Fund via Stripeconst funding = await txn.fund({wallet_id: "wallet_a",amount: 100,})
TxnError on failure, which includes status and message properties.MCP Server
The @txn-dev/mcp-server package lets AI assistants like Claude manage wallets and payments via the Model Context Protocol. Install it globally, then add it to your MCP client config.
npm install -g @txn-dev/mcp-server
Claude Desktop
Add this to your claude_desktop_config.json:
{"mcpServers": {"txn-payments": {"command": "txn-mcp-server","env": {"TXN_API_KEY": "txn_live_..."}}}}
Available tools
| Tool | Description |
|---|---|
| create_wallet | Create a new agent wallet |
| list_wallets | List all wallets |
| get_balance | Check a wallet's balance |
| pay | Transfer between wallets |
| fund_wallet | Create a Stripe funding session |
LangChain
The @txn-dev/langchain package provides a TxnToolkit that plugs directly into LangChain and LangGraph agents.
npm install @txn-dev/langchain @langchain/core
import { TxnToolkit } from "@txn-dev/langchain"const toolkit = new TxnToolkit("txn_live_...")const tools = toolkit.getTools()// Use with a LangGraph agentimport { createReactAgent } from "@langchain/langgraph/prebuilt"import { ChatAnthropic } from "@langchain/anthropic"const agent = createReactAgent({llm: new ChatAnthropic({ model: "claude-sonnet-4-20250514" }),tools,})
The toolkit exposes the same five tools as the MCP server: create_wallet, list_wallets, get_balance, pay, and fund_wallet.
Ready to build?
Create your first wallet in under a minute.