Developers

What is HTTP 402 Payment Required?

402 is the status code for “pay, then retry.” For APIs and agents it’s a handshake—not a checkout page and not a paywall overlay.

Payment Required as a glowing gateway — the API pay handshake without a form.

HTTP 402 has been reserved for decades. Most of the web ignored it because cards need a form. Agents don’t have a form. They have a status code, a challenge, and a retry. That’s why 402 is suddenly a product, not trivia.

The loop

  1. Client calls the route.
  2. Server returns 402 with how to pay (amount, rail, who).
  3. Client settles.
  4. Client retries with proof.
  5. Server runs the handler and returns the payload.

If step two is “redirect to a hosted page,” you don’t have 402. You have checkout with extra headers. If step four is a cookie from a human login, you don’t have an agent rail.

Payment Required is the handshake. The form is the fallback for humans who still want one.

402 vs what you already have

  • API keys — identity and quota, not per-call settlement
  • Stripe Checkout — human UI, swipe economics
  • Prepaid credits — accounting after the fact
  • 402 — this request, this price, then the work

Snippet-shaped mental model

Middleware on the route you already run. Unpaid → 402. Paid → JSON. That’s express-vybe-402. The buyer is a Vybe balance with policy—not a PAN in a prompt.

Read this, then wrap one route. The playground is your local logs: unpaid, paid, once. Collect can list the same SKU for humans. Same ledger.

Keep going

Get the next note. Then ship the product.

One email when we publish. Meanwhile: join the waitlist and put the next payment on your balance.

Join the waitlist
More notes

Keep reading, or open the app.