Payment
Infrastructure
for AI Agents
Create wallets, fund them, and let your AI agents transact autonomously. Built for the era where agents handle money — safely, programmatically, and at scale.
Quickstart
Get your first agent wallet running in under 2 minutes.
1. Get your API key
After subscribing, your TrueLens API key is shown in your dashboard. It looks like tl_live_xxx.
2. Create a wallet
curl -X POST https://truelens-2.polsia.app/api/pay-rails/wallets \
-H "X-API-Key: tl_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "research-agent"}'
const res = await fetch('https://truelens-2.polsia.app/api/pay-rails/wallets', {
method: 'POST',
headers: {
'X-API-Key': 'tl_live_YOUR_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: 'research-agent' })
});
const { wallet } = await res.json();
console.log(wallet.id, wallet.balance); // → 1, "0.000000"
3. Fund the wallet
Use the Pay Rails Dashboard to fund any wallet via Stripe checkout. Choose $10, $25, $50, or $100.
4. Transfer between agents
curl -X POST https://truelens-2.polsia.app/api/pay-rails/transfer \
-H "X-API-Key: tl_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"from_wallet_id": 1,
"to_wallet_id": 2,
"amount": 0.25,
"description": "Payment for data task"
}'
await fetch('https://truelens-2.polsia.app/api/pay-rails/transfer', {
method: 'POST',
headers: {
'X-API-Key': 'tl_live_YOUR_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from_wallet_id: 1,
to_wallet_id: 2,
amount: 0.25,
description: 'Payment for data task'
})
});
Authentication
Pay Rails uses your TrueLens API key for authentication. Send it as an HTTP header on every request.
X-API-Key: tl_live_YOUR_KEY
Your key is scoped to your account — wallets created through the API belong to your business. Keep it private. If compromised, regenerate a new key from the dashboard.
Pay Rails API Keys
Optionally, generate purpose-specific Pay Rails API keys from the dashboard. These keys start with pr_live_ and can be used in your agent code.
Wallets
A wallet is an isolated USD balance. Each agent, workflow, or team gets its own wallet. Wallets are cheap to create — spin up as many as you need.
Wallet object
{
"id": 1,
"business_id": 42,
"name": "research-agent",
"balance": "24.750000",
"created_at": "2026-03-31T18:00:00Z",
"updated_at": "2026-03-31T18:30:00Z"
}
Balance is a high-precision decimal string (6 decimal places). Cast to float when doing arithmetic.
Funding
Fund wallets via the Pay Rails Dashboard. Select a wallet, click Fund Wallet, choose an amount ($10–$100), and complete checkout via Stripe.
Funds appear in your wallet within seconds of payment completion. Deposits are logged as type: "deposit" transactions.
Transactions
Every money movement is recorded as a transaction. Transactions are immutable once created.
Transaction types
| Type | Description |
|---|---|
deposit | Funds added via Stripe checkout |
transfer | Agent-to-agent payment via /api/pay-rails/transfer |
Transaction object
{
"id": 7,
"from_wallet_id": 1,
"from_wallet_name": "orchestrator",
"to_wallet_id": 2,
"to_wallet_name": "research-agent",
"amount": "0.250000",
"status": "completed",
"type": "transfer",
"description": "Payment for data task",
"created_at": "2026-03-31T19:12:05Z"
}
Wallet Endpoints
Returns all wallets for your account, ordered by creation date (newest first).
{ "success": true, "wallets": [ { "id": 1, "name": "...", "balance": "...", ... } ] }
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | required | Human-readable wallet name (e.g. "research-agent", "payments-pool") |
Returns up to 100 transactions for the specified wallet, ordered by date descending.
Transaction Endpoints
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| wallet_id | integer | optional | Filter to a specific wallet |
| limit | integer | optional | Max results (default: 200) |
Atomically debit one wallet and credit another. The source wallet must have sufficient balance.
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| from_wallet_id | integer | required | Source wallet ID (must belong to your account) |
| to_wallet_id | integer | required | Destination wallet ID |
| amount | number | required | Amount in USD (e.g. 0.25, 1.00) |
| description | string | optional | Human-readable memo (e.g. "Payment for data task") |
Returns a CSV file download with all transactions. Useful for accounting and audit.
API Key Endpoints
Generates a new pr_live_xxx key. The raw key is returned once only. Store it securely.
{ "success": true, "key": "pr_live_abc123...", "masked": "pr_live_abc...f9" }
Permanently revokes a key. Irreversible. Agents using this key will get 401 Unauthorized.
JavaScript SDK
The Pay Rails SDK is a thin wrapper around the REST API. Install via npm or copy the snippet.
Install
npm install @truelens/pay-rails
Usage
import { createWallet, payAgent, getBalance } from "@truelens/pay-rails";
// Initialize (reads PR_API_KEY from env automatically)
const wallet = await createWallet("research-agent");
console.log(wallet.id); // → 1
// Pay another agent
await payAgent(wallet.id, recipientWalletId, 0.25, "Data research task");
// Check balance
const balance = await getBalance(wallet.id);
console.log(`$${balance}`); // → "$24.75"
SDK Examples
Vanilla JS fetch wrapper
// pay-rails.js — drop this in your project
const BASE = 'https://truelens-2.polsia.app';
const headers = () => ({
'X-API-Key': process.env.TRUELENS_API_KEY,
'Content-Type': 'application/json'
});
export async function createWallet(name) {
const res = await fetch(`${BASE}/api/pay-rails/wallets`, {
method: 'POST', headers: headers(),
body: JSON.stringify({ name })
});
const data = await res.json();
if (!data.success) throw new Error(data.error);
return data.wallet;
}
export async function payAgent(fromId, toId, amount, description = '') {
const res = await fetch(`${BASE}/api/pay-rails/transfer`, {
method: 'POST', headers: headers(),
body: JSON.stringify({ from_wallet_id: fromId, to_wallet_id: toId, amount, description })
});
const data = await res.json();
if (!data.success) throw new Error(data.error);
return data;
}
export async function getBalance(walletId) {
const res = await fetch(`${BASE}/api/pay-rails/wallets/${walletId}`, { headers: headers() });
const data = await res.json();
return parseFloat(data.wallet.balance);
}
export async function listTransactions(walletId) {
const res = await fetch(`${BASE}/api/pay-rails/wallets/${walletId}/transactions`, { headers: headers() });
const data = await res.json();
return data.transactions;
}
Agent orchestration pattern
import { createWallet, payAgent, getBalance } from './pay-rails.js';
// Orchestrator agent has a master wallet
const orchestratorWalletId = 1; // created in dashboard
// Spawn sub-agents and pay them per task
async function runResearchTask(query) {
const agentWallet = await createWallet(`research-${Date.now()}`);
// Fund sub-agent for this task
await payAgent(orchestratorWalletId, agentWallet.id, 1.00, `Research: ${query}`);
// Agent does work...
const result = await researchAgent(query, agentWallet.id);
// Reclaim unused balance
const remaining = await getBalance(agentWallet.id);
if (remaining > 0) {
await payAgent(agentWallet.id, orchestratorWalletId, remaining, 'Reclaim unused');
}
return result;
}
Rate Limits
| Endpoint Group | Limit |
|---|---|
Wallet reads (GET /wallets, GET /wallets/:id) | 300 req/min |
Transfers (POST /transfer) | 60 req/min |
Wallet creation (POST /wallets) | 20 req/min |
| Key management | 10 req/min |
Rate limit headers are included in all responses: X-RateLimit-Remaining and X-RateLimit-Reset.
Error Codes
All errors return a JSON body with an error field and an appropriate HTTP status.
| HTTP Status | Error | Cause |
|---|---|---|
| 400 | Missing required fields | Required body parameter is absent or empty |
| 400 | Insufficient balance | Source wallet has less than the requested transfer amount |
| 401 | Missing API key | No X-API-Key header sent |
| 401 | Invalid API key | Key not found or revoked |
| 403 | Subscription inactive | Your TrueLens subscription has lapsed |
| 404 | Wallet not found | Wallet ID doesn't exist or belongs to another account |
| 500 | Internal error | Server-side failure — retry with exponential backoff |
Get Started — Create Your First Agent Wallet
Subscribe to TrueLens and get immediate access to Pay Rails. Create wallets, fund them, and let your agents run.
Start Building →