The x402 API payment flow
The x402 protocol is an open standard that lets AI agents pay for API calls the same way a browser pays for a web page — with a cryptographic receipt attached to the HTTP request. Pay3 implements x402 natively on Stellar, making it possible for your AI to discover and access paid data feeds, tools, and services without any human involvement.AI makes an unauthenticated request
Server responds with HTTP 402 Payment Required
402 Payment Required with a payment specification: the price, the asset (e.g. USDC), and an optional memo that identifies the resource.AI asks Pay3 to execute the payment
Pay3 signs and submits a Stellar transaction
Stellar confirms and Pay3 returns a payment proof
AI resends the request with the payment proof
Server verifies on Stellar and delivers the resource
The transfer flow (direct payments)
When you ask your AI to send funds directly — “pay 5 USDC to John” — it calls thetransfer MCP tool. Here is exactly what happens from that call to the moment the recipient sees the funds.
AI calls transfer(recipient, asset, amount, idempotency_key)
transfer tool with four arguments: who to pay, which asset, how much, and an idempotency_key — a stable identifier for this specific payment intent.MCP server authenticates the token
PAY3_MCP_AUTH_TOKEN from the session configuration. If the token is expired, revoked, or malformed, the request is rejected immediately and the AI receives an error.Recipient is resolved
- A verified contact name or alias stored in your Pay3 contacts (e.g.
"John") - A raw Stellar public key (e.g.
GDQP2KPQ…)
Policy engine evaluates the transfer
- Is the asset allowed? (e.g. USDC, XLM)
- Does the amount exceed the per-transaction maximum?
- Does today’s spending plus this amount exceed the daily budget?
- Is the recipient on any blocklist?
- Has the session expired?
Policy engine returns a decision
AUTO_EXECUTE: session key decrypted and transaction submitted
- Decrypts the session keypair stored server-side.
- Constructs a Stellar payment transaction.
- Signs it with the session key and submits it to the Stellar network via the Soroban vault contract or Horizon API.
- Waits for confirmation (typically 3–5 seconds).
Budget updated, audit log written, result returned
Three-level execution model
Every payment decision passes through the same three-outcome engine. Understanding it tells you exactly what your AI can do autonomously, what requires your attention, and what gets blocked entirely.AUTO_EXECUTE
PENDING_APPROVAL
REJECT
Session key security model
Pay3’s security model is built around one principle: your AI never has access to your private key. Here is how that guarantee is enforced at every layer.A temporary session keypair is generated
The session key is registered on-chain in your Soroban vault
add_session call that records:- The session public key
- The session expiry timestamp
- The per-transaction maximum (from your policy)
- The daily maximum (from your policy)
Policy snapshot is attached at session creation
Every tool call is authenticated by MCP token
PAY3_MCP_AUTH_TOKEN on every tool call. Pay3 links the token to the session record, verifies it hasn’t been revoked, and loads the associated smart account and policy snapshot.Sessions expire automatically
You can revoke all sessions instantly