N8N Integration
Connect your N8N workflows to X402-enabled APIs
🔄 N8N Integration
Connect your N8N workflows to X402-enabled APIs with automatic payment handling.
📺 Watch Video Tutorial: Build Your First N8N Workflow
OAuth 2.0 Method (Recommended)
The easiest way to connect N8N - no token copying required!
Step 1: Install N8N Node
Step 2: Create OAuth Credential
- In N8N, go to Credentials → Add Credential
- Search for "AgnicWallet OAuth2 API"
- Click "Connect my account"
- Authorize with your wallet and set spending limits
- You're done! Start using the credential in workflows
Step 3: Use in Workflow
Add the "AgnicWallet X402 Request" node:
API Key Method
For CI/CD pipelines or programmatic access.
Step 1: Generate Token
- Go to AgnicPay Dashboard
- Click "Connect App"
- Set spending limits and label
- Copy your API token:
agnic_tok_...
Step 2: Add to N8N
- In N8N, add "AgnicWallet API" credential
- Paste your API token
- Save and use in workflows
MCP Server Method
Connect N8N to the AgnicPay MCP server for access to all X402 tools.
Configuration
Add an MCP Client node in your n8n workflow:
The MCP server handles payment automatically!
Available MCP Tools
| Tool | Description | Parameters |
|---|---|---|
make_x402_request | Fetch data from X402 APIs with automatic payment | url, method, headers, body |
check_balance | Check wallet balance | network (optional) |
get_payment_history | View payment history | limit, startDate, network |
discover_apis | Browse available X402 APIs | category, search, maxPrice, sort |
fund_wallet | Get funding instructions | network (optional) |
Workflow Examples
Example 1: Automated Content Generation
This workflow calls an X402-enabled AI API every hour to generate content:
Example 2: Data Enrichment Pipeline
Example 3: Multi-API Aggregation
Token Management
Spending Limits
Protect your workflows with spending limits when generating tokens:
| Limit Type | Description |
|---|---|
| Per transaction | Maximum amount per API call |
| Daily limit | Total spend allowed per day |
| Monthly limit | Total spend allowed per month |
Multiple Tokens
Create separate tokens for different workflows:
| Token | Use Case | Daily Limit |
|---|---|---|
n8n-content-gen | Content generation | $20 |
n8n-data-enrich | Data enrichment | $50 |
n8n-reporting | Daily reports | $10 |
Error Handling
Common Errors
| Status | Error | Solution |
|---|---|---|
401 | Invalid token | Check your API token |
402 | Insufficient balance | Add USDC to your wallet |
429 | Rate limited | Add delay between requests |
500 | Provider error | Retry or check API status |
Error Workflow Pattern
Add error handling to catch payment failures:
Best Practices
1. Set Appropriate Limits
Match spending limits to your expected usage:
2. Use Descriptive Token Names
Name tokens by their purpose:
n8n-prod-content-2025n8n-staging-testn8n-analytics-daily
3. Monitor Usage
Check your usage regularly in the AgnicPay Dashboard.
4. Handle Errors Gracefully
Always add error handling nodes to catch payment failures and insufficient balance errors.