Introduction
An HTTP 402 payment protocol for API monetization using Stripe. Inspired by x402, but built on traditional credit card rails instead of blockchain settlement.
Clients and servers negotiate payment via HTTP headers. No signup, no API keys, no OAuth. A client with a credit card can pay for any stripe402-enabled API on the first request.
What is stripe402?
stripe402 turns the HTTP 402 status code — reserved since 1997 but never standardized — into a practical payment protocol. When a client requests a paid resource, the server responds with 402 and a machine-readable description of the price and how to pay. The client tokenizes a card via Stripe, retries with a payment header, and the server charges the card, credits a balance, and serves the resource.
Subsequent requests use a client ID (derived from the card fingerprint) to deduct from the credit balance — no payment until credits run out.
Features
No signup, no API keys, no dashboards — the payment is the authentication
Credit card payments via Stripe
Sub-cent pricing via a credits system (1 unit = 1/10,000 of a dollar)
AI agents can discover and pay for APIs without human setup
Redis and PostgreSQL persistence backends included
Express middleware included; framework-agnostic core makes it easy to add others
Packages
@stripe402/core
Protocol types, header encoding, HMAC identity, error types
@stripe402/server
Stripe integration, Redis and PostgreSQL stores
@stripe402/express
Express middleware for payment-gated routes
@stripe402/client-axios
Axios interceptor for automatic 402 handling
@stripe402/client-fetch
Fetch wrapper for automatic 402 handling
Quick Links
Getting Started — install and run in 5 minutes
Protocol Overview — how the payment flow works
Package Reference — detailed API docs for each package
Guides — step-by-step tutorials
Configuration Reference — all settings and options
Last updated