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

# x402 on Metal

> x402 payments on Metal settle in *USDZ with the facilitator paying the gas, as standard exact payments or per call through clearing

[x402](https://x402.org) lets a server charge for an HTTP request: it
answers `402 Payment Required` with a price, and the client retries with a
signed payment. On Metal, that payment authorizes a transfer of `*USDZ`,
Metal's dollar token. The agent only signs the payment; the seller
passes it to the [facilitator](https://docs.metalntwx.com/agents/facilitator.md), which submits it on
chain and pays the gas.

Metal's facilitator settles two schemes: `exact`, one transfer per
payment, and `bajillion`, Metal's clearing, a running total against one
deposit.

## The `exact` flow

`exact` is standard x402: the agent signs one transfer of `*USDZ` for one
price, and the facilitator submits it as one transaction. It is the same
[authorized payment](https://docs.metalntwx.com/build/payments/authorized-payment.md) any seller on
Metal accepts, which is why an agent can pay from an account it does not
own, within [limits](https://docs.metalntwx.com/agents/mandates.md) the owner set.

```mermaid theme={null}
sequenceDiagram
    autonumber
    participant A as Agent
    participant S as Seller
    participant F as Facilitator
    participant M as Metal
    A->>S: Request the resource
    S-->>A: 402 Payment Required, with the price
    Note over A: Signs a payment in *USDZ
    A->>S: Request again, with the payment
    S->>F: Verify the payment
    F-->>S: Valid
    Note over S: Does the work
    S->>F: Settle the payment
    F->>M: Submits the transfer, pays the gas
    F-->>S: Settled
    S-->>A: The resource, with the receipt
```

## The `bajillion` flow

Clearing is for frequent, low-cost purchases, where a transaction per
payment would cost more than the purchase. The agent deposits `*USDZ` once
and signs a running total with each request; the [clearing](https://docs.metalntwx.com/agents/clearing.md)
service answers each with a signed receipt and certifies the totals on
chain every few seconds.

```mermaid theme={null}
sequenceDiagram
    autonumber
    participant A as Agent
    participant S as Seller
    participant F as Facilitator
    participant C as Clearing service
    A->>S: Request the resource
    S-->>A: 402 Payment Required, with the price
    Note over A: Signs a running total that grows by the price
    A->>C: Sends the payment
    C-->>A: Signed receipt
    A->>S: Request again, with the receipt
    S->>F: Settle the payment
    F->>C: Confirms the receipt
    F-->>S: Settled, with the receipt
    Note over S: Does the work
    S-->>A: The resource
    Note over C: Every few seconds, certifies the totals on chain
```

In both, the seller pays nothing and the agent pays no gas for a payment.
Under clearing each side pays the gas of its own deposits and withdrawals.

> [card] [Pay for an API](https://docs.metalntwx.com/agents/quickstart-pay.md)
>
> The agent's side: an account, funds and a paid request.

> [card] [Facilitator](https://docs.metalntwx.com/agents/facilitator.md)
>
> Endpoints, limits, refusal reasons and retries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.