Skip to content

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.

Three ways for an agent to find out that Open Accountant speaks x402:

  1. /.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
  2. Link headers — every response includes Link: </.well-known/x402>; rel="payment"; type="application/json"
  3. /x402/demo — always returns HTTP 402 with a valid payment-requirements body. $0.001 fixed price. Useful for sandbox testing and scanner detection.
RoutePrice rangeBought with
GET /content/skills/{slug}$0.05 – $0.25 per callx402 or Polar bearer
GET /content/chains/{slug}$0.05 per callx402 or Polar bearer
GET /x402/demo$0.001x402 only (sandbox)

Full price table lives at /.well-known/x402.

1. Agent GETs api.openaccountant.ai/content/skills/tax-prep
2. API returns HTTP 402 + accepts: [{ scheme, price, network, payTo }]
3. Agent signs a USDC transfer on Base and includes it in X-PAYMENT header
4. API verifies with the x402 facilitator and returns the skill markdown

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.

Terminal window
curl -i https://api.openaccountant.ai/x402/demo
HTTP/2 402
content-type: application/json
cache-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 in api/src/middleware/auth.ts
  • Scheme: exact via @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_ADDRESS secret on the Cloudflare Worker