x402 - dev focused - web banner

Build pay-per-use APIs and agent payments with x402

Turn any HTTP resource into a paid endpoint using a simple, standard request-response flow. Designed for APIs, AI agents, and machine-to-machine (M2M) payments.

Why Algorand is the best fit for x402 developers

x402 is payment-rail agnostic by design, but some networks fall short of its core requirements. Algorand stands out by delivering production-ready performance across key dimensions:

  • Deterministic finality that keeps verification inside synchronous HTTP flows.

  • Low transaction fees that make true micropayments viable.

  • Stablecoin support for predictable, per-request pricing.

  • Reliable performance for high-frequency, machine-to-machine traffic.

  • Native atomic grouping to enable more complex payment instructions

These properties make Algorand a strong settlement layer for pay-per-use APIs and agent payments.


 

The roles in an x402 system

x402 separates responsibilities to keep systems modular and composable.

Merchant - the economic actor offering something of value. 

The merchant defines pricing, payment terms, and access rules. In simple systems, the merchant and resource server may be the same entity. In more complex systems, they are often separate.

Resource server - the HTTP endpoint that is being protected gates access behind payment. 

The resource server responds with HTTP 402 when payment is required and serves the resource once payment is verified.

Facilitator - the coordination layer between HTTP services and the payment rail.

The facilitator verifies settlement, enforces pricing and access rules, and prevents replay or double-spend attempts.

This separation allows applications to stay focused on their core logic while payments remain abstracted.

How the x402 request flow works

At a protocol level, x402 follows a predictable pattern:

  1. A client or agent requests a protected resource.
  2. The server responds with HTTP 402 and structured payment requirements.
  3. The client submits payment proof.
  4. The facilitator verifies settlement.
  5. The server returns the requested resource.

 

When a resource requires payment, the server responds with HTTP 402 Payment Required. The client fulfills the payment requirement and retries the request. Settlement and verification happen behind the scenes, keeping the flow web-native and synchronous.

For a deeper conceptual discussion, read our x402 blog post.

diagram-2

Choosing a facilitator model

Facilitators are a core part of x402, and how you deploy them depends on your needs.

Self-hosted facilitator

  • Full control over verification and pricing logic

  • Custom policies and settlement rules

  • Greater operational responsibility

Shared or managed facilitator

  • Faster time to integration

  • Less infrastructure to maintain

  • Opinionated defaults

You can start with a managed setup and move to a self-hosted facilitator as your requirements evolve.

Try GoPlausible's facilitator now ->

Common x402 developer use cases

Algorand is x402-ready. The network’s low fees, instant finality, and stablecoin support make it possible to support high-frequency, pay-per-use payment traffic without breaking real-time request flows.

Pay-per-API access

Charge per request without managing plans or quotas. 

Agent-to-service payments

Allow AI agents to discover services and pay for usage autonomously.

On-demand compute and inference

Meter and charge for execution time or inference requests.

Premium data and content APIs

Sell access to high-value data without subscriptions.

Internal service monetization

Enable usage-based billing and cost attribution across microservices.

Developer resources by intent

Explore the Algorand Multichain Facilitator with Bazaar integration:

Run your own facilitator using Algorand's exact specification:

Explore a live example:

Run an x402 backend middleware using Typescript:

Run x402 fullstack using Typescript:

Run x402 paywall UI using Typescript:

Run x402 clients using Typescript:

Use only x402 core and avm mechanisms in Typescript:

Use x402 Bazaar extension in Typescript:

Run x402 Core functionality in Python:

Run x402 Backend servers in Python:

Run x402 Frontend clients in Python:

Use the x402 Bazaar extension in Python:

Keep engaged with x402

Ready to build? Explore reference implementations, test against live endpoints, or talk to our team about your use case.

Experience x402 in action

DISCLAIMER: The content provided in this page is for informational purposes only. The information is provided by the Algorand Foundation and while we strive to keep the information up-to-date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability, or availability with respect to the blog or the information, products, services, or related graphics contained in the blog for any purpose. The content of this blog is not intended to be legal, financial, or investment advice nor is it an endorsement, guarantee, or investment recommendation. You should not take any action before conducting your own research or consulting with a qualified professional. Any reliance you place on such information is therefore strictly at your own risk.  All companies are independent entities solely responsible for their operations, marketing, and compliance with applicable laws and regulations. In no event will Algorand Foundation nor any affiliates  be liable for any loss or damage including without limitation, indirect, or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this blog. Through this blog, you may be able to link to other websites which are not under the control of the Algorand Foundation. We have no control over the nature, content, and availability of those sites. The inclusion of any links does not imply a recommendation nor endorse the views expressed therein.