# x402-facilitator

**GitHub:** [fastxyz/fast-sdk](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-facilitator/README.md)

## What You Can Do

The x402 Facilitator is the **trust anchor** of the x402 protocol. It runs as a service (or is called as an API) and does two critical jobs:

* **Verifies payment payloads** — confirms that a payment presented by a client matches the server's expected network, recipient, asset, and amount
* **Settles payments** — finalizes supported payment flows after successful verification

Use the facilitator when building:

* **x402 server integrations** — every server needs to verify incoming payment proofs via a facilitator
* **Shared payment infrastructure** — one facilitator service can back multiple x402-protected services
* **Custom verification logic** — if your server needs direct control over verification and settlement

## Installation

Install from npm as `@fastxyz/x402-facilitator`. For the exact install command, route surface, and deployment examples, use the [package README on GitHub](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-facilitator/README.md).

## Architecture

The facilitator sits between an x402-enabled server and the underlying payment network. It exposes verification and settlement endpoints so application servers can stay focused on delivering the protected resource.

```
Client               Server              Facilitator           Fast Network
  │                     │                     │                     │
  │  pay (signs tx)     │                     │                     │
  │────────────────────►│                     │                     │
  │                     │                     │  submit / sync       │
  │                     │────────────────────►│────────────────────►│
  │                     │                     │                     │
  │                     │  200 OK + resource  │                     │
  │◄────────────────────│                     │                     │
  │                     │  verifyProof()      │                     │
  │                     │────────────────────►│                     │
  │                     │                     │  check settled txs   │
  │                     │                     │◄────────────────────│
  │                     │  { valid: true }    │                     │
  │                     │◄────────────────────│                     │
```

| Component                 | Role                                                                              |
| ------------------------- | --------------------------------------------------------------------------------- |
| **Verification endpoint** | Checks whether the presented x402 payment is valid for the requested resource     |
| **Settlement endpoint**   | Finalizes supported payment flows after successful verification                   |
| **Network adapters**      | Connect Fast and supported EVM payment flows to the common x402 service interface |

## Verification Flow

When a server receives a request with `X-PAYMENT`, it calls the facilitator:

1. **Parse** — Decode the payment payload from the request header
2. **Validate** — Check that network, recipient, asset, and amount match the server's requirement
3. **Verify** — Confirm the payload is valid for the relevant Fast or EVM payment flow
4. **Settle** — Finalize the payment when the integration requires settlement
5. **Respond** — Return a structured verification or settlement result to the calling service

## Running the Facilitator Service

The facilitator can run as a standalone HTTP service that your servers call, or it can be mounted inside an existing application. The current package surface and deployment patterns are documented in the [x402-facilitator README on GitHub](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-facilitator/README.md).

## Facilitator API

The current package exposes verification and settlement endpoints, including `POST /verify`, `POST /settle`, and `GET /supported`. Exact request and response schemas are maintained in the [x402-facilitator README on GitHub](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-facilitator/README.md).

## Security Properties

The facilitator provides the following high-level guarantees:

| Property                    | How                                                                                                    |
| --------------------------- | ------------------------------------------------------------------------------------------------------ |
| **Correct recipient**       | Payment must match the recipient configured by the server                                              |
| **Correct amount**          | Payment must satisfy the configured price requirement                                                  |
| **Correct asset/network**   | Payment must match the configured asset and payment network                                            |
| **Structured verification** | Servers receive a protocol-level verification result instead of implementing network checks themselves |

## Relationship to x402 Server

The x402 Server SDK (x402-server) ships with built-in facilitator integration — you typically don't call the facilitator directly when using x402-server. You **do** use the facilitator directly when:

* Building a custom payment verification endpoint
* Running the facilitator as a standalone service for multiple x402 servers

***

**For complete API documentation, supported routes, configuration, and deployment examples, see the** [**x402-facilitator README on GitHub**](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-facilitator/README.md)**.**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fast.xyz/sdk-references/payment-protocol-adapters/x402-sdk/x402-facilitator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
