> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payai.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Merchant Introduction

> Learn how to sell services with x402.

## Monetize your API with x402

x402 lets you monetize HTTP APIs and content with on-chain payments, while keeping your existing server stack.

Benefits:

✅ Customers don't pay network fees.\
✅ Payment settles in \< 1 second.\
✅ Universal compatibility -- if it speaks HTTP, it speaks x402.

## Architecture at a glance

<img src="https://mintcdn.com/payai/4LHfgOPrYQU9GWE8/images/x402-sequence-diagram.svg?fit=max&auto=format&n=4LHfgOPrYQU9GWE8&q=85&s=f9a5356f8d04bfa03987fe5a8d8d0db4" alt="x402 sequence diagram" width="1992" height="1570" data-path="images/x402-sequence-diagram.svg" />

* **Client**: Calls your protected resource and submits payments.
* **Server (merchant)**: Advertises payment requirements, verifies payments, fulfills requests, and settles payments.
* **Facilitator**: Verifies and/or settles payments on your behalf via standard endpoints.
* **Blockchain**: Where payments are executed and confirmed.

## It's that easy

Add x402 payments to your server with just a few lines:

<Tabs>
  <Tab title="Express">
    ```typescript theme={null}
    import { paymentMiddleware, x402ResourceServer } from "@x402/express";
    import { ExactEvmScheme } from "@x402/evm/exact/server";
    import { HTTPFacilitatorClient } from "@x402/core/server";
    import { facilitator } from "@payai/facilitator";

    const facilitatorClient = new HTTPFacilitatorClient(facilitator);

    app.use(
      paymentMiddleware(
        {
          "GET /weather": {
            accepts: [
              {
                scheme: "exact",
                price: "$0.001",
                network: "eip155:84532",
                payTo: evmAddress,
              },
            ],
            description: "Weather data",
            mimeType: "application/json",
          },
        },
        new x402ResourceServer(facilitatorClient)
          .register("eip155:84532", new ExactEvmScheme()),
      ),
    );
    ```
  </Tab>

  <Tab title="Hono">
    ```typescript theme={null}
    import { paymentMiddleware, x402ResourceServer } from "@x402/hono";
    import { ExactEvmScheme } from "@x402/evm/exact/server";
    import { HTTPFacilitatorClient } from "@x402/core/server";
    import { facilitator } from "@payai/facilitator";

    const facilitatorClient = new HTTPFacilitatorClient(facilitator);

    app.use(
      paymentMiddleware(
        {
          "GET /weather": {
            accepts: [
              {
                scheme: "exact",
                price: "$0.001",
                network: "eip155:84532",
                payTo: evmAddress,
              },
            ],
            description: "Weather data",
            mimeType: "application/json",
          },
        },
        new x402ResourceServer(facilitatorClient)
          .register("eip155:84532", new ExactEvmScheme()),
      ),
    );
    ```
  </Tab>
</Tabs>

## Getting started

Select one of the quickstart examples, or read the [reference](/x402/reference) for more details.

<Tabs>
  <Tab title="TypeScript">
    <CardGroup>
      <Card title="Express" href="/x402/servers/typescript/express" icon="server">
        Quickstart for building an x402-enabled server with Express.
      </Card>

      <Card title="Hono" href="/x402/servers/typescript/hono" icon="server">
        Quickstart for building an x402-enabled server with Hono.
      </Card>

      <Card title="Next.js" href="/x402/servers/typescript/nextjs" icon="server">
        Quickstart for building an x402-enabled server with Next.js.
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Python">
    <CardGroup>
      <Card title="FastAPI" href="/x402/servers/python/fastapi" icon="server">
        Quickstart for building an x402-enabled server with FastAPI.
      </Card>

      <Card title="Flask" href="/x402/servers/python/flask" icon="server">
        Quickstart for building an x402-enabled server with Flask.
      </Card>
    </CardGroup>
  </Tab>
</Tabs>

## Facilitator setup

The `@payai/facilitator` package provides a pre-configured facilitator that connects to the PayAI facilitator at `https://facilitator.payai.network`:

```bash theme={null}
npm install @payai/facilitator
```

```typescript theme={null}
import { facilitator } from "@payai/facilitator";
import { HTTPFacilitatorClient } from "@x402/core/server";

const facilitatorClient = new HTTPFacilitatorClient(facilitator);
```

This works immediately on the free tier. For production, set `PAYAI_API_KEY_ID` and `PAYAI_API_KEY_SECRET` environment variables — see [Going to Production](/x402/facilitators/pricing). For details on how authentication works or to implement it without PayAI packages, see [Facilitator Authentication](/x402/facilitators/authentication).

## x402 reference

For a deeper dive into message shapes, headers, verification and settlement responses, see the [x402 Reference](/x402/reference).

## Need help?

<Card title="Join our Community" icon="discord" href="https://discord.gg/eWJRwMpebQ">
  Have questions or want to connect with other developers? Join our Discord server.
</Card>
