{
  "openapi": "3.1.0",
  "info": {
    "title": "Servaro Public & Control-Plane API",
    "version": "1.5.0",
    "description": "Read-only service discovery, promotional coupon validation, managed DNS zones & BIND exports, support ticketing, live chat concierge, Servaro provisioning dry-run blueprints, and Model Context Protocol (MCP 2025-03-26) JSON-RPC 2.0 server."
  },
  "servers": [{ "url": "https://servaro.1444sezgin.workers.dev" }],
  "paths": {
    "/api/catalog": {
      "get": {
        "operationId": "listCatalog",
        "summary": "List all 13 Servaro services, direct prices and platform divisions",
        "responses": {
          "200": {
            "description": "Public catalog",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Check control-plane and D1 reachability",
        "responses": {
          "200": { "description": "Control plane and storage reachable" },
          "503": { "description": "Degraded or unconfigured storage" }
        }
      }
    },
    "/api/coupons": {
      "get": {
        "operationId": "listOrValidateCoupons",
        "summary": "List active promotional coupons or validate a code against a subtotal and term",
        "parameters": [
          { "name": "code", "in": "query", "schema": { "type": "string" } },
          { "name": "subtotal", "in": "query", "schema": { "type": "number" } },
          { "name": "months", "in": "query", "schema": { "type": "integer" } },
          { "name": "family", "in": "query", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Active coupons or validation result" }
        }
      },
      "post": {
        "operationId": "validateCoupon",
        "summary": "Validate a promotional coupon code",
        "responses": {
          "200": { "description": "Valid coupon calculation" },
          "422": { "description": "Ineligible or unknown coupon" }
        }
      }
    },
    "/api/dns": {
      "get": {
        "operationId": "getDnsZone",
        "summary": "Read a managed DNS zone and its RFC-1035 BIND zone file",
        "parameters": [
          { "name": "domain", "in": "query", "schema": { "type": "string" } },
          { "name": "format", "in": "query", "schema": { "type": "string", "enum": ["json", "bind"] } }
        ],
        "responses": {
          "200": { "description": "Authoritative DNS zone and BIND export" }
        }
      },
      "post": {
        "operationId": "mutateDnsZone",
        "summary": "Add/remove authoritative DNS records or apply 1-click Business Mail/Hosting/DMARC presets",
        "responses": {
          "200": { "description": "Updated DNS zone" },
          "201": { "description": "Created DNS record" }
        }
      }
    },
    "/api/tickets": {
      "get": {
        "operationId": "getTicketOrQuote",
        "summary": "Track a support ticket (SVT-...) or quote (SVQ-...) by reference",
        "parameters": [
          { "name": "ref", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Ticket thread or quote summary" },
          "404": { "description": "Reference not found" }
        }
      },
      "post": {
        "operationId": "createOrReplyTicket",
        "summary": "Create a new support ticket (SVT-...) or add a customer reply",
        "responses": {
          "201": { "description": "Support ticket created" },
          "200": { "description": "Reply added" }
        }
      }
    },
    "/api/chat": {
      "get": {
        "operationId": "getChatSession",
        "summary": "Fetch live chat session messages",
        "responses": { "200": { "description": "Live chat session" } }
      },
      "post": {
        "operationId": "postChatMessage",
        "summary": "Send a live chat message and receive instant Concierge response",
        "responses": { "200": { "description": "Updated chat session" } }
      }
    },
    "/api/provisioning": {
      "get": {
        "operationId": "getProvisioningCatalog",
        "summary": "Read Servaro Provisioning Engine posture, product keys, plan prices and service specifications",
        "parameters": [
          {
            "name": "service",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["hosting", "vps", "vds", "dedicated", "business-mail"]
            }
          },
          { "name": "domain", "in": "query", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Servaro provisioning manifest and specifications" }
        }
      },
      "post": {
        "operationId": "postProvisioningAction",
        "summary": "Generate a dry-run Servaro provisioning blueprint or inspect live domain DNS/RDAP posture",
        "responses": {
          "200": { "description": "Provisioning blueprint or live DNS/RDAP inspection report" },
          "400": { "description": "Invalid request payload" }
        }
      }
    },
    "/api/agent": {
      "get": {
        "operationId": "agentManifest",
        "summary": "Read agent and MCP capabilities",
        "responses": { "200": { "description": "REST and MCP capability manifest" } }
      },
      "post": {
        "operationId": "agentRpc",
        "summary": "Execute MCP JSON-RPC 2.0 methods (initialize, tools/list, tools/call, resources/list, resources/read, prompts/list, prompts/get)",
        "responses": {
          "200": { "description": "JSON-RPC response" },
          "400": { "description": "Invalid JSON or request object" }
        }
      }
    },
    "/mcp": {
      "get": {
        "operationId": "mcpManifest",
        "summary": "Read Model Context Protocol (2025-03-26) server manifest",
        "responses": { "200": { "description": "MCP server manifest" } }
      },
      "post": {
        "operationId": "mcpRpc",
        "summary": "Streamable HTTP Model Context Protocol JSON-RPC 2.0 endpoint",
        "responses": { "200": { "description": "JSON-RPC 2.0 response" } }
      }
    },
    "/api/quote": {
      "post": {
        "operationId": "recordQuote",
        "summary": "Store a stack activation or engineering request with consent",
        "responses": {
          "201": { "description": "Request stored with SVQ reference" },
          "400": { "description": "Validation failed" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentTool": {
        "type": "object",
        "properties": {
          "name": {
            "enum": [
              "catalog.list",
              "stack.compose",
              "quote.prepare",
              "provisioning.blueprint",
              "coupon.validate",
              "dns.inspect",
              "dns.zone.read",
              "ticket.status"
            ]
          }
        }
      }
    }
  }
}
