x402 Client Node
The x402 Client node is the core component for making payment-protected API requests in your n8n workflows. It automatically handles 402 responses, creates payments, and retries with payment proofs.
Overview
Section titled “Overview”The x402 Client node:
- Detects 402 Payment Required responses
- Automatically creates and signs payments
- Retries requests with payment proof
- Returns protected data to your workflow
- Supports configurable payment limits
- Works with all HTTP methods (GET, POST, PUT, DELETE)
Node Configuration
Section titled “Node Configuration”Wallet Source
Section titled “Wallet Source”Choose how to provide wallet credentials:
Saved Wallet (Recommended)
- Connect Wallet Manager once, wallet is saved
- Future executions use saved wallet automatically
- Perfect for scheduled workflows
Private Key (Reusable)
- Enter your private key directly
- Wallet reused across all executions
- Great for trigger-based workflows
From Wallet Manager Node
- Live connection to Wallet Manager
- Always uses latest wallet state
- Best for dynamic wallet management
Auto-Generate Per Node
- Generates unique wallet per node
- Requires funding each time
- Not recommended for production
Resource URL
Section titled “Resource URL”The URL of the x402-enabled API endpoint:
https://api.example.com/premium-datahttp://localhost:3000/webhook/my-apiHTTP Method
Section titled “HTTP Method”Select the HTTP method for your request:
- GET - Retrieve data
- POST - Send data
- PUT - Update resource
- DELETE - Remove resource
Request Body
Section titled “Request Body”For POST and PUT requests, specify the JSON body:
{ "query": "example", "limit": 10}Use n8n expressions for dynamic values:
{ "userId": "{{$json.id}}", "timestamp": "{{new Date().toISOString()}}"}Headers
Section titled “Headers”Add custom HTTP headers:
Name: X-API-Key
Value: your-api-key-here
Or use expressions:
Name: Authorization
Value: Bearer {{$json.token}}
Auto-Pay
Section titled “Auto-Pay”When enabled, the node automatically:
- Detects 402 responses
- Checks payment amount against limit
- Creates and signs payment
- Retries with payment proof
- Returns the protected data
When disabled, the node will fail with an error if payment is required.
Max Payment Amount (USDC)
Section titled “Max Payment Amount (USDC)”Safety limit to prevent overspending:
Development: 0.10 USDCProduction: 1.00 USDCHigh-value APIs: 5.00 USDCIf the API requires more than this amount, the node throws an error instead of paying.
Protocol Format
Section titled “Protocol Format”Official X-402 Protocol (Recommended)
- Standard x402 specification
- Signature-based payment proof
- No blockchain transaction needed (off-chain)
- Fast and efficient
Signed Transaction (Legacy)
- Pre-signed Solana transaction
- Compatible with custom implementations
- Can be settled on-chain
- Requires more setup
Output Data
Section titled “Output Data”The x402 Client node returns:
Successful Response
Section titled “Successful Response”{ "data": { // API response data }, "_x402Payment": { "amount": "0.01", "currency": "USDC", "recipient": "ABC123...", "sender": "9rKnvE7...", "network": "solana-devnet", "timestamp": "2024-01-15T10:30:00.000Z" }}Free Endpoint (No Payment)
Section titled “Free Endpoint (No Payment)”If the endpoint doesn’t require payment (returns 200 immediately):
{ "result": "data from API" // No _x402Payment field}Using the Output
Section titled “Using the Output”Access data in subsequent nodes:
Get API Data
Section titled “Get API Data”{ { $json.data; }}Get Payment Amount
Section titled “Get Payment Amount”{ { $json._x402Payment.amount; }}Check if Payment Was Made
Section titled “Check if Payment Was Made”{ { $json._x402Payment !== undefined; }}Get Transaction Timestamp
Section titled “Get Transaction Timestamp”{ { $json._x402Payment.timestamp; }}Common Patterns
Section titled “Common Patterns”Call Single API
Section titled “Call Single API”[Trigger] ↓[x402 Wallet Manager] ↓[x402 Client] - URL: https://api.example.com/data ↓[Process Data]Call Multiple APIs
Section titled “Call Multiple APIs”[Trigger] ↓[x402 Wallet Manager] ↓[x402 Client 1] Premium Data (0.01 USDC) ↓[x402 Client 2] Analytics (0.05 USDC) ↓[Merge Results]Conditional Payment
Section titled “Conditional Payment”[Trigger] ↓[x402 Wallet Manager] ↓[IF] Balance > 1 USDC? ├─ YES → [x402 Client] Call paid API └─ NO → [Send Alert] Low balanceMix Free and Paid APIs
Section titled “Mix Free and Paid APIs”[Trigger] ↓[HTTP Request] Free endpoint (no payment) ↓[x402 Client] Paid endpoint (with payment) ↓[Combine Data]Advanced Options
Section titled “Advanced Options”Show Transaction Details
Section titled “Show Transaction Details”Enable to include additional payment metadata in output:
{ "_x402Payment": { "amount": "0.01", "scheme": "exact", "resource": "/api/premium-data" // ... more details }}Clear Saved Wallet
Section titled “Clear Saved Wallet”Only for “Saved Wallet” mode. Clears the saved wallet so you can set up a new one.
Reset Wallet
Section titled “Reset Wallet”Only for “Auto-Generate” mode. Generates a new wallet for this node.
Troubleshooting
Section titled “Troubleshooting””No wallet data found”
Section titled “”No wallet data found””Problem: Client can’t access wallet
Solutions:
- Ensure Wallet Manager is connected (for “From Wallet Manager” mode)
- Check saved wallet exists (for “Saved Wallet” mode)
- Enter private key (for “Private Key” mode)
“Insufficient balance”
Section titled ““Insufficient balance””Problem: Not enough USDC or SOL
Solutions:
- Run Wallet Manager alone
- Check balances in output
- Fund wallet at faucets (devnet) or send funds (mainnet)
- Re-run workflow
”Payment exceeds limit”
Section titled “”Payment exceeds limit””Problem: API requires more than max allowed
Solutions:
- Increase “Max Payment Amount” if acceptable
- Use a different API
- Check API pricing documentation
”Payment rejected by server”
Section titled “”Payment rejected by server””Problem: Server didn’t accept payment
Solutions:
- Check console logs for details
- Verify network matches (both devnet or both mainnet)
- Ensure wallet has sufficient balance
- Try with “Official X-402 Protocol” format
Best Practices
Section titled “Best Practices”- Always set payment limits to prevent overspending
- Use Saved Wallet for production workflows
- Monitor balances regularly
- Test on devnet before mainnet
- Enable “Continue On Fail” for error handling
- Log payment details for auditing
What’s Next?
Section titled “What’s Next?”- Wallet Manager - Managing wallets
- Mock Server - Testing setup
- Error Handling - Handle failures
- Multiple Endpoints - Advanced patterns