Skip to Content
px402Devnet
Getting started

Charge for your API

Put your HTTPS API behind the px402 gateway and set a price per route.

You keep running your API. px402 answers the 402, checks the payment, and forwards only paid calls to you. Your identity is a Turnkey sub-organization: its root API key signs every platform call. There are no passwords and no px402 API keys.

Before you start

The CLI imports an existing Turnkey root API key; it cannot create one. An admin reviews your organization, provider and routes before they go live. Devnet only.

Import your identity

px402 identity init --sub-org <uuid> --user <uuid> --import
px402 me

Create an organization

px402 provider org create --slug acme --name "Acme"

Prove your domain

px402 provider domain add api.acme.example --org <orgId>

Add the printed TXT record, then check it:

px402 provider domain check <domainId>

Create the provider

px402 provider create --org <orgId> --slug acme --name "Acme API" --domain <domainId> --upstream https://api.acme.example/v1
px402 provider secret rotate --provider <providerId>

The proxy secret is shown once. Your API must refuse any request that does not carry it in X-Px402-Proxy-Secret.

Set up the receiver

px402 provider receiver import --provider <providerId>

Compare the four words it shows, then confirm. This gives px402 the viewing seed that lets it check payments to you. The seed cannot spend.

Describe your routes

Save this as routes.json. Prices are base units: 10000 is 0.01 USDC.

{
  "version": 1,
  "routes": [
    { "key": "weather", "method": "GET", "path": "/weather/:city", "price": 10000, "asset": "USDC", "description": "Current weather" }
  ]
}
px402 provider routes import routes.json --provider <providerId>
px402 provider routes submit --provider <providerId>

After approval, a route is live at https://acme.devnet.x402.px402.tech/weather/<city> and listed in the catalog.

Next: what your API receives and what you can see about payers.