Agentic Payments
AI agents can discover and pay for stripe402 APIs without human intervention.
The problem
Today, when an AI agent discovers a useful API, it can't use it without a human creating an account, generating API keys, configuring billing, and providing the keys to the agent. That breaks autonomous workflows.
How stripe402 works for agents
With stripe402, an agent can:
Discover an API endpoint
Read pricing from the machine-readable 402 response
Pay with a pre-authorized card (via a stored PaymentMethod ID)
Use the resource immediately
Keep making requests against its credit balance
No human in the loop. The agent treats payment as just another HTTP header.
Implementation
All you need: card details
An agent does not need a Stripe account. The only prerequisite is a credit card (number, expiration, CVC). When a stripe402 API responds with 402, the response includes the server's publishable key — the agent uses that key to tokenize its card on the fly.
Complete agent setup
Budget controls
Agents should have spending policies:
How the protocol helps agents
The 402 response is machine-readable, so agents can parse it without any prior knowledge of the API:
After the first payment, the agent receives a clientId and uses credits for subsequent requests. No repeated charges, just a lightweight header on each request.
The same credit card works with any stripe402-enabled API. Each provider's publishable key creates a separate PaymentMethod, but the agent only ever needs its card details.
Security considerations
Store card details securely (environment variables, encrypted config)
Set spending limits — agents should have daily/monthly budgets
Monitor usage: which APIs the agent is paying for and how much
Use Stripe test mode during development
PCI scope: agents handling raw card numbers are in SAQ-D scope; card details go directly to Stripe, never to the API server
Cache PaymentMethod IDs — the
pm_...ID can be reused for subsequent top-ups on the same server
See Creating Payment Methods for all options including caching strategies.
Last updated