Skip to main content
For AI agents, autonomous services, or any client that needs to pay for an API or piece of content, x402 turns a 402 Payment Required response into a signed Hedera transfer. The client does not need its own fee-paying node: a facilitator covers the network fee and submits the transaction.

Register the Hedera scheme

Install and import the client packages, then register the exact scheme with a signer for your account:
client.ts

Make a paid request

Once the scheme is registered, requests to x402-gated endpoints are handled automatically:
  1. The client calls the resource (for example, GET /weather) without any extra headers.
  2. The server replies with 402 Payment Required and the PaymentRequirements, including the facilitator feePayer.
  3. The client builds, signs, and Base64-encodes a TransferTransaction to the payTo account.
  4. The client resubmits the request with the PaymentPayload in the X-Payment header (or equivalent).
You can also use the lower-level pay helpers if you want explicit control over signing and retries.

Requirements

  • The client account must hold the asset being paid (HBAR or the relevant HTS token).
  • For HTS tokens, the client account must be associated with that token.
  • Use a facilitator that advertises the Hedera network you are paying on.

Further reading

Hedera's exact scheme

Message shapes, assets, and safety checks.

Accept x402 on Hedera

Add payment gating to a resource server.