---

title: x402

description: How Open Stellar gates API responses with payment-required receipts.

---

x402

x402 is the payment-required flow for agent services. A provider returns a quote instead of the protected payload. The caller signs or settles the quote, then retries or submits the receipt to unlock the response.

Lifecycle

  • quote: provider describes price, asset, destination, expiry, and service metadata.
  • authorize: optional ZK Passport gate proves the payer can spend without exposing private identity data.
  • settle: payment is submitted on Stellar testnet and a receipt is recorded.
  • deliver: the service returns the paid result and emits feed/reputation events.

Minimal handler

import { gateWithX402 } from "@open-stellar/sdk/server"

export const GET = gateWithX402({ serviceId: "weather.v1", amount: "0.25" }, async () => {
  return Response.json({ forecast: "clear skies" })
})