Overview
The x402 payment protocol enables micropayments for API calls using cryptocurrency. Syra implements x402 v2 with USDC on Solana.Protocol Version
Syra uses x402 v2 with the following features:- Real-time payment settlement
- USDC (SPL token) on Solana
- Automatic facilitator fallback
- Payment-Response headers
- Discoverable endpoints on x402scan
Payment Flow
1. Request Payment
Client makes request to paid endpoint:2. Payment Required
Server responds with payment requirement:3. Settlement
Payment is settled automatically:- Deducted from agent wallet
- Transferred in USDC on Solana
- Transaction confirmed on-chain
- Payment-Response header included
4. Response Delivery
API returns data with payment confirmation:Payment Options
Endpoints define payment options:Settlement Methods
Standard Settlement
Fallback Settlement
Handles facilitator failures gracefully:Buyback Mechanism
After successful payment, automatic buyback is triggered:Pricing Configuration
Prices are defined in configuration:Effective Pricing
Development wallets may receive discounted pricing:Discovery
All discoverable endpoints are indexed on x402scan:- Endpoint path and method
- Price in USD
- Input/output schemas
- Description and documentation
Agent Integration
Balance Check
Before calling tools:Tool Call with Payment
Error Handling
Payment Errors
Budget Exceeded
Caching
To reduce costs, responses are cached:Security Features
- Non-custodial payments
- On-chain settlement verification
- Automatic timeout handling
- Facilitator fallback
- Request logging and analytics
Best Practices
- Check Balance First: Always verify sufficient USDC before calls
- Handle Failures: Implement fallback for payment failures
- Use Caching: Leverage cached responses when available
- Monitor Costs: Track spending across API calls
- Test in Dev: Use
/devendpoints during development
Next Steps
News API
Make your first x402 API call
Agent Tools
Integrate x402 with AI agents