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

# Introduction to the x402 Facilitator

> Verify and settle HTTP 402 agentic payments with the official XentFi x402 Facilitator SDK, backed by XentFi WAAS and real EIP-3009 signatures.

`@xentfi/x402-facilitator` is the official TypeScript SDK for the **XentFi x402 Payment Facilitator** — a typed client for `/verify`, `/settle`, and `/supported`, plus helpers for signing real EIP-3009 authorizations.

```bash theme={null}
npm install @xentfi/x402-facilitator
```

## What is x402?

[x402](https://github.com/coinbase/x402) is an open convention for monetizing HTTP resources using the (long-reserved, rarely-used) **`402 Payment Required`** status code. A resource server responds `402` with a machine-readable list of accepted payment requirements; the client (often an AI agent) signs a payment authorization and retries the request with an `X-PAYMENT` header attached. It's designed for agent-to-agent and agent-to-API payments where there's no human clicking "buy" — just an agent that needs to pay for an API call and keep going.

XentFi's facilitator implements the **`eip3009`** scheme: payments are [EIP-3009](https://eips.ethereum.org/EIPS/eip-3009) `TransferWithAuthorization` signatures — a gasless, off-chain-signed authorization that a relayer (your XentFi WAAS wallet) submits on-chain during settlement.

```mermaid theme={null}
sequenceDiagram
    participant Payer as Paying Agent
    participant Server as Resource Server (you)
    participant Facilitator as XentFi x402 Facilitator
    participant Chain as Blockchain

    Payer->>Server: GET /premium-report
    Server-->>Payer: 402 Payment Required<br/>{ accepts: [PaymentRequirement] }
    Payer->>Payer: Sign EIP-3009 authorization<br/>(signEip3009Authorization)
    Payer->>Server: GET /premium-report<br/>X-PAYMENT: base64(payload)
    Server->>Facilitator: POST /verify
    Facilitator-->>Server: { isValid: true }
    Server->>Facilitator: POST /settle
    Facilitator->>Chain: Submit TransferWithAuthorization
    Chain-->>Facilitator: txHash
    Facilitator-->>Server: { success: true, txHash, network }
    Server-->>Payer: 200 OK + report + txHash
```

## Two roles, one SDK

<CardGroup cols={2}>
  <Card title="💰 Resource server" icon="server">
    You're getting paid. Use `X402FacilitatorClient` to `verify()` an incoming payment and `settle()` it on-chain — your WAAS wallet relays the transaction and receives the funds.
  </Card>

  <Card title="🤖 Payer" icon="bot">
    You're paying. Use `signEip3009Authorization()` to build a real, offline EIP-712 signature from any [viem](https://viem.sh) `LocalAccount`, then attach it as the `X-PAYMENT` header.
  </Card>
</CardGroup>

## Backed by XentFi WAAS

On initialization, you provide your XentFi **WAAS** `apiKey` and `orgId` — the facilitator URL and relayer wallet are fixed on the backend side. Your organization's WAAS wallet is what pays gas (for settlement) and receives funds. These credentials are sent as headers on every request; the SDK adds them for you.

<Note>
  This is the same XentFi organization API key / org ID used across the platform — see [Authentication](/api-reference/authentication) for how to get one. It's a different credential from the *agent* API keys used by [`@xentfi/mcp-sdk`](/agent/introduction), which act on behalf of a single agent rather than an organization's WAAS wallet.
</Note>

## Get started

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/x402/quickstart">
    Install the SDK and make your first `/supported` call.
  </Card>

  <Card title="Resource Server Guide" icon="server" href="/x402/resource-server">
    Monetize an API endpoint with x402.
  </Card>

  <Card title="Payer Guide" icon="bot" href="/x402/payer">
    Pay an x402-protected endpoint as an agent.
  </Card>

  <Card title="API Reference" icon="code" href="/x402/api-reference">
    `X402FacilitatorClient`, types, and signing helpers.
  </Card>
</CardGroup>
