x402 SDK
@dexterai/x402 adds payments to HTTP requests. A service responds with its price, your client pays, and the request returns the service's result. You can use the SDK to buy data and other services from code, or to collect payments for an API you run.
- The client requests the resource.
- The API returns HTTP 402 and its payment requirements.
- The client authorizes payment and retries with its proof.
- The API asks the facilitator to verify and settle the payment.
- The facilitator returns the settlement result.
- After successful settlement, the API returns the resource and receipt.
Make Payments
The client handles the payment exchange around your request. Your code supplies a funded wallet and spending limits.
- Pay From Node.js includes a complete script for buying a service with a
Solana keypair.
- For an app where a person approves payments through their browser wallet, follow Pay From a Browser.
Set Spending Limits before running repeated requests. Errors and Retries covers rejected payments and interrupted requests.
If you want an existing agent client to use your Dexter Account, start with OpenDexter. Dexter Connect provides account sign-in and approval flows for your own app.
Accept Payments
The seller middleware adds a price to an Express endpoint and verifies payment before your handler delivers the response. Choose the network, price, and receiving address for that endpoint.
Charge for an Endpoint walks through a working server. Once it is reachable, publish it on Indexter so people and agents can find it.
The Facilitator verifies payment authorizations and submits settlement. Its guide covers the public endpoint and network-specific configuration.
Use Track Settlement to connect a delivered response to the payment your account receives. For repeated purchases under one approval, see Tabs.
Networks and Package
The guides identify the wallet and network each example uses. Networks and Packages lists chain identifiers and the SDK releases used by the examples. Use Node.js 22 or newer and install the SDK with its Vault peer:
Last Updated: