Menu

1 / 2

AI Agents Can Now Pay for APIs Automatically — No Credit Cards, No OAuth

DEV Community·ShinyDapps·6 months ago
#awHX2FwQ
#ai#mcp#bitcoin#l402#agent
Reading 0:00
15s threshold

The Friction Nobody Talks About

You're building an AI agent. It needs to call a premium API — weather forecasts, financial data, compute resources, whatever.

How does it pay?

Credit card → requires a human to approve, link a card, and manage billing

API key → requires pre-registration, someone to provision access, a dashboard to manage

OAuth → identity, not payment; you still need billing on top

Every option requires human intervention before the agent can act. That's not autonomous.

HTTP 402: The Protocol That Was Always Meant for This

RFC 2616 reserved status code 402 Payment Required back in 1999 — "for future use." That future is now, and it's called the L402 protocol .

Here's what it looks like from the agent's perspective:

Agent → GET /api/premium-data Server ← 402 Payment Required WWW-Authenticate: L402 invoice="lnbc10n1..."

Agent pays Lightning invoice (1 sat, ~$0.001) Agent → GET /api/premium-data Authorization: L402 <macaroon>:<preimage> Server verifies: SHA256(preimage) == paymentHash ✓…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.