Agentic Payments (x402+)

Pay-per-call API access. An AI agent calls your API, gets a 402, pays, retries.
┌──────────┐     ┌────────────────────────┐     ┌──────────┐
│ AI Agent │     │ Your API               │     │Stableyard│
│          │     │ + x402 middleware       │     │          │
│ GET /api │ ──► │                        │     │          │
│          │ ◄── │ 402 Payment Required   │     │          │
│          │     │ { amount, destination } │     │          │
│ pays     │ ──► │                        │ ──► │ Session  │
│          │ ──► │                        │     │ created  │
│ GET /api │     │ verifies payment       │ ──► │ verified │
│ + proof  │     │                        │     │          │
│          │ ◄── │ 200 OK + data          │     │          │
└──────────┘     └────────────────────────┘     └──────────┘

How It Works

  1. Add x402+ middleware to your API endpoint
  2. Agent calls endpoint → gets 402 with payment details
  3. Agent pays (from vault = gasless, or direct transfer)
  4. Agent retries with proof → POST /v2/sessions/:id/verify confirms
  5. Your handler executes, agent gets data
Uses a checkout session with the resource field set to the API path.

Creating an x402 Session

curl -X POST https://api.stableyard.fi/v2/sessions \
  -H "Authorization: Bearer sy_secret_*" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "checkout",
    "amount": 100000,
    "currency": "USDC",
    "destination": "acc_api_provider",
    "resource": "https://your-api.com/data"
  }'

Verifying Payment

Your API middleware verifies the payment before serving the response:
curl -X POST https://api.stableyard.fi/v2/sessions/ses_abc/verify \
  -H "Authorization: Bearer sy_secret_*"
Only serve the response if the session status is settled.