x402 Pay lets Drupal sell content and API calls to AI agents, and to people with a wallet, for USDC on Arc. It implements x402, the open protocol that puts the long-unused HTTP status 402 Payment Required to work: the site answers with a price, the client signs a payment, the site delivers. No accounts, no checkout, no card fees, payments of a fraction of a cent.
AI crawlers and agents already read your site. With x402 Pay they can pay for it.
Features
- A price field for any entity. Add x402 price to nodes, products or any fieldable entity. Each field sells one view mode (the full text, a summary…) at a price, with per-entity overrides and a price per translation.
- Agents pay, people browse. On the entity's own URL, agents get a 402 with the price while browsers still see the page. Every product also has its own URL, announced to agents with
Linkheaders. Buyers get clean Markdown of what the view mode shows. - Paid APIs. The payment gate service charges any controller per request, and settles only when the response is successful: a failed call is never charged.
- Discovery for agents.
/x402/discoverylists everything for sale in the format of Circle's Discovery API. For people, a Views filter and a price formatter. - Your rules at the time of sale. A
PriceEventlets code change the price, make it free, deny the sale or pick the seller's wallet; aDeliveryEventlets it answer with anything, e.g. the result of a paid service. - Settle your way. Through Circle's facilitator (keyless trial or API key), or with the site's own facilitator: Drupal sends the buyer's signed transfer on chain itself, from a gas wallet that pays only the gas (about 0.002 USDC per sale on Arc). Sales always go from the buyer straight to the seller.
- Money off the server. Sellers can be cold-wallet addresses with no key on the site, or seller keys can be swept to a cold wallet on cron.
- An audit trail. Every payment is logged with route, amount, payer and transaction hash.
Use cases
- Charge AI crawlers and answer engines for articles, research or data, while humans keep reading for free.
- Sell API calls (fact-checking, analysis, generation) to other agents, paid per call.
- Build a marketplace where each listing pays its own seller.
Post-installation
- Store your keys with the Key module using the Environment provider (never Configuration: it ends up in config exports).
- Go to Configuration → Web services → x402 Pay and choose how each network settles: Circle (trial or API key) or your own facilitator with a gas wallet.
- Add an x402 price field to an entity type: set the price, network, seller (a key or an address) and the view mode it sells.
- Try it:
node scripts/buy.mjs https://your-site/node/1is a buyer agent in one file that pays the 402 and prints what it bought.
Additional requirements
- Drupal 11.1+ or 12, PHP 8.3+ with the
gmpextension. - Key.
- Composer libraries:
kornrunner/keccak,kornrunner/secp256k1,league/html-to-markdown. - USDC on Arc for buyers; for the own facilitator, a gas wallet with a little USDC.
Recommended modules
- Wallet Auth: sign in with a wallet (SIWE), for people and agents, so purchases and prices can attach to an account.
Similar projects
We know of no other x402 module for Drupal. Payment gateways for Drupal Commerce charge people through a checkout; x402 Pay charges per request, without accounts, and works for agents.
Roadmap
- Drupal Commerce gateway: check out in USDC (
x402_pay_commerce). - ECA integration for the price rules (
x402_pay_eca). - More networks: other EVM chains and Solana.
- Smart-contract wallet signatures (ERC-1271) in the own facilitator.
Background
Built for Ombú, an open-source marketplace on Drupal where AI agents sell to people and to other agents. Development happens on GitHub; issues are welcome here on drupal.org.
Ask your assistant about x402 pay
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.0.0-beta1 | Pre-release | 11 | PHP ^8.3 | Oct 13, 2026 |