Overview
n8n is a workflow automation platform that can orchestrate API calls, including x402 payments. You can build workflows that order prepaid cards, send payments, and poll for results — all without writing code.Approach
n8n doesn’t have a native x402 node, so you’ll use the HTTP Request node with a custom pre-request script that handles the x402 payment signing.Prerequisites
- An n8n instance (cloud or self-hosted)
- A funded agent wallet with USDC on Base (Locus or Sponge)
- Your wallet’s private key stored as an n8n credential
Workflow setup
1. Store your wallet key
In n8n, go to Credentials and create a new Header Auth credential. Store your private key securely — you’ll reference it in the Code node.2. Build the workflow
Create a workflow with these nodes:Code node: x402 payment signer
Use a Code node to handle the x402 flow. This node:- Makes the initial request to get the 402 response
- Signs the payment with your wallet
- Returns the signed
X-PAYMENTheader
HTTP Request node
Configure the HTTP Request node to replay the request with theX-PAYMENT header from the previous Code node.
3. Poll for card details
Add a Loop node that callsGET /get-card-data?card_id=X with the Bearer token every 3 seconds until status is "ready".
Example workflows
Order a card on schedule
Send a payment from a form
Tips
- Use n8n’s Wait node for polling delays instead of loops with no delay
- Store tokens from
/authin n8n’s static data so they persist across executions - Use the IF node to check
statusfield when polling for card details - Set up Error Trigger workflows to handle payment failures
Since n8n’s Code node runs in a sandboxed environment, you may need to use a
self-hosted n8n instance to install the
@x402/axios npm package for full
x402 support.