Skip to main content
Every x402 payment involves exactly three roles. They can be three separate machines or three libraries in the same process, but the responsibilities do not blur.

Client

The client is whatever makes the initial HTTP request: a browser, a mobile app, a CLI, an agent runtime. It holds the buyer’s wallet (or delegates to one), signs the authorization entries that authorize the transfer, and attaches the resulting X-Payment header on retry. The client never broadcasts the transaction itself. That is the facilitator’s job. This split is what lets the facilitator sponsor Stellar fees on the client’s behalf without the client needing XLM.

Server (resource server)

The server is the API being paid for. It:
  1. Emits the initial 402 with PaymentRequired.
  2. On retry, hands the X-Payment payload plus the PaymentRequirements to the facilitator’s /verify endpoint.
  3. Only serves the protected resource after receiving a successful verification.
  4. Optionally calls /settle to finalize the payment on-chain (or lets the facilitator settle automatically).
The server does no cryptography and touches no blockchain. It knows how to describe a price and how to trust a facilitator’s answer.

Facilitator

The facilitator is the neutral third party that:
  • Verifies that the client’s signed payload matches the server’s PaymentRequirements.
  • Sponsors Stellar fees so neither buyer nor seller pays gas.
  • Submits the settled transaction to the Stellar network and returns the txHash.
  • (In this implementation) catalogs the endpoint into the Bazaar for discovery.
A facilitator is trusted with one thing: honestly reporting whether a payment cleared. It is not trusted with the payment itself. The scoped authorization signature means the facilitator cannot redirect funds or change the amount.

Why the split matters

It is tempting to imagine the server handling payment directly. It would be simpler, until the server has to sponsor gas, index every SEP-41 token it accepts, and stay online 24/7 to settle late transactions. The facilitator absorbs that operational surface and lets the server be a normal HTTP API that happens to charge for calls.

Where next

  • Facilitator goes deeper on what a facilitator does internally.
  • The Bazaar explains how servers get discovered by clients.
  • Self-Facilitation is for the (rare) case where you want to be your own facilitator.