HomeDocumentation

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

Shell
npm install @txn-dev/sdk

2Initialize the client

TypeScript
import { Txn } from "@txn-dev/sdk"
 
const txn = new Txn("txn_live_...")

3Create a wallet

TypeScript
const wallet = await txn.wallets.create({
name: "my-agent",
currency: "usd"
})

4Pay another agent

TypeScript
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.

Shell
curl https://api.txn.dev/wallets \
-H "Authorization: Bearer txn_live_..."
API key modes
Keys are scoped to either 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

POST/wallets

Create a new wallet for your organization.

Request body

JSON
{
"name": "translation-agent",
"currency": "usd",
"metadata": { "agent_version": "2.1" }
}

Response

JSON
{
"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).
GET/wallets

List all wallets for your organization in the current mode.

Response

JSON
{
"wallets": [
{
"id": "w-a1b2c3d4",
"name": "translation-agent",
"balance": "150.00",
"currency": "usd"
}
]
}

Transfers

POST/pay

Transfer funds between two wallets. Both wallets must use the same currency and mode.

Request body

JSON
{
"from": "wallet_sender_id",
"to": "wallet_receiver_id",
"amount": 0.003,
"memo": "translated 340 words en>fr",
"idempotency_key": "job_7f3a9c"
}

Response

JSON
{
"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

POST/fund

Create a Stripe checkout session to add funds to a wallet.

Request body

JSON
{
"wallet_id": "w-a1b2c3d4",
"amount": 50.00
}

Response

JSON
{
"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.

JSON
{
"error": "Insufficient balance"
}
StatusMeaning
400Bad request. Check your parameters.
401Unauthorized. Check your API key.
403Forbidden. You don't own that resource.
500Server 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.

Shell
npm install @txn-dev/sdk
TypeScript
import { Txn } from "@txn-dev/sdk"
 
const txn = new Txn("txn_live_...")
 
// Create a wallet
const wallet = await txn.wallets.create({
name: "my-agent",
currency: "usd",
})
 
// List wallets
const wallets = await txn.wallets.list()
 
// Get a single wallet
const w = await txn.wallets.get("wallet_id")
 
// Transfer funds
const transfer = await txn.pay({
from: "wallet_a",
to: "wallet_b",
amount: 1.50,
memo: "service fee",
})
 
// Fund via Stripe
const funding = await txn.fund({
wallet_id: "wallet_a",
amount: 100,
})
Error handling
All SDK methods throw a 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.

Shell
npm install -g @txn-dev/mcp-server

Claude Desktop

Add this to your claude_desktop_config.json:

JSON
{
"mcpServers": {
"txn-payments": {
"command": "txn-mcp-server",
"env": {
"TXN_API_KEY": "txn_live_..."
}
}
}
}

Available tools

ToolDescription
create_walletCreate a new agent wallet
list_walletsList all wallets
get_balanceCheck a wallet's balance
payTransfer between wallets
fund_walletCreate a Stripe funding session

LangChain

The @txn-dev/langchain package provides a TxnToolkit that plugs directly into LangChain and LangGraph agents.

Shell
npm install @txn-dev/langchain @langchain/core
TypeScript
import { TxnToolkit } from "@txn-dev/langchain"
 
const toolkit = new TxnToolkit("txn_live_...")
const tools = toolkit.getTools()
 
// Use with a LangGraph agent
import { 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.

Go to Dashboard