Overview

Integration guide

Everything you need to put the gateway in front of your API and let agents pay for it — in five steps.

An integration has two sides. As the merchant, you run the gateway in front of your API and decide what each endpoint costs and who can see it. As the agent (the buyer), you discover those resources, call them, and answer a payment challenge when one comes back. This tab covers both, end to end.

Before you start

  • An HTTP API the gateway can reach
    Any existing JSON API. No SDK goes into your backend and nothing in it is rewritten.
  • Node.js ≥ 22, or Docker
    Node for the CLI and the gateway itself; Docker only for the bundled demo stack.
  • A wallet address you control
    This becomes payTo. It is an address only — the gateway never asks for a merchant key.
  • A network
    The local dev chain for development, Base Sepolia to prove real settlement, Base mainnet for real funds.

Merchant integration in five steps

  1. Describe your API

    Turn endpoints into resources in config.yaml — by hand, from OpenAPI, or with the wizard. See Describe your API.

  2. Accept payments

    Configure x402 with your payTo, the network and a facilitator. See Accept payments.

  3. Expose to agents

    Enable HTTP, MCP, A2A or ACP and choose per resource where it appears. See Expose to agents.

  4. Run and verify

    Start the gateway, then let validate and doctor prove it. See Run the gateway.

  5. Go live

    Admin token, origins, TLS and rate limiting at your edge. See the go-live checklist.

A complete configuration

This is a whole, valid config.yaml: one paid endpoint, reachable over HTTP and MCP, settling real USDC on Base Sepolia through the public testnet facilitator. Replace the backend URL and MERCHANT_WALLET, and it is an integration.

config.yamlyaml
version: 1

merchant:
  id: my-store
  name: My Store
  publicBaseUrl: ${GATEWAY_PUBLIC_BASE_URL:-http://localhost:8080}

server:
  port: ${GATEWAY_PORT:-8080}
  host: 0.0.0.0
  adminToken: ${ADMIN_TOKEN}

storage:
  receipts:
    driver: sqlite
    path: ./data/receipts.sqlite

protocols:
  http:
    enabled: true
  mcp:
    enabled: true
    mountPath: /mcp

resources:
  premium_report:
    name: Premium Report
    description: A paid endpoint on your existing backend.
    input:
      type: object
      properties: {}
      additionalProperties: false
    backend:
      type: http
      method: GET
      url: ${MERCHANT_API_BASE_URL}/api/report
      timeoutMs: 10000
    pricing:
      type: fixed
      amount: "0.01"
      currency: USDC
    expose: [http, mcp]
    payments: [x402]

payments:
  x402:
    enabled: true
    network: eip155:84532
    rpcUrl: https://base-sepolia-rpc.publicnode.com   # health checks only
    asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e"   # Circle USDC
    assetName: USDC
    assetVersion: "2"
    assetDecimals: 6
    payTo: ${MERCHANT_WALLET}
    maxTimeoutSeconds: 300
    facilitator:
      mode: remote
      url: https://x402.org/facilitator
      auth: { type: none }
bash
export MERCHANT_API_BASE_URL=https://api.example.com
export MERCHANT_WALLET=0xYourWalletAddress
export ADMIN_TOKEN=$(openssl rand -hex 32)

npx @devlab.group/agent-commerce validate --config config.yaml

Agent integration

Pick your path