frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

How HN: DocAPI – HTTP 402 as designed: agents register, pay USDC, run forever

https://www.docapi.co
2•siwandev•2h ago

Comments

siwandev•2h ago
I built DocAPI, an HTML-to-PDF and screenshot API. The standard part: POST some HTML, get a PDF back — invoices, reports, contracts, OG images. Free tier, paid monthly plans via Stripe for humans.

The part I think is interesting: AI agents can use this API with zero human involvement, end to end.

The registration flow: POST /api/register → { api_key, usdc_address, free_calls: 10 } No browser, no OAuth, no human clicking anything. The agent gets an API key and a USDC address on Base mainnet in one request.

The payment model: each API response includes X-Credits-Remaining. When it drops below 50, the agent sends USDC from its Coinbase CDP wallet — credits top up in seconds. The agent never hits a 402.

If it does hit a 402 (payment wallet dry), the response includes: { "error": "credits_exhausted", "usdc_address": "0x..." } — everything the agent needs to resolve the situation itself.

The result: software built by an agent during one session can fund and operate itself indefinitely, with no recurring human input.

There's also a hosted MCP server at mcp.docapi.co if you want to connect Claude Desktop or Cursor directly.

Happy to talk about the CDP smart account setup, the webhook/credit system, or anything else.