> ## Documentation Index
> Fetch the complete documentation index at: https://base-a060aa97-docs-devrel-859-new-docs-org-pages-pr-branch.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Charge for an API

> Protect a fixed-price API route with the x402 exact scheme on Base.

Charge a known amount before returning an API response. In the Base USDC flow used here, x402 carries an EIP-3009 authorization through the HTTP `402 Payment Required` handshake, then a facilitator verifies and settles it.

These examples target Base Sepolia (`eip155:84532`) and the public test facilitator. Confirm the facilitator's supported network, asset, and settlement contracts before a live test.

<Steps>
  <Step title="Return Payment Requirements">The unpaid request receives a 402 response with the scheme, network, token, price, and recipient.</Step>
  <Step title="Sign and Retry">The buyer applies its spend policy, signs the advertised payment, and retries with `PAYMENT-SIGNATURE`.</Step>
  <Step title="Verify Before Work">Seller middleware verifies the payload before your protected handler runs.</Step>
  <Step title="Settle">The facilitator submits the payment and returns settlement details with the response.</Step>
</Steps>

## Price a Fixed Route

<CodeGroup>
  ```typescript TypeScript · Express lines wrap expandable highlight={1,3} theme={null}
  app.use(paymentMiddleware({
    "GET /fixed": {
      accepts: [{ scheme: "exact", price: "$0.01", network, payTo }],
      description: "Fixed-price market report",
      mimeType: "application/json",
    },
  }, resourceServer));
  app.get("/fixed", (_request, response) => response.json({ report: "Base market summary" }));
  ```

  ```go Go · net/http lines wrap expandable highlight={3} theme={null}
  routes := x402http.RoutesConfig{
  	"GET /fixed": {
  		Accepts: x402http.PaymentOptions{{Scheme: "exact", Price: "$0.01", Network: network, PayTo: payTo}},
  		Description: "Fixed-price market report", MimeType: "application/json",
  	},
  }
  mux := http.NewServeMux()
  mux.HandleFunc("GET /fixed", func(w http.ResponseWriter, _ *http.Request) {
  	_ = json.NewEncoder(w).Encode(map[string]string{"report": "Base market summary"})
  })
  ```

  ```python Python · FastAPI lines wrap expandable highlight={3} theme={null}
  routes = {
      "GET /fixed": RouteConfig(
          accepts=[PaymentOption(scheme="exact", price="$0.01", network=network, pay_to=pay_to)],
          description="Fixed-price market report",
          mime_type="application/json",
      )
  }


  @app.get("/fixed")
  async def fixed() -> dict[str, str]:
      return {"report": "Base market summary"}
  ```
</CodeGroup>

<Check>
  An unpaid request receives 402; a valid paid retry reaches the handler and returns the resource once.
</Check>

<Warning>
  Treat the facilitator response and your own fulfillment record as separate checks. Make the route idempotent so a retried paid request cannot deliver the same one-time resource twice.
</Warning>

## See Also

<CardGroup cols={2}>
  <Card title="Settle Usage-Based Payments" icon="gauge" href="/build-on-base/accept-payments/settle-usage-based-payments">Set the final charge after successful work.</Card>
  <Card title="Call a Paid Service" icon="robot" href="/build-on-base/accept-payments/call-a-paid-service">Add network, asset, and spend policy on the buyer.</Card>
</CardGroup>
