x402 Payment Protocol
x402 is an open protocol for machine-to-machine
payments using the HTTP 402 Payment Required status code. It enables AI
agents to pay for services programmatically using USDC stablecoin.
x402 is live on api.openaccountant.ai today — every paid skill and
chain is gated behind @x402/hono payment middleware in addition to the
Polar.sh bearer-token path.
Discovery
Section titled “Discovery”Three ways for an agent to find out that Open Accountant speaks x402:
/.well-known/x402— machine-readable JSON: network, facilitator, pay-to, per-route prices- API (authoritative):
https://api.openaccountant.ai/.well-known/x402 - Site mirror:
https://openaccountant.ai/.well-known/x402 - Docs mirror:
https://docs.openaccountant.ai/.well-known/x402
- API (authoritative):
- Link headers — every response includes
Link: </.well-known/x402>; rel="payment"; type="application/json" /x402/demo— always returns HTTP 402 with a valid payment-requirements body. $0.001 fixed price. Useful for sandbox testing and scanner detection.
Protected Routes
Section titled “Protected Routes”| Route | Price range | Bought with |
|---|---|---|
GET /content/skills/{slug} | $0.05 – $0.25 per call | x402 or Polar bearer |
GET /content/chains/{slug} | $0.05 per call | x402 or Polar bearer |
GET /x402/demo | $0.001 | x402 only (sandbox) |
Full price table lives at /.well-known/x402.
How It Works
Section titled “How It Works”1. Agent GETs api.openaccountant.ai/content/skills/tax-prep2. API returns HTTP 402 + accepts: [{ scheme, price, network, payTo }]3. Agent signs a USDC transfer on Base and includes it in X-PAYMENT header4. API verifies with the x402 facilitator and returns the skill markdownVia MCP
Section titled “Via MCP”Agents connected to the Open Accountant MCP server can also invoke paid content as MCP tools:
get_skill_content({ slug })get_chain_content({ slug })
When called without auth these return an isError result containing a JSON
body with code: 402, the payment_requirements, and a pointer to the REST
endpoint for clients that need the real X-PAYMENT exchange.
Example — Demo Endpoint
Section titled “Example — Demo Endpoint”curl -i https://api.openaccountant.ai/x402/demoHTTP/2 402content-type: application/jsoncache-control: no-store
{ "x402_version": 2, "error": "payment_required", "resource": "https://api.openaccountant.ai/x402/demo", "accepts": [{ "scheme": "exact", "price": "$0.001", "network": "...", "payTo": "0x..." }], "facilitator": "https://x402.org/facilitator"}- Middleware:
@x402/hono— applied inapi/src/middleware/auth.ts - Scheme:
exactvia@x402/evm/exact/server - Network: Base (Sepolia in dev, Base mainnet in production)
- Facilitator:
https://x402.org/facilitator(public) - Pay-to address:
X402_PAY_TO_ADDRESSsecret on the Cloudflare Worker
Related
Section titled “Related”- API Authentication — bearer + x402 dual-auth
- MCP Server — invoke paid content as MCP tools
- x402 spec