Getting Started
Let's get you accepting x402 payments in 5 minutes. No BS, no complexity.
What You Need
Ability to make HTTP requests (if you've ever called an API, you're good)
A wallet address to receive payments (we'll help you get one if you don't have it)
That's it. Seriously.
What We're Doing
Super simple:
Get your API key (30 seconds)
Make one API call to verify payments
Done. You're accepting x402 payments.
Setup
No SDK to install. No complex dependencies. Interface402 is just HTTP endpoints.
If you want to use our examples, grab the HTTP library for your language:
npm install axios # or use fetch
npm install ws # for WebSocket supportpip install requests
pip install websocket-clientcargo add reqwest
cargo add tokio-tungstenite # for WebSocket supportGet Your API Key
Go to interface402.dev
Sign up (literally just your email)
Grab your API key from the dashboard
Keep it secret (don't put it in your frontend code or GitHub)
Accept Your First Payment
Copy, paste, done:
curl -X POST https://api.interface402.dev/v1/payments/verify \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"payment_proof": "BASE64_ENCODED_PAYMENT_PROOF",
"amount": 1000000,
"recipient": "YOUR_WALLET_ADDRESS",
"network": "solana"
}'const response = await fetch('https://api.interface402.dev/v1/payments/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
payment_proof: 'BASE64_ENCODED_PAYMENT_PROOF',
amount: 1000000,
recipient: 'YOUR_WALLET_ADDRESS',
network: 'solana'
})
});
const data = await response.json();
console.log('Payment verified:', data);import requests
response = requests.post(
'https://api.interface402.dev/v1/payments/verify',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
json={
'payment_proof': 'BASE64_ENCODED_PAYMENT_PROOF',
'amount': 1000000,
'recipient': 'YOUR_WALLET_ADDRESS',
'network': 'solana'
}
)
data = response.json()
print('Payment verified:', data)That's It
You just verified an x402 payment. Told you it was simple.
Real Example (Drop This Into Your App)
Here's how to actually use this in a real server:
// Your API server receives a 402 Payment Required request
app.get('/api/protected-resource', async (req, res) => {
const paymentProof = req.headers['x-payment-proof'];
if (!paymentProof) {
// No payment provided, return 402
return res.status(402).json({
error: 'Payment Required',
amount: 1000000,
recipient: 'YOUR_WALLET_ADDRESS',
network: 'solana'
});
}
try {
// Verify the payment with Interface402
const verification = await fetch('https://api.interface402.dev/v1/payments/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
payment_proof: paymentProof,
amount: 1000000,
recipient: 'YOUR_WALLET_ADDRESS',
network: 'solana'
})
});
const result = await verification.json();
if (result.verified) {
// Settle the payment
await fetch('https://api.interface402.dev/v1/payments/settle', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
payment_id: result.payment_id
})
});
// Payment verified and settled, return the resource
return res.json({ data: 'Your protected resource' });
} else {
return res.status(402).json({ error: 'Invalid payment' });
}
} catch (error) {
return res.status(500).json({ error: 'Payment verification failed' });
}
});What's Next?
Check out the API Reference for all the details
See more code examples in your favorite language
Set up WebSocket streaming to get notified when payments happen
Read about x402 if you're curious how it works under the hood
Quick Tips
Keep your API key secret - Don't put it in frontend code or commit it to GitHub
Check payment amounts - Make sure you're getting paid what you expect
Handle errors - Networks fail, APIs timeout. Handle it gracefully.
Start small - Test with small amounts first
Use WebSockets - Get real-time updates when payments come through
How x402 Works (The Simple Version)
Someone requests your API → You say "402, pay me $X"
They send a payment → You check it with Interface402
It's valid → You give them what they asked for
That's it. We handle all the blockchain stuff so you don't have to think about it.
Last updated
