Documentation
Everything you need to give your AI agents the ability to transact autonomously across crypto, card, and ACH payment rails.
Base URL: https://AgentPayment/api/v1
Quickstart
Get your first agent-to-agent payment running in under 5 minutes.
1. Sign up and get your API keys
Go to AgentPayment and sign up. Here's what happens:
- First email arrives immediately — contains your Sandbox Agent ID + API Key and a verification link
- Click the verification link — confirms your email (link expires in 24 hours)
- Second email arrives — contains your Live Agent ID + API Key for real payments
2. Install the SDK
pip install agent-payment-sdk
3. Make your first payment (sandbox)
from agent_payment_sdk import AgentPaymentClient
# Use your sandbox credentials — no real money moves
consumer = AgentPaymentClient(api_key="apn_your_sandbox_api_key")
provider = AgentPaymentClient(api_key="apn_provider_sandbox_api_key")
# Step 1 — Consumer sets auto-billing rule once
consumer.set_billing_rule(
max_amount=50.00,
preferred_rail="card", # card | crypto | bank
approved_provider_id="sandbox_provider_agent_id"
)
# Step 2 — Provider creates invoice — auto-paid instantly
invoice = provider.create_invoice(
to_agent_id="sandbox_consumer_agent_id",
amount=3.00,
description="API usage — 5 calls @ $0.60",
payment_rail="card"
)
print(invoice["status"]) # PAID
print(invoice["invoice_id"]) # uuid
print(invoice["transaction_id"]) # uuid
4. Manage your agents
Visit your Agent Dashboard to create additional agents, rotate API keys, and monitor your account — no code needed.
Sandbox vs Live
AgentPayment provides two environments — sandbox for testing and live for real payments.
| Feature | Sandbox | Live |
|---|---|---|
| Agent ID prefix | sandbox_ | agent_ |
| Real money | No — simulated balance ($1,000) | Yes |
| Crypto payments | Simulated tx hash | Real ETH on Base Mainnet |
| Card payments | Stripe test mode | Stripe live mode |
| ACH payments | Plaid sandbox | Plaid production |
| Mixing sandbox/live | ❌ Not allowed — returns error | |
sandbox_live_mismatch error.Authentication
All API requests require an API key passed in the X-API-Key header.
curl https://AgentPayment/api/v1/agents/agent_abc123 \
-H "X-API-Key: apn_your_api_key_here"
| Header | Value | Required |
|---|---|---|
| X-API-Key | Your agent API key (starts with apn_) | Yes |
| Content-Type | application/json | For POST requests |
Crypto (ETH / USDC / Base)
Non-custodial crypto payments on Base Mainnet. Agents sign transactions client-side with their own private key — the platform never holds funds. Our router contract splits the payment atomically on-chain: receiver gets their amount, platform fee is taken in the same transaction.
Prerequisites
- Both agents must have verified wallet addresses (see Wallet Verification)
- Sending agent wallet must have sufficient ETH for payment + gas (~$0.001 on Base)
- Install SDK with crypto support:
pip install agent-payment-sdk[crypto]
Send a crypto payment (ETH)
from agent_payment_sdk import AgentPaymentClient
# agent_private_key stays on your machine — never sent to the platform
client = AgentPaymentClient(
api_key="apn_your_api_key",
agent_private_key="0xYourAgentPrivateKey"
)
# Get nonce and gas price
nonce = client._request("GET", "/api/v1/payments/nonce", params={"address": "0xYourWalletAddress"})
gas = client._request("GET", "/api/v1/payments/gas-price")
# Send payment — router contract splits fee atomically on-chain
result = client.send_crypto_payment(
from_agent_id="agent_sender_id",
to_agent_id="agent_receiver_id",
amount_wei=935860781350166, # ~$2 in wei
to_wallet_address="0xReceiverWalletAddress",
gas_price=gas["gas_price_wei"],
nonce=nonce["nonce"],
chain_id=8453 # Base Mainnet
)
print(result["tx_hash"]) # 0xdf5a83a5...
print(result["basescan_url"]) # https://basescan.org/tx/0x...
print(result["message"]) # Transaction broadcast to Base Mainnet. Platform never held your funds.
USDC payments
# USDC — stable value, 1:1 USD, no price volatility
payment = client._request("POST", "/api/v1/payments/create", json={
"from_agent_id": "agent_sender_id",
"to_agent_id": "agent_receiver_id",
"amount": 10.00,
"currency": "USDC",
"payment_method": "crypto"
})
| Currency | Use Case | Fee |
|---|---|---|
| ETH | Native crypto, flexible amounts, on-chain fee split via router contract | 0.5% |
| USDC | Stable value, predictable billing, no price volatility | 0.5% |
Router contract: 0xB4732569092a4DFfd18A2D1A37bD8d3A4B0C291e on Base Mainnet. View on BaseScan
Stripe Cards
Process card payments via Stripe Connect. Money flows directly from consumer's card to provider's Stripe account. AgentPayment fee: 0.5% (Free) / 0.3% (Pro) / 0.2% (Business). Stripe's processing fees are charged separately by Stripe.
Consumer setup — save a card
Simply redirect your user to:
https://AgentPayment/setup-card.html?agent_id=YOUR_AGENT_ID&api_key=YOUR_API_KEY&callback_url=YOUR_CALLBACK_URLURL parameters:
agent_id — the consumer agent ID saving the cardapi_key — the agent's API keycallback_url — (optional) redirect URL after card is saved. Receives ?status=success&payment_method_id=xxx&agent_id=xxxThe page handles Stripe.js card collection securely — card details never touch your server.
Or integrate manually — Step 1: Create a SetupIntent to collect card details:
curl -X POST https://AgentPayment/api/v1/payment-methods/card/setup \
-H "X-API-Key: apn_your_api_key" \
-H "Content-Type: application/json" \
-d '{"agent_id": "agent_your_id"}'
# Returns: client_secret, setup_intent_id, customer_id
Step 2: Use the client_secret with Stripe.js to collect card details, then confirm:
curl -X POST https://AgentPayment/api/v1/payment-methods/card/confirm \
-H "X-API-Key: apn_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_your_id",
"payment_method_id": "pm_xxx"
}'
Provider setup — receive card payments
Providers must complete Stripe Connect onboarding once to receive card payments directly:
curl -X POST https://AgentPayment/api/v1/billing/connect/onboard \
-H "X-API-Key: apn_your_api_key" \
-H "Content-Type: application/json" \
-d '{"agent_id": "agent_your_id"}'
# Returns: onboarding_url — open in browser to complete KYC
Pay with card
payment = client.create_payment(
from_agent_id="agent_sender_id",
to_agent_id="agent_receiver_id",
amount=25.00,
currency="USD",
payment_method="stripe_card"
)
ACH Bank Transfer
Bank transfers via Plaid (account linking) + Stripe Connect (processing). Best for high-value settlements. AgentPayment fee: 0.5% (Free) / 0.3% (Pro) / 0.2% (Business). Stripe ACH fees are charged separately by Stripe. Settlement: 2-3 business days.
Consumer setup — link a bank account
Simply redirect your user to:
https://AgentPayment/setup-bank.html?agent_id=YOUR_AGENT_ID&api_key=YOUR_API_KEY&callback_url=YOUR_CALLBACK_URLURL parameters:
agent_id — the consumer agent ID linking the bankapi_key — the agent's API keycallback_url — (optional) redirect URL after bank is linked. Receives ?status=success&payment_method_id=xxx&agent_id=xxxThe page handles Plaid Link securely — bank credentials never touch your server.
Or integrate manually — Step 1: Get a Plaid link token:
curl -X POST https://AgentPayment/api/v1/payment-methods/bank-account/link-token \
-H "X-API-Key: apn_your_api_key" \
-H "Content-Type: application/json" \
-d '{"agent_id": "agent_your_id"}'
# Returns: link_token — use with Plaid Link to connect bank
Step 2: After user completes Plaid Link, exchange the public token:
curl -X POST https://AgentPayment/api/v1/payment-methods/bank-account \
-H "X-API-Key: apn_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_your_id",
"public_token": "public-sandbox-xxx",
"account_id": "account_id_from_plaid"
}'
Provider setup — receive ACH payments
Same as card — complete Stripe Connect onboarding once (see Provider Setup above).
Pay with ACH
payment = client.create_payment(
from_agent_id="agent_sender_id",
to_agent_id="agent_receiver_id",
amount=500.00,
currency="USD",
payment_method="bank"
)
External Payments (Accountless)
Any AI agent — even one with no AgentPayment account — can pay an invoice from a registered provider. This is the Accountless Payment Protocol pattern: the payer discovers payment requirements, sends funds, and receives an access token to prove payment.
How it works
- Provider (registered) creates an invoice as normal
- Provider shares the
invoice_idwith the external payer - External payer fetches payment details — no API key needed
- External payer sends ETH / card / ACH payment
- Platform issues a signed
access_token - Payer passes
access_tokento provider to unlock the service - Provider verifies token — no API key needed to verify
Step 1 — Provider creates invoice
from agent_payment_sdk import AgentPaymentClient
provider = AgentPaymentClient(api_key="your_api_key")
invoice = provider.create_invoice(
to_agent_id=None, # no consumer account required
amount=5.00,
currency="USD",
payment_rail="crypto",
description="AI data feed access — 1 hour"
)
invoice_id = invoice["invoice_id"]
# Share invoice_id with the external payer
Step 2 — External payer fetches payment info
No SDK or account needed. Any HTTP client works.
# No API key required
info = AgentPaymentClient.get_invoice_pay_info(
invoice_id=invoice_id,
base_url="https://AgentPayment"
)
# Returns: amount, currency, receiver_wallet, accepted_rails
print(info["accepted_rails"])
# [{"rail": "crypto", "receiver_wallet": "0x...", "network": "base-mainnet"}]
/api/v1/invoices/{invoice_id}/pay-infoPublic — no authentication required. Returns payment details.
Step 3 — External payer pays (crypto)
from agent_payment_sdk import AgentPaymentClient
# Payer has NO AgentPayment account — just an ETH wallet
receipt = AgentPaymentClient.pay_external_invoice(
invoice_id=invoice_id,
rail="crypto",
private_key="0x...", # payer's ETH private key
base_url="https://AgentPayment"
)
access_token = receipt["access_token"]
# Pass access_token to the provider to unlock the service
Step 3 (alternative) — External payer pays (card)
receipt = AgentPaymentClient.pay_external_invoice(
invoice_id=invoice_id,
rail="card",
payment_method_id="pm_...", # Stripe Payment Method ID from Stripe.js
payer_email="agent@example.com",
base_url="https://AgentPayment"
)
/api/v1/invoices/{invoice_id}/pay-externalPublic — no authentication required.
| Field | Required | Description |
|---|---|---|
rail | Yes | crypto, card, or ach |
tx_hash | Crypto only | On-chain tx hash of your ETH transfer to provider wallet |
payer_wallet | Crypto only | Your ETH wallet address |
payment_method_id | Card/ACH only | Stripe pm_... token from Stripe.js |
payer_email | No | Optional — for receipt |
Step 4 — Provider verifies access token
# Provider verifies before granting service access
result = AgentPaymentClient.verify_external_payment(
invoice_id=invoice_id,
access_token=token_from_payer,
base_url="https://AgentPayment"
)
if result["valid"]:
grant_access_to_service()
print(f"Verified — payer: {result['payer_wallet']}")
/api/v1/invoices/{invoice_id}/access/{token}Public — no authentication required. Returns {"valid": true} if payment confirmed.
Partial & Installment Payments
Invoices can be paid in multiple installments. A consumer with a billing rule capped below the invoice amount automatically pays their maximum — the remainder stays pending for later.
How partial payments work
- Provider creates invoice for $100
- Consumer has billing rule max $40 — auto-pays $40 instantly
- Invoice status becomes
PARTIAL_PAID,amount_remaining: 60 - Consumer raises their limit or manually pays the rest
- Invoice becomes
PAIDwhen fully settled
Check invoice balance
invoice = provider.get_invoice(invoice_id)
print(invoice["amount_paid"]) # 40.0
print(invoice["amount_remaining"]) # 60.0
print(invoice["status"]) # PARTIAL_PAID
print(invoice["partial_payments"]) # 1
Pay the remaining balance
# Consumer pays the full remaining balance
consumer = AgentPaymentClient(api_key="consumer_api_key")
result = consumer._request(
"POST",
f"/api/v1/invoices/{invoice_id}/pay-remaining"
)
print(result["status"]) # PAID
Pay a specific partial amount
# Pay only $25 of the $60 remaining
result = consumer._request(
"POST",
f"/api/v1/invoices/{invoice_id}/pay-remaining",
json={"partial_amount": 25.00}
)
print(result["amount_remaining"]) # 35.0
/api/v1/invoices/{invoice_id}/pay-remainingAuthenticated — requires consumer API key. Optional body: {"partial_amount": float}
List invoices with payment progress
# See all invoices with paid/remaining amounts
invoices = consumer._request("GET", "/api/v1/invoices")
for inv in invoices["invoices"]:
print(f"{inv['invoice_id']}: "
f"${inv['amount_paid']} paid, "
f"${inv['amount_remaining']} remaining, "
f"status: {inv['status']}")
Agent-to-Agent Billing
The pull payment model — provider agents autonomously invoice consumer agents, which auto-approve and pay instantly based on billing rules. Zero human intervention required.
How it works
- Consumer agent sets an auto-approval billing rule once (max amount + preferred rail)
- Provider agent serves a request and creates an invoice against the consumer
- System checks billing rule → if approved, payment processes instantly
- Both agents receive confirmation with transaction ID and tx hash
Step 1 — Consumer sets billing rule
consumer = AgentPaymentClient(api_key="apn_consumer_key")
rule = consumer.set_billing_rule(
max_amount=10.00, # auto-approve invoices up to $10
preferred_rail="crypto", # crypto | card | bank
approved_provider_id="agent_provider_id"
)
print(rule["message"]) # Auto-approve invoices from agent_provider_id up to $10.0
Step 2 — Provider creates invoice
provider = AgentPaymentClient(api_key="apn_provider_key")
invoice = provider.create_invoice(
to_agent_id="agent_consumer_id",
amount=3.00,
description="API usage — 150 requests @ $0.02/req",
payment_rail="crypto"
)
print(invoice["status"]) # PAID (auto-approved instantly)
print(invoice["invoice_id"]) # uuid
print(invoice["paid_at"]) # 2026-03-17T...
PENDING until manually approved via approve_invoice().Recurring Billing
Providers register a billing schedule once — the platform fires it automatically at the chosen interval. Two models: webhook-based (Model A) or fully autonomous (Model B).
Model A — Webhook-Based
Platform fires a webhook to your callback_url at each interval. You calculate actual usage and call POST /invoices with the real amount.
provider = AgentPaymentClient(api_key="apn_provider_key")
schedule = provider.create_recurring_billing(
consumer_id="agent_consumer_id",
frequency="1h", # 30m, 1h, 6h, 1d, 7d, 30d
payment_rail="CRYPTO",
callback_url="https://your-service.com/billing-webhook",
max_per_period=100.00, # safety cap per cycle
description="API usage billing"
)
At each interval, your callback_url receives:
{
"event": "billing_due",
"recurring_id": "f55ecdcf-...",
"provider_id": "agent_xyz",
"consumer_id": "agent_abc",
"period_start": "2026-04-04T15:00:00",
"period_end": "2026-04-04T16:00:00",
"payment_rail": "CRYPTO",
"max_per_period": 100.0
}
Then create an invoice for the actual usage:
# In your webhook handler:
usage = calculate_usage(period_start, period_end)
invoice = provider.create_invoice(
to_agent_id="agent_consumer_id",
amount=usage,
payment_rail="CRYPTO",
description="API usage 15:00-16:00 UTC"
)
# Consumer billing rule auto-pays if within limit
Model B — Fully Autonomous
Platform calls your usage_endpoint at each interval, creates the invoice, and triggers auto-payment. Zero involvement after setup.
schedule = provider.create_recurring_billing(
consumer_id="agent_consumer_id",
frequency="1h",
payment_rail="CRYPTO",
usage_endpoint="https://your-service.com/usage",
max_per_period=100.00,
description="API usage billing"
)
# AgentPayment auto-generates a secure token — store it once:
token = schedule["usage_auth_token"] # e.g. "a3f9c2e1d4b7..."
usage_auth_token at registration and returns it once. The platform sends it as Authorization: Bearer <token> on every usage pull — verify it on your endpoint. After that, everything runs autonomously. If ever compromised, rotate with POST /api/v1/recurring-billing/{id}/rotate-token.Your usage_endpoint receives a POST and must return:
# Platform sends:
{
"recurring_id": "f55ecdcf-...",
"consumer_id": "agent_abc",
"period_start": "2026-04-04T15:00:00",
"period_end": "2026-04-04T16:00:00"
}
# Your response:
{ "amount": 42.50 } # Return 0 to skip invoicing this period