Skip to content

Pay x402 APIs from an n8n workflow

n8n workflows can pay for an x402-gated API and keep going with PipRail, the missing “pay two cents and continue” step for automations and AI-agent workflows. It’s a community node that settles straight from your own wallet, budget-bound and verified on your own RPC: no facilitator, no fee.

Like the elizaOS plugin (and unlike OpenClaw / Hermes, which wire the @piprail/mcp server), n8n gets a native node, @piprail/n8n-nodes-piprail, that wraps the published @piprail/sdk directly. The SDK is bundled into the package, so it installs with zero runtime dependencies, and the wallet key is read only from the encrypted n8n credential, never from the environment or filesystem.

The node sets usableAsTool: true, so an n8n AI Agent node can call it directly as a budget-bound payment tool.

In your self-hosted n8n: Settings → Community Nodes → Install, then enter:

@piprail/n8n-nodes-piprail

Add a PipRail API credential:

FieldRequiredDefaultPurpose
Private KeyyesnoneHex key (0x…) of the wallet payments are sent from. Stored as an encrypted n8n credential; read only from there.
ChainnobaseEVM chain to pay on, e.g. base, ethereum, arbitrum, optimism, polygon, bnb, avalanche.
RPC URLnononeOptional custom RPC. Leave blank to use the SDK default for the chain.

One PipRail node, four operations:

OperationWhat it doesMoves money?
Pay URLFetch a URL; if it returns HTTP 402, pay within the spend caps and return the unlocked responseyes
Plan PaymentRead-only: can the wallet afford it, and on which railno
QuoteRead-only: the price of a gated URLno
Estimate CostRead-only: price plus a gas estimate in the native coinno

Pay URL returns { status, ok, paid, transaction, receipt, body }. paid/transaction reflect a real on-chain settle (even when the merchant emits no receipt), and receipt is the verifiable receipt when one is provided. It pays with schemes: ['onchain-proof', 'exact'], so it also settles standard x402 servers.

On the Pay URL operation, open Spend Caps:

CapMaps toPurpose
Max Per Paymentpolicy.maxAmountCeiling for any single payment
Max Totalpolicy.maxTotalLifetime ceiling for the whole execution. It accumulates across every input item (one shared ledger), so feeding N items can’t spend N × the cap

Both are checked before any on-chain send, so the workflow cannot overspend. Full policy surface: Payment policy.

Point the node at the live demo (0.01 USDC on Base):

  1. Quote https://piprail.com/x402/demo → the price, no funds moved.
  2. Pay URLstatus 200, paid: true, and the on-chain transaction.
  3. Cap holds. Set Max Total below the price and confirm the node is declined, no funds moved.

The runnable node lives at integrations/n8n/piprail/: npm run build, npm run typecheck, npm run smoke, npm run lint (passes n8n’s own n8n-node lint). It’s proven on Base mainnet by driving the node’s own execute(): a real on-chain settle, with the maxTotal cap enforced across multiple items.