# **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:

- 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 ->](https://algorand.co/blog/x402-unlocking-the-agentic-commerce-era)**

[Enlarge image](https://algorand.co/hubfs/diagram-2.webp)

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

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

- [x402 AVM **->**](https://www.npmjs.com/package/@x402/avm) and [example code **->**](https://github.com/x402-foundation/x402/tree/main/typescript/packages/mechanisms/avm)

Explore the Algorand Multichain Facilitator with Bazaar integration:

- [Algorand Facilitator docs **->**](https://facilitator.goplausible.xyz/docs)
- [Algorand Facilitator **->**](https://facilitator.goplausible.xyz/)
- [Algorand Facilitator-supported networks **->**](https://facilitator.goplausible.xyz/supported)

Run your own facilitator using Algorand's exact specification:

- [Algorand x402 scheme **->**](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_algo.md)

GoPlausible x402 on Algorand developer hub

- [Docs, packages, facilitator & live test endpoints)](https://x402.goplausible.xyz/) **->**

Explore a live example:

- [Live x402 endpoint protected content demo **->**](https://x402.goplausible.xyz/protected)
- [Live x402 endpoint protected weather API demo **->**](https://x402.goplausible.xyz/protected)

Run an x402 backend middleware using Typescript:

- [x402 ExpressJS server package **->**](https://www.npmjs.com/package/@x402/express)
- [x402 Hono Server package **->**](https://www.npmjs.com/package/@x402/hono) and [example code **->**](https://github.com/algorandfoundation/x402-demo/tree/main/x402-examples/server/hono)

Run x402 clients using Typescript:

- x402 [Fetch client package **->**](https://www.npmjs.com/package/@x402/fetch) and [example code **->**](https://github.com/algorandfoundation/x402-demo/tree/main/x402-examples/client/fetch)

- x402 [Axios client package **->**](https://www.npmjs.com/package/@x402/axios) and [example code **->**](https://github.com/algorandfoundation/x402-demo/tree/main/x402-examples/client/axios)

Use x402 Bazaar extension in Typescript:

- x402 [Bazaar extension package **->**](https://www.npmjs.com/package/@x402-avm/extensions) and [example code **->**](https://github.com/GoPlausible/.github/blob/main/profile/algorand-x402-documentation/typescript/x402-avm-extensions-examples.md)

### Experience x402 in action

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

- [Sign up for the next x402 workshop](https://algorand.co/developers/workshops).

- [Explore reference implementation documentation](https://dev.algorand.co/resources/x402-on-algorand/).

- [Partner with us on agentic commerce](https://fjtqz.share-eu1.hsforms.com/2fAL6ZOblQnCB1YzXtGLLSA).

- [Agentic x402 Skills](https://github.com/algorand-devrel/algorand-agent-skills)

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