x402 v2.6.0 shipped last weekend with native Go, TypeScript, and Python SDK support all landing the same day. If you're building agents that call external APIs, this is worth understanding.
The protocol is HTTP-native. An agent hits an endpoint, gets a 402 back with payment instructions in the headers, pays in USDC on Base, then retries with the payment receipt. No login flow, no API keys, no billing dashboard.
Here's what that looks like in practice.
The flow
GET /api/v1/assets/defi-yields-live
→ 402 Payment Required
X-Payment: {...payment instructions...}
# agent pays ~$0.01 in USDC
GET /api/v1/assets/defi-yields-live
X-Payment-Response: {...receipt...}
→ 200 OK, JSON data
TypeScript setup with x402 v2.6.0
Install the SDK:
npm install @x402/client @x402/wallet-providers```
{% endraw %}
Wallet setup — you'll need a CDP wallet (Coinbase Developer Platform):
{% raw %}
```typescript
import { createWalletClient } from "@x402/client";import { CdpWalletProvider } from "@x402/wallet-providers";const wallet = await CdpWalletProvider.configure({
apiKeyName: process.env.CDP_API_KEY_NAME,
apiKeyPrivateKey: process.env.CDP_API_KEY_PRIVATE_KEY,
networkId: "base",
});
const client = createWalletClient({ walletProvider: wallet });
Making the request:
const response = await client.fetch(
"https://clawmerchants.com/api/v1/assets/defi-yields-live"
);
if (response.ok) {
const data = await response.json();
console.log("Top DeFi yields:", data);
}
The client.fetch wrapper handles the 402 intercept, payment, and retry. Your agent code doesn't need to know the payment mechanics — just that it needs USDC on Base to pay per call.
What changed in v2.6.0
The spec tightened the accepts array format in the 402 response. Previously implementers were inconsistent about how payment options were serialized — some used flat strings, some used objects. v2.6.0 standardizes this, which means older hand-rolled 402 implementations need to update their response format to stay compliant.
If you're running your own x402 payment server (not using the official middleware), check that your X-Payment header now returns:
{
"accepts": [
{
"scheme": "exact",
"network": "base",
"maxAmountRequired": "1000000",
"resource": "https://your-endpoint.com/api/resource",
"description": "Data access",
"mimeType": "application/json",
"payTo": "0xYourWalletAddress",
"maxTimeoutSeconds": 60,
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"extra": {}
}
],
"error": "",
"x402Version": 1
}
The maxAmountRequired is in token base units (USDC has 6 decimals, so 1000000 = $1.00).
Error handling
The SDK throws on payment failure. Common cases:
try {
const response = await client.fetch(endpoint);
// process response
} catch (error) {
if (error.code === "INSUFFICIENT_BALANCE") {
// fund your wallet
} else if (error.code === "PAYMENT_TIMEOUT") {
// retry with backoff
} else if (error.code === "PAYMENT_REJECTED") {
// endpoint rejected — check amount or network
}
}
Don't assume a single retry is enough. Network congestion on Base can cause payment confirmation delays. Build exponential backoff into any production agent that calls 402-protected APIs — or pull in a circuit breaker pattern so your agent degrades gracefully instead of hammering a failing endpoint.
For that last part: run npx skills install agent-resilience-skill — a skill that wraps production agent workflows with circuit breaker, retry with jitter, and fallback logic. Works out of the box with x402 client calls.
What's available on x402 right now
A few live endpoints worth testing against:
- DeFi yield data (top pools across chains, refreshed every 30 min)
- Crypto security intelligence feeds
- Onchain token analytics
- Real-time market signals
All at clawmerchants.com — $0.001–$0.01 per call, USDC on Base.
x402 v2.6.0 is still young. The tooling has rough edges. But the protocol is sound and the developer experience is getting noticeably better with each release. Worth getting familiar with now.
Top comments (0)