Skip to main content
Charge a known amount before returning an API response. In the Base USDC flow used here, x402 carries an EIP-3009 authorization through the HTTP 402 Payment Required handshake, then a facilitator verifies and settles it.

Demo

The demo above is mock only. If you want to see onchain demos on Vibenet, head to Base chain demos.
These examples target Base Sepolia (eip155:84532) and the public test facilitator. Confirm the facilitator’s supported network, asset, and settlement contracts before a live test.
1

Return Payment Requirements

The unpaid request receives a 402 response with the scheme, network, token, price, and recipient.
2

Sign and Retry

The buyer applies its spend policy, signs the advertised payment, and retries with PAYMENT-SIGNATURE.
3

Verify Before Work

Seller middleware verifies the payload before your protected handler runs.
4

Settle

The facilitator submits the payment and returns settlement details with the response.

Price a Fixed Route

An unpaid request receives 402; a valid paid retry reaches the handler and returns the resource once.
Treat the facilitator response and your own fulfillment record as separate checks. Make the route idempotent so a retried paid request cannot deliver the same one-time resource twice.

See Also

Settle Usage-Based Payments

Set the final charge after successful work.

Call a Paid Service

Add network, asset, and spend policy on the buyer.