The Nevermined x402 programmable extension
Nevermined extends x402 with a smart-account-friendly scheme so the payment payload can authorize programmable settlement (credits/subscriptions/PAYG) instead of only an ERC-20 transfer.Subscriber flow (client side)
Step 1: Discover payment requirements (HTTP 402)
When calling a protected endpoint, the server returns a402 Payment Required response and includes the payment requirements (plan/agent binding, maximum amount, network, scheme).
- TypeScript
- Python
Step 2: Build the x402 payment payload
The client creates a payment payload that encodes the allowed permissions (for example, a session-key capability scoped to a plan/agent and a spend cap).- TypeScript
- Python
Step 3: Retry request with payment header
The payment payload is sent in-band with HTTP (commonly via thePAYMENT-SIGNATURE header).
- TypeScript
- Python
Resource server flow (API/agent side)
Step 1: Return 402 when payment is missing
If the payment header is not present, respond with402 plus the payment requirements you accept.
- TypeScript
- Python
Step 2: Verify with the facilitator
Decode the payment payload and ask the facilitator to verify it (including simulating any allowed on-chain actions).- TypeScript
- Python
Step 3: Execute Workload
Step 4: Settle Payment
- TypeScript
- Python
Complete Request Lifecycle
Error Handling
| Error | HTTP Status | Cause |
|---|---|---|
| Missing payment header | 402 | No PAYMENT-SIGNATURE header |
| Invalid signature | 402 | Signature verification failed |
| Insufficient balance | 402 | User needs to purchase more credits |
| Expired session | 402 | Session key has expired |
| Settlement failed | 500 | On-chain transaction failed |