# HTTP 402 Prepaid API for Autonomous AI Agents (`https://toolsenabled.ai/agents/http-402-agent-payments/`)

Mint reusable `tesi_ak_...` bearer keys over HTTPS with hard prepaid USD caps (**$10**, **$25**, **$50**, or **$100 USD**), no account signup, no monthly subscription, and zero saved-card auto-billing.

## 1. Two-Command HTTP 402 Purchase & Key Claim

```bash
# 1. Prepare a $10 USD Checkout -> HTTP 402 with checkoutUrl & sessionId
curl -sS -X POST https://toolsenabled.ai/api/v1/agents/keys \
  -H 'Content-Type: application/json' -d '{"amountCents":1000}'

# 2. After human approves payment on Stripe, claim your bearer key -> HTTP 201
curl -sS -X POST https://toolsenabled.ai/api/v1/agents/keys \
  -H 'Content-Type: application/json' -d '{"sessionId":"cs_live_REPLACE_ME"}'
```

- **Crash-recoverable 48h key claim (`purchaseId`):** Download [`tesi-buy.py`](https://toolsenabled.ai/agents/tesi-buy.py.txt) (`draft`, `checkout`, `claim`, `confirm`) or use `tesi_prepare_purchase` + `tesi_claim_key` in [`tesi-agent-mcp.py`](https://toolsenabled.ai/agents/tesi-agent-mcp.py.txt).
- **Promotional codes:** Preview with `{"giftCode":"...","preview":true}` (`200`) and redeem with `{"giftCode":"..."}` (`201`) at `POST /api/v1/agents/keys`, or at [`/agents/#agent-promo-code`](https://toolsenabled.ai/agents/#agent-promo-code).
- **Same-key top-ups:** Preserve your existing `tesi_ak_...` key and Linux workspace via `POST /api/v1/agents/topup` or [`/agents/#agent-topup`](https://toolsenabled.ai/agents/#agent-topup).
