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

# x402 Facilitator Overview

> The Nevermined x402 Facilitator verifies and settles x402 payments with smart accounts and programmable contracts

The Nevermined x402 Facilitator is an **enforcement and settlement engine** for x402. It lets any API, agent, MCP tool, or protected resource accept **HTTP-native payments** without running on-chain infrastructure.

It supports both:

* **Standard x402 settlement** ("pay-per-request" style)
* **Nevermined's programmable x402 extension** (`nvm:erc4337` scheme with smart accounts + session keys + contract settlement)

<Note>
  For the complete technical specification, see the [x402 Smart Accounts Extension Spec](/docs/specs/x402-smart-accounts).
</Note>

The Facilitator sits in the [x402 payment flow](/docs/development-guide/nevermined-x402) — when a server receives a payment token, it delegates verification and settlement to the Facilitator rather than handling it directly.

## Why use a Facilitator?

A facilitator is the third party that:

* verifies payment proofs
* simulates/enforces what is allowed (amount, plan, merchant/agent binding)
* executes settlement on-chain
* returns a canonical receipt (e.g., transaction hash)

This is particularly important for **programmable x402**, where settlement may be more than a single ERC-20 transfer (credits, subscriptions, policy-based settlement).

## Facilitator API

### Environments

| Environment    | URL                                          | Purpose                               |
| -------------- | -------------------------------------------- | ------------------------------------- |
| **Sandbox**    | `https://facilitator.sandbox.nevermined.app` | Testing and development with testnets |
| **Production** | `https://facilitator.live.nevermined.app`    | Live mainnet transactions             |

<Note>
  Use the sandbox environment for development and testing. Switch to production only when you're ready to process real payments.
</Note>

### Core Endpoints

The Nevermined x402 Facilitator exposes two core endpoints for payment verification and settlement:

<CardGroup cols={2}>
  <Card title="Verify Endpoint" icon="shield-check">
    **POST** `/api/v1/x402/verify`

    Validates payment authorization, checks permissions, and simulates on-chain settlement before workload execution.
  </Card>

  <Card title="Settle Endpoint" icon="credit-card">
    **POST** `/api/v1/x402/settle`

    Executes on-chain settlement after workload completion and returns transaction receipt.
  </Card>
</CardGroup>

## How it works

```mermaid theme={null}
sequenceDiagram
    participant Client
    participant Server as Resource Server (API/Agent)
    participant Facilitator as Nevermined x402 Facilitator
    participant Chain as Blockchain

    Client->>Server: Request
    Server-->>Client: 402 + payment-required header

    Client->>Client: Generate x402 token via SDK
    Client->>Server: Retry + payment-signature header

    Server->>Facilitator: /verify (simulate + validate)
    Facilitator->>Chain: Policy + balance checks
    Facilitator-->>Server: Verification OK

    Server->>Server: Execute workload

    Server->>Facilitator: /settle (execute settlement)
    Facilitator->>Chain: Execute contract settlement
    Facilitator-->>Server: Receipt + txHash

    Server-->>Client: Response + payment-response header
```

## Nevermined's programmable x402 extension

Standard x402 is often implemented as an "exact transfer" authorization (e.g., EIP-3009). Nevermined extends x402 to support:

* **Smart Accounts (ERC-4337)** and delegated **session keys**
* **Smart-contract settlement** (credits, subscriptions, PAYG, dynamic charging)
* **Policy enforcement** (merchant allowlists, spend caps, validity windows)

This keeps the HTTP handshake the same, but upgrades settlement from "transfer" to **programmable execution**.

## Facilitator responsibilities

### Verification

* x402 envelope structure/version
* signature authenticity
* session key validity + scoped permissions
* plan state + subscriber balance
* simulation of allowed on-chain actions (UserOps)

### Settlement

After the server completes its work, the facilitator can execute the settlement action permitted by the payment payload, such as:

* `order` (purchase/top-up)
* `redeem` / `burn` (consume credits)
* "exact" transfers (when using standard x402)

## Getting started

<CardGroup cols={2}>
  <Card title="Express.js Integration" icon="node-js" href="/docs/integrate/add-to-your-agent/express">
    One-line payment protection with Express middleware
  </Card>

  <Card title="How It Works" icon="gears" href="/docs/products/x402-facilitator/how-it-works">
    End-to-end flow (client + server) with x402 headers and facilitator calls
  </Card>

  <Card title="Payment Models" icon="calculator" href="/docs/integrate/patterns/payment-models">
    Credits, subscriptions, and dynamic pricing using programmable settlement
  </Card>

  <Card title="x402 Protocol" icon="plug" href="/docs/development-guide/nevermined-x402">
    Integrate x402 into your API/agent
  </Card>

  <Card title="Google A2A" icon="sparkles" href="/docs/integrations/google-a2a">
    Use x402 with A2A + AP2-style payment intent messaging
  </Card>
</CardGroup>
