x402 Protocol
The x402 protocol enables machine-to-machine payments on the web using HTTP status code 402. Invoica extends x402 with financial compliance — invoicing, tax calculation, budget enforcement, and settlement detection.How x402 Works
The x402 protocol uses HTTP to negotiate and execute payments between AI agents and resource servers:x402 Headers
The protocol uses two key headers:PAYMENT-REQUIRED (Server → Client)
When a server requires payment for a resource, it responds with HTTP 402 and includes thePAYMENT-REQUIRED header. This header contains the payment details the agent needs:
- price — Amount to pay
- token — Token to use (e.g., USDC)
- recipient — Wallet address to send payment to
- network — Blockchain network (e.g., base, ethereum, solana)
PAYMENT-SIGNATURE (Client → Server)
After the agent completes the payment, it retries the original request with thePAYMENT-SIGNATURE header containing the signed payment proof:
Standard x402 Flow
With Invoica Middleware
Invoica sits as a transparent proxy between the agent and the resource server. When it intercepts a 402 response, it generates an invoice, calculates applicable taxes, and tracks the settlement:Invoice Metadata Headers
In addition to the standard x402 headers, Invoica uses custom headers to capture invoice metadata from AI agents:What Invoica Adds
| Capability | Standard x402 | With Invoica |
|---|---|---|
| Payment | Yes | Yes |
| Invoice Generation | No | Automatic |
| Tax Calculation | No | Multi-jurisdiction |
| Budget Enforcement | No | Per-agent limits |
| Settlement Detection | Basic | Dual (poll + event) |
| Audit Trail | No | Full ledger |
| PDF Delivery | No | Automatic |
Supported Networks
Invoica supports settlement detection on:- Ethereum Mainnet — ERC-20 token transfers (tested on Sepolia)
- Base Mainnet — Low-cost L2 transactions with EIP-3009 support
- Solana Mainnet — SPL USDC token transfers
- Arbitrum — Optimistic rollup settlements