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

# Publisher Quickstart

> Start charging AI bots for content access — pay-per-crawl setup with USDC micropayments in 5 minutes. Non-custodial Cloudflare pay-per-crawl alternative.

Set up pay-per-crawl on your site in five minutes — detect AI bots (GPTBot, ClaudeBot, PerplexityBot, etc.), return HTTP 402, collect USDC micropayments on Base. Works standalone or as a non-custodial alternative to Cloudflare pay-per-crawl.

## Xenarch vs Cloudflare pay-per-crawl

|                | Xenarch                                                     | Cloudflare pay-per-crawl                   |
| -------------- | ----------------------------------------------------------- | ------------------------------------------ |
| **Custody**    | Non-custodial — USDC settles on-chain via splitter contract | Custodial — Cloudflare holds your earnings |
| **Fee**        | 0% (capped at 0.99% forever)                                | Cloudflare takes a cut                     |
| **Settlement** | USDC on Base L2, every payment on-chain                     | Fiat payout, off-chain ledger              |
| **Stack**      | Any stack (Python, Node, WordPress, Joomla, custom)         | Cloudflare Workers required                |
| **Pricing**    | Per-page or per-path, publisher-defined                     | Cloudflare-defined                         |

## Prerequisites

* A USDC wallet on Base (this is where you receive payments)
* Your content served over HTTPS

## Step 1: Register

```bash theme={null}
npx xenarch register
```

This creates your publisher account and returns an API key (`xk_pub_...`).

## Step 2: Add your site

```bash theme={null}
npx xenarch site-add example.com
```

Returns a site token (`st_...`) and site ID. Save both.

## Step 3: Set pricing

```bash theme={null}
npx xenarch pricing example.com --default 0.003
```

Sets a default price of \$0.003 per page. Add path-specific rules:

```bash theme={null}
npx xenarch pricing example.com \
  --rule "/premium/*=0.01" \
  --rule "/api/*=0.05" \
  --rule "/public/*=0"
```

## Step 4: Install middleware

Choose your integration:

<Tabs>
  <Tab title="FastAPI (Python)">
    ```bash theme={null}
    pip install xenarch[fastapi]
    ```

    **Site-wide middleware** (gates all bot traffic):

    ```python theme={null}
    from xenarch.middleware import XenarchMiddleware

    app.add_middleware(
        XenarchMiddleware,
        site_token="st_...",
        site_id="your-site-uuid",
        access_token_secret="your_secret",
        excluded_paths={"/healthz", "/docs"},
    )
    ```

    **Per-route decorator** (gates individual endpoints):

    ```python theme={null}
    from xenarch.decorator import require_payment

    gate = require_payment(
        site_token="st_...",
        site_id="your-site-uuid",
        access_token_secret="your_secret",
    )

    @app.get("/premium")
    @gate
    async def premium(request: Request):
        return {"content": "premium data"}
    ```

    See the [FastAPI middleware guide](/integrations/fastapi-middleware).
  </Tab>

  <Tab title="WordPress">
    1. Install the Xenarch plugin from the WordPress directory
    2. Go to **Settings > Xenarch**
    3. Enter your site token and configure pricing
    4. Toggle bot categories to gate (AI Search, Assistants, Agents, etc.)

    See the [WordPress guide](/integrations/wordpress).
  </Tab>

  <Tab title="Custom server">
    Implement the flow manually:

    1. Detect bots via User-Agent matching
    2. Call `POST /v1/gates` to create a gate
    3. Return HTTP 402 with the gate response
    4. When agents submit a Bearer token, verify it via `POST /v1/access-tokens/verify`

    See the [API reference](/api-reference/overview).
  </Tab>
</Tabs>

## Step 5: Add pay.json (optional)

Serve a `pay.json` file at `/.well-known/pay.json` so agents can discover your pricing without hitting a 402 first:

```bash theme={null}
npx pay-json-generate \
  --wallet 0xYOUR_WALLET \
  --receiver 0xC6D3a6B6fcCD6319432CDB72819cf317E88662ae \
  --price 0.003 \
  --provider xenarch \
  --output .well-known/pay.json
```

See the [pay.json spec](/integrations/pay-json).

## How it works for your users

* **Humans**: Pass through completely unaffected. The middleware only gates bot traffic.
* **AI agents with payment**: Pay USDC, get an access token, access your content.
* **AI agents without payment**: See HTTP 402 with payment instructions.

## Check your earnings

```bash theme={null}
npx xenarch stats your-site-id
```
