# Gateway: charge for any API in one call

Put an existing HTTPS API behind x402 without changing a line of it. You get a URL here; a buyer calls it, pays your price in USDC, and the request is forwarded to your API with the response handed back. The money goes straight to your wallet.

## Start

```
POST https://pay.neuronto.com/credits/account                          # a key, free, if you have none
POST https://pay.neuronto.com/gateways
Authorization: Bearer <your key>
Content-Type: application/json

{"name": "Weather API", "upstream": "https://api.example.com",
  "price_usd": 0.01, "pay_to": "0xYourChecksummedAddress",
  "description": "Current conditions for any city"}
```

The answer carries your gateway URL, `https://pay.neuronto.com/g/<id>`. `GET https://pay.neuronto.com/g/<id>/v1/now?city=Oslo` is forwarded to `https://api.example.com/v1/now?city=Oslo` once paid.

## How a call works

1. Unpaid, the gateway answers 402 with your terms, in the header the official x402 clients read first.
2. The buyer's client signs and retries. The payment is verified before your API is called.
3. Your API answers. Only if it succeeded is the payment settled; a failed call costs the buyer nothing.
4. The buyer gets your response with the settlement receipt attached.

Your API receives `X-Neuronto-Gateway: <secret>` on every forwarded call, so it can refuse traffic that did not come through the gateway, and `X-Neuronto-Payer` with the paying address.

## Price

- **1,000 paid calls a month free**, per owner.
- After that, **1% of each payment, at least 0.5 credits ($0.0005)**, charged to your prepaid [credits](https://pay.neuronto.com/credits), never taken out of your buyers' payments.
- If your free calls are used and your credits run out, the gateway turns buyers away **before** they pay, never after.

## Manage

```
GET    https://pay.neuronto.com/gateways              # yours, with this month's usage
PATCH  https://pay.neuronto.com/gateways/<id>         # price_usd, upstream, pay_to, name, description, active
```

## Rules it keeps

- **Non-custodial.** Payments move from the buyer's wallet to `pay_to`. Nothing is held here.
- **Discovery is earned, not bought.** A gateway resource enters the [catalogue](https://pay.neuronto.com/discovery/resources) the way any paid resource does, by being paid for, and is offered to the Neuronto ARD registry, which ranks it like any other entry. The fee is for the proxy, never for placement.
- **Safe forwarding.** https upstreams on public addresses only, connected to the address that was checked, no redirects followed, cookies and payment headers never forwarded, responses up to 10 MB.
