{
  "openapi": "3.1.0",
  "info": {
    "title": "CleanQuote API",
    "version": "1.0.0",
    "description": "Stateless residential cleaning quote calculator. Mirrors the browser tool's pricing formula exactly. No authentication, no storage of inputs.",
    "contact": { "email": "hello@getcleanq.com", "url": "https://getcleanq.com" },
    "license": { "name": "Free to use" }
  },
  "servers": [{ "url": "https://getcleanq.com" }],
  "paths": {
    "/api/quote": {
      "post": {
        "operationId": "calculateQuote",
        "summary": "Calculate a residential cleaning estimate",
        "description": "Runs the same formula as the CleanQuote web tool: hours = max(1, round((baseHours + bedrooms*0.25 + bathrooms*0.35) * multiplier, 0.5)); cost = max(minimumFee, hours * hourlyRate); price = cost / (1 - margin) + add-ons. Returns a full breakdown plus the formula used, so a caller can explain the number to a human.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "service": {
                    "type": "string",
                    "enum": ["Regular Cleaning", "Deep Cleaning", "Move-out Cleaning"],
                    "default": "Regular Cleaning"
                  },
                  "bedrooms": { "type": "number", "minimum": 0, "maximum": 6, "default": 2 },
                  "bathrooms": { "type": "number", "minimum": 0, "maximum": 6, "default": 2 },
                  "homeSize": {
                    "type": "string",
                    "enum": ["small", "medium", "large", "xlarge"],
                    "default": "medium",
                    "description": "small < 1000 sq ft; medium 1000-1999; large 2000-2999; xlarge 3000+"
                  },
                  "addons": {
                    "type": "array",
                    "items": { "type": "string" },
                    "description": "Add-on names from the price book, e.g. 'Inside oven', 'Inside refrigerator', 'Inside cabinets', 'Interior windows', 'Pet hair / extra vacuuming', 'Heavy buildup or clutter'"
                  },
                  "book": {
                    "type": "object",
                    "description": "Optional custom price book. Omitted fields fall back to defaults ($120 minimum, $55/hr, 20% margin).",
                    "properties": {
                      "minimumFee": { "type": "number", "default": 120 },
                      "hourlyRate": { "type": "number", "default": 55 },
                      "margin": { "type": "number", "minimum": 0, "maximum": 80, "default": 20 },
                      "multipliers": { "type": "object" },
                      "sizeHours": { "type": "object" },
                      "bedroomHours": { "type": "number", "default": 0.25 },
                      "bathroomHours": { "type": "number", "default": 0.35 },
                      "addons": { "type": "array", "items": { "type": "object" } }
                    }
                  }
                }
              },
              "examples": {
                "twoBedTwoBathRegular": {
                  "summary": "Typical 2-bed / 2-bath regular clean",
                  "value": { "service": "Regular Cleaning", "bedrooms": 2, "bathrooms": 2, "homeSize": "medium" }
                },
                "deepCleanWithAddons": {
                  "summary": "Deep clean with two add-ons",
                  "value": {
                    "service": "Deep Cleaning",
                    "bedrooms": 3,
                    "bathrooms": 2,
                    "homeSize": "large",
                    "addons": ["Inside oven", "Heavy buildup or clutter"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote breakdown",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "input": { "type": "object" },
                    "priceBook": { "type": "object" },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "hours": { "type": "number" },
                        "serviceCost": { "type": "number" },
                        "basePrice": { "type": "number" },
                        "marginAmount": { "type": "number" },
                        "addons": { "type": "array", "items": { "type": "object" } },
                        "addonTotal": { "type": "number" },
                        "total": { "type": "number" }
                      }
                    },
                    "formula": { "type": "object" }
                  }
                }
              }
            }
          },
          "400": { "description": "Invalid JSON body" },
          "429": { "description": "Daily rate limit exceeded" }
        }
      },
      "options": { "summary": "CORS preflight", "responses": { "204": { "description": "OK" } } }
    },
    "/api/feedback": {
      "post": {
        "operationId": "sendFeedback",
        "summary": "Send product feedback",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["message"],
                "properties": {
                  "kind": { "type": "string", "enum": ["idea", "bug", "pricing", "love", "other"], "default": "other" },
                  "message": { "type": "string", "minLength": 3, "maxLength": 2000 },
                  "email": { "type": "string", "description": "Optional, for a reply" },
                  "page": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Feedback received" },
          "400": { "description": "Validation error" },
          "429": { "description": "Daily limit reached" }
        }
      }
    }
  }
}
