Skip to main content
AI agents can send and receive stablecoin payments autonomously using XPayLabs. Agents call the REST API to create collection orders and initiate payouts, listen for webhook events, and manage balances — with zero gateway fees and full self-custody of funds.

Why Crypto for AI Agents?

ChallengeXPayLabs Solution
Agents need programmable moneyREST API for createCollection / createPayout — agents call endpoints directly
No human in the loop for approvalsAutomated signing with environment-stored secrets
Cross-border agent-to-agent paymentsStablecoins on TRON, EVM, and SUI settle in seconds
MicrotransactionsZero gateway fees — only blockchain gas costs (0.010.01–0.50)
Self-custody requiredNon-custodial — keys stay in your Docker containers

Agent Payment Flows

Incoming Payments (Agent Gets Paid)

An agent receives crypto payments by creating collection orders. This is the most common flow — users or other agents send funds to a deposit address generated by the agent.
The agent then listens for the ORDER_SUCCESS webhook to release the service:

Outgoing Payments (Agent Pays Out)

An agent initiates payouts to external addresses — paying for compute, staking, or settling with other agents:

Agent-to-Agent Payments

Two autonomous agents can transact directly:

Autonomous Agent Architecture

Key Design Considerations

Secret Management

The merchant token and API secret must be accessible to the agent at runtime without hardcoding:

Idempotency

Agents may retry failed requests. Use the orderId field as an idempotency key — the same orderId on a createCollection or createPayout call returns the existing order instead of creating a duplicate.

Webhook Reliability

Agents should use the polling fallback (getOrderStatus) if webhooks are missed. Poll every 3 seconds until SUCCESS, EXPIRED, or FAILED:

Balance Management

Before creating payouts, check the gateway’s hot wallet balance:
For EVM chains, also ensure the hot wallet has sufficient native gas tokens (ETH, BNB, MATIC, AVAX) to cover transaction fees.

Use Cases

Use CaseFlowExample
API access pay-per-callAgent creates collection → user pays → webhook unlocks endpointLLM inference API
Compute marketplaceAgent A pays Agent B for GPU time via payoutDistributed ML training
Autonomous affiliateAffiliate agent receives collection webhook, splits payout to referrerReferral program
Agent-to-agent settlementPeriodic batch payouts between agent walletsCross-agent accounting
Micropayment streamingFrequent small collections (ticketed)Real-time data feeds

Getting Started

  1. Deploy XPayLabs via Docker Compose
  2. Install the Node.js SDK or call the REST API directly
  3. Configure your agent’s environment with the merchant token and API secret
  4. Create a webhook endpoint for ORDER_SUCCESS events
  5. Start creating collection and payout orders programmatically
For agent-to-agent payments, both agents can share the same XPayLabs gateway instance — or run separate instances with their own keys for full isolation.
Last modified on June 26, 2026