{
  "openapi": "3.1.0",
  "info": {
    "title": "Subcent402 Gateway API",
    "description": "Multi-Rail M2M Micro-Payment Gateway & L402 Macaroon Minting Hub for Autonomous AI Agents.",
    "version": "1.0.0",
    "contact": {
      "name": "Quite Good Project Labs",
      "url": "https://subcent402.com"
    }
  },
  "servers": [
    {
      "url": "https://api.subcent402.com",
      "description": "Global Edge Gateway"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Gateway Health Check",
        "responses": {
          "200": {
            "description": "Gateway status and fee metrics"
          }
        }
      }
    },
    "/v1/invoice/create": {
      "post": {
        "summary": "Mint Macaroon Challenge & Invoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["priceUsd", "toolName", "recipientWallet"],
                "properties": {
                  "priceUsd": { "type": "number", "example": 0.003 },
                  "toolName": { "type": "string", "example": "tokenenrich_lookup" },
                  "recipientWallet": { "type": "string", "example": "0xYourWalletAddress" },
                  "ttlSeconds": { "type": "integer", "default": 900 }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created L402 challenge with fee breakdown"
          }
        }
      }
    },
    "/v1/invoice/settle": {
      "post": {
        "summary": "Verify Settlement & Release Preimage",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["paymentHash", "rail"],
                "properties": {
                  "paymentHash": { "type": "string" },
                  "rail": { "type": "string", "enum": ["BASE_USDC", "LIGHTNING_BTC", "MOCK_VAULT"] }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preimage proof unlocked"
          }
        }
      }
    }
  }
}
