x402 for Developers: Build Pay-Per-Use APIs and Agent Payments

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.

Start here: x402 for developers/builders: What are you building?

x402 supports different roles and deployment models. Choose the path that matches what you need.

/Icons%20(transparent%20background)/Wallet-transparent-bg.svg)

Selling access to an API, data, or service

Protect HTTP endpoints and charge per request without subscriptions, API keys, or custom billing systems.

Learn more ->](https://algorand.co/agentic-commerce/x402/developers#roles) /Icons%20(transparent%20background)/Resillience-transparent-bg.svg)

Building a client that automates payments

Consume x402-protected APIs and resources programmatically, with payments handled automatically.

Learn more ->](https://algorand.co/agentic-commerce/x402/developers#flow) /Icons%20(transparent%20background)/Party-transparent-bg.svg)

Running your own payment verification logic

Deploy and control your own facilitator for custom pricing, policies, and settlement rules.

Learn more ->](https://algorand.co/agentic-commerce/x402/developers#facilitatormodel) /Icons%20(transparent%20background)/Pure%20Proof-of-Stake-transparent-bg.svg)

Getting started with minimal infrastructure

Use existing tooling and reference implementations to integrate x402 quickly.

Learn more ->](https://algorand.co/agentic-commerce/x402/developers#resources)

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:

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 ->

Enlarge image

Choosing a facilitator model

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

Self-hosted facilitator

Shared or managed facilitator

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

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

Algorand Virtual Machine (AVM) implementation of the x402 payment protocol

Explore the Algorand Multichain Facilitator with Bazaar integration:

Run your own facilitator using Algorand's exact specification:

GoPlausible x402 on Algorand developer hub

Explore a live example:

Run an x402 backend middleware using Typescript:

Run x402 clients using Typescript:

Use x402 Bazaar extension in Typescript:

Experience x402 in action

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

Turn your API endpoint into a pay-per-request service and compete for your share of $100K USD + 500K ALGO prize pools.