# Nanotoll API - account, keys, billing ## Overview api.nanotoll.dev is the single public REST API for nanotoll.dev. This host serves the account side; the compress endpoint lives under /v1 on the same host, and the MCP server at https://mcp.nanotoll.dev exposes the same operation as a tool. It owns account registration, key issuance, trial keys, account state (tier, credit, expiry, usage), balance checks and payment history, plus the public discovery and verification endpoints under /v1 (limits, receipt verification). Credit terms (deposit minimum, trial grant) are published on the compress host at GET /v1/limits. Revenue metrics are internal (dashboard only). One API key, one balance. Compress is the only billed endpoint; the MCP server also serves check_balance, which reads that same account balance for free. ## Endpoints ### POST /api/v1/register Self-register - returns an API key and a USDC funding address. No auth, no body. Call this first: the compression service (MACS, via REST or the MCP server) bills against the balance created here. Response: ```json { "api_key": "macs_...", "funding_address": "0x...", "chain": "base", "token": "USDC", "credit_balance": 0.0, "legal_notice_version": "...", "refund_policy_url": "https://nanotoll.dev/legal/refund/", "withdrawal_notice_url": "https://nanotoll.dev/legal/refund/#2-right-of-withdrawal-for-consumers-eu-eea-and-uk" } ``` The last three fields carry the refund policy and, for EU/EEA and UK consumers, the 14-day withdrawal notice. Store them with the response: that copy is the notice we are required to deliver in a durable medium. Errors: 429 (rate limit on register), 500 (server error). ### POST /api/v1/trial Free trial key: issued in a single call, no auth, no request body, no email. One free key per IP (subject to a service-wide daily cap). The response includes a Base USDC funding address: fund it to upgrade the trial key to a permanent paid key with no re-registration. Response (201): ```json { "api_key": "macs_...", "funding_address": "0x...", "chain": "base", "token": "USDC", "key_type": "free", "credit_balance": 0.1, "expires_at": "2026-11-25T10:00:00Z" } ``` Errors: 409 (this IP already had a free key), 429 (rate limit or the daily trial cap; retry after the returned retry_after seconds), 500. ### Credit terms The smallest credited deposit and the free-trial grant are published on the compress host: GET https://api.nanotoll.dev/v1/limits (fields min_deposit_usd and free_trial). Served from the same configuration the deposit watcher enforces and the trial issuer grants, so the numbers there cannot drift from behaviour. ### GET /api/v1/balance Check current credit balance. Requires API key, free. Response: ```json { "credit_balance": 0.5, "funding_address": "0x...", "chain": "base", "token": "USDC" } ``` Authentication: Bearer token in Authorization header. Errors: 401 (invalid key), 500 (server error). ### GET /api/v1/account Full account state for this key. Requires API key, free. Response: ```json { "key_type": "free", "tier": "trial", "key_status": "active", "internal": false, "credit_balance": 0.5, "funding_address": "0x...", "chain": "base", "token": "USDC", "expires_at": "2026-11-12T10:00:00Z", "trial_inflight_limit": 1, "usage": { "charged_requests": 0, "charged_chars": 0, "charged_amount": 0.0, "refunded_requests": 0 }, "limits_endpoint": "/v1/limits" } ``` tier is "trial" (free trial grant) or "paid" (funded key). expires_at is null for keys that never expire. key_status is derived on read: "active", or "expired" for a free key past its expires_at. Expiry applies to trial keys only - a credit_balance of 0 is an insufficient balance (402), not a dead key. trial_inflight_limit is 1 for trial keys, null otherwise. Service-wide caps and per-mode prices are public at GET /v1/limits (no auth). Authentication: Bearer token in Authorization header. Errors: 401 (invalid key), 500 (server error). ### GET /api/v1/payments Check recent onchain payment history. Requires API key, free. Response: ```json { "payments": [ { "tx_hash": "0x...", "log_index": 1, "amount": 5000000, "chain": "base", "confirmations_seen": 12, "status": "confirmed", "created_at": "2026-08-25T10:00:00Z" } ], "count": 1 } ``` Authentication: Bearer token in Authorization header. Errors: 401 (invalid key), 500 (server error). No deposits -> 200 with an empty payments array and count 0. ### GET /openapi.json OpenAPI 3.0 specification. ### GET /health/live Returns {"status":"ok"} (liveness - process alive, runtime responsive). ### GET /health/ready Returns {"status":"ready"} or 503 (readiness - DB + migrations + RPC). ## Pricing No charge for registration, balance, or payment queries. TOLL is the billing gateway - other services bill through it. ## Auth & Onboarding 1. Call `POST /api/v1/register` on the API (https://api.nanotoll.dev) - receive an API key and a USDC funding address. Or claim a free trial key via `POST /api/v1/trial` (no body, 1 per IP). 2. Send USDC (Base L2) to the funding address. Credits appear after 12 block confirmations. 3. Use the API key as Bearer token in the Authorization header for all billed services. 4. No accounts, no web signup. Agents only. ## Chaining /api.nanotoll.dev is the single public REST API: account, key and balance on this host; /v1/limits (live caps and prices), POST /v1/receipts/verify (receipt notary) and POST /v1/compress are public. /v1/compress needs an API key and is billed per call; its contract - modes, caps, prices, receipt fields - is published at https://macs.nanotoll.dev/openapi.json. One API key, one balance. The per-service hosts of earlier versions are retired. ## Links - API: https://api.nanotoll.dev/llms.txt - MCP server: https://mcp.nanotoll.dev - Product site: https://nanotoll.dev - Status (planned): https://status.nanotoll.dev