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

# How Prism Works

> Under the hood: how Prism turns any API endpoint into a paid, permissionless service for AI agents.

Prism uses a two-layer architecture that separates business logic from on-chain settlement. You integrate at the orchestration layer — familiar APIs and SDKs. Settlement happens transparently on-chain through the Spectrum layer. Merchants never need to touch smart contracts directly.

## Two-layer architecture

Prism is the off-chain **orchestration layer** you integrate against; **Spectrum** is the on-chain **settlement layer** that moves the stablecoins. Merchants never touch a smart contract directly. For how the two layers fit together — and how Prism implements each protocol — see the Architecture section.

<Card title="Architecture overview" icon="diagram-project" href="/prism/architecture/overview">
  The orchestration and settlement layers, and Prism as the layer that speaks every protocol.
</Card>

## Transaction Lifecycle

Here's what happens during a payment, step by step:

<Steps>
  <Step title="Request">
    An AI agent makes an HTTP request to the merchant's protected endpoint
    (e.g., `GET /api/premium/data`).
  </Step>

  <Step title="402 Response">
    The Prism SDK middleware intercepts the request and returns **HTTP 402
    Payment Required**. The response includes payment requirements: amount,
    token, chain, recipient address, and a deadline.
  </Step>

  <Step title="Payment">
    The agent's wallet reads the 402 response, constructs a stablecoin payment,
    and submits it on-chain.
  </Step>

  <Step title="Retry with Proof">
    The agent retries the original request, this time including the payment
    proof (transaction signature) in the `X-PAYMENT` header.
  </Step>

  <Step title="Verification">
    Prism forwards the payment proof to Spectrum, which verifies the on-chain
    transaction — correct amount, correct token, correct recipient, transaction
    confirmed.
  </Step>

  <Step title="Settlement">
    Once verified, settlement is complete. The stablecoins are in the merchant's
    wallet. Prism confirms the payment to the SDK middleware.
  </Step>

  <Step title="Access Granted">
    The middleware allows the original request to proceed. The agent receives
    the requested resource.
  </Step>
</Steps>

**Timing:** End-to-end settlement takes a few seconds, depending on the chain. Base transactions typically settle in \~2 seconds, while Ethereum takes \~12 seconds.

After the request completes, Prism delivers a webhook notification to the merchant's configured endpoint with the full transaction details.

## Protocol support

Prism is protocol-agnostic — one integration covers x402, UCP, and ACP, so your setup stays the same regardless of which protocol a buyer's agent speaks. For what each protocol is, see the [protocol landscape overview](/prism/concepts/commerce-protocols); for how Prism implements each, see [Architecture](/prism/architecture/overview).

## Settlement

All settlements happen in stablecoins. Merchants choose which tokens and chains to accept in the [Prism console](/prism/production/console). The transaction is final once confirmed on the blockchain. No chargebacks, no disputes, no clawbacks.

Settlement flows directly from the agent's wallet to the merchant's wallet. No intermediary holds the funds. The merchant can hold stablecoins or transfer them to another wallet.

| Chain    | Settlement Time | Gas Cost |
| -------- | --------------- | -------- |
| Base     | \~2 seconds     | Very low |
| Arbitrum | \~2 seconds     | Very low |
| BSC      | \~3 seconds     | Low      |
| Ethereum | \~12 seconds    | Higher   |

[Settlement deep dive →](/prism/concepts/settlement)
