How Dhali Supports the x402 Payment Protocol for Pay-Per-Request APIs
The x402 payment protocol is an emerging open standard that enables payments directly inside HTTP requests. Instead of relying on accounts, API keys, subscriptions, or traditional billing systems, a server can respond with HTTP 402 (Payment Required) and ask the client to attach a signed payment payload in the request headers. Once payment is verified, the server returns the requested resource. (Coinbase Developer Docs)
This model enables machine-native payments for APIs, allowing applications, agents, and services to pay programmatically for data, compute, or services.
Dhali supports this model and provides infrastructure that makes x402 payments practical for high-frequency API usage.
Importantly, Dhali has been embedding cryptographic payments directly into HTTP headers for several years as part of its API monetisation infrastructure. This aligns closely with the philosophy behind x402: replacing traditional authentication mechanisms with verifiable payments attached to every request.
What Is the x402 Payment Protocol?
The x402 protocol activates the long-reserved HTTP 402 Payment Required status code to allow servers to request payment before returning a resource. (x402)
In a typical x402 flow:
- A client sends a normal HTTP request to an API.
- The server responds with HTTP 402 Payment Required and payment instructions.
- The client creates a signed payment authorization using their wallet.
- The client retries the request with the payment payload attached in a header.
- The server verifies the payment and returns the requested resource. (x402)
This design allows APIs to move from authentication-based access control to payment-based access control, enabling real-time micropayments for services.
Using Dhali as an x402 Facilitator
Dhali can operate as an x402 facilitator, providing payment verification infrastructure for APIs that want to accept programmatic payments.
In this model:
- clients attach a signed x402 payment payload to their request
- the resource server verifies the payment through Dhali
- the API returns the requested response once payment is confirmed.
This allows developers to integrate pay-per-request APIs without building their own blockchain payment infrastructure.
A full guide for resource servers integrating Dhali’s x402 support is available here:
https://dhali.io/docs/x402-support/
High-Frequency x402 Micropayments
Many x402 implementations settle payments directly on blockchain networks. While secure, this approach can introduce latency and transaction fees.
Dhali instead applies x402 using blockchain payment channels, enabling payments to be authorized off-chain and settled later.
This approach allows API payments to occur:
- with very low latency
- at high throughput
- without incurring a blockchain transaction fee per request.
The result is an x402 infrastructure capable of supporting real-time API monetization at internet scale.
Performance Comparison: Off-Chain vs On-Chain x402
| System | Latency | Throughput | Cost per call (1¢ API) |
|---|---|---|---|
| Off-chain x402 (Dhali) | ~30 ms | 10000+ TPS | $0.0002 |
| On-chain x402 (Ethereum) | ~12 s | ~22 TPS | ~$0.01 |
| On-chain x402 (Base) | ~2 s | ~100 TPS | ~$0.001 |
Multi-Chain x402 Payments
Dhali’s x402 implementation is multi-chain, allowing APIs to accept payments across several blockchain ecosystems.
Supported assets include:
- ETH
- XRP
- USDC
- RLUSD
This allows API providers and clients to interact through a single x402 payment interface while choosing the network or asset that best fits their application.
See Dhali’s x402 Payments in Action
You can try the live x402 demo on the Dhali website:
The demo shows how developers can generate payment signatures, send API requests, and observe x402 payments being processed in real time.
The Future of API Monetization
The x402 protocol brings payments directly into the HTTP request-response cycle of the web. By embedding payments into standard web requests, developers can build machine-to-machine payment systems, pay-per-request APIs, and real-time digital services without subscriptions or billing infrastructure.
Dhali builds on this idea by providing infrastructure that enables high-frequency x402 micropayments across multiple blockchain networks.
As API-driven applications and AI agents continue to grow, x402-based API payments are likely to become an increasingly important part of the internet’s economic layer.