{
  "openapi": "3.1.0",
  "info": {
    "title": "WaterFilterHelp Agent API",
    "version": "1.1.0",
    "description": "Programmatic water treatment recommendations and free quote requests for Canadian homeowners."
  },
  "servers": [
    {
      "url": "https://waterfilterhelp.ca"
    }
  ],
  "paths": {
    "/api/v1/services": {
      "get": {
        "operationId": "listServices",
        "responses": {
          "200": {
            "description": "Supported services"
          }
        }
      }
    },
    "/api/v1/locations": {
      "get": {
        "operationId": "listLocations",
        "responses": {
          "200": {
            "description": "Supported locations"
          }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "operationId": "healthCheck",
        "responses": {
          "200": {
            "description": "Healthy"
          }
        }
      }
    },
    "/api/v1/quotes": {
      "post": {
        "operationId": "submitQuoteRequest",
        "summary": "Submit a water treatment quote request",
        "description": "Obtain explicit user consent before submitting PII. Use dry_run=true to validate and preview without creating a lead.",
        "parameters": [
          {
            "name": "dry_run",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dry-run preview"
          },
          "201": {
            "description": "Quote created"
          },
          "400": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          },
          "502": {
            "description": "Persistence adapter failed"
          }
        }
      }
    },
    "/api/v1/wizard": {
      "get": {
        "operationId": "getWizardManifest",
        "summary": "Wizard capability manifest",
        "responses": {
          "200": {
            "description": "Machine-readable wizard schema",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/wizard/recommend": {
      "post": {
        "operationId": "recommendWaterTreatmentStack",
        "summary": "Recommend a water treatment stack from symptoms",
        "description": "No contact info required. Returns a recommended equipment stack, CAD cost ranges, and quote_handoff fields for POST /api/v1/quotes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WizardRecommendRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recommendation generated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WizardRecommendResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          }
        }
      },
      "get": {
        "operationId": "getWizardManifest",
        "summary": "Wizard capability manifest",
        "responses": {
          "200": {
            "description": "Machine-readable wizard schema",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "QuoteRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "consent",
          "name",
          "email",
          "phone",
          "address",
          "city",
          "province",
          "country",
          "service_type",
          "water_source",
          "urgency"
        ],
        "properties": {
          "consent": {
            "type": "boolean",
            "description": "Explicit consent to share PII for contractor matching",
            "const": true
          },
          "name": {
            "type": "string",
            "description": "Full name",
            "minLength": 2,
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "description": "Email address",
            "format": "email",
            "maxLength": 254
          },
          "phone": {
            "type": "string",
            "description": "Phone number",
            "minLength": 7,
            "maxLength": 40
          },
          "address": {
            "type": "string",
            "description": "Property street address",
            "minLength": 5,
            "maxLength": 200
          },
          "city": {
            "type": "string",
            "description": "Property city",
            "minLength": 2,
            "maxLength": 80
          },
          "province": {
            "type": "string",
            "description": "Canadian province code",
            "enum": [
              "AB",
              "BC",
              "MB",
              "NB",
              "NL",
              "NS",
              "NT",
              "NU",
              "ON",
              "PE",
              "QC",
              "SK",
              "YT"
            ],
            "minLength": 2,
            "maxLength": 2
          },
          "postal_code": {
            "type": "string",
            "description": "Canadian postal code",
            "pattern": "^[A-Z]\\d[A-Z] \\d[A-Z]\\d$"
          },
          "country": {
            "type": "string",
            "description": "Country code",
            "const": "CA",
            "default": "CA"
          },
          "details": {
            "type": "string",
            "description": "Project details",
            "maxLength": 4000
          },
          "agent_source": {
            "type": "string",
            "description": "Submitting agent, e.g. chatgpt",
            "maxLength": 64,
            "default": "agent"
          },
          "agent_version": {
            "type": "string",
            "description": "Optional submitting agent version",
            "maxLength": 64
          },
          "submission_method": {
            "type": "string",
            "description": "openapi, mcp, webmcp, or agent-skill",
            "enum": [
              "openapi",
              "mcp",
              "webmcp",
              "agent-skill"
            ],
            "default": "openapi"
          },
          "website": {
            "type": "string",
            "description": "Spam honeypot; leave empty"
          },
          "service_type": {
            "type": "string",
            "description": "Water treatment service",
            "enum": [
              "water_softener",
              "whole_home_filter",
              "reverse_osmosis",
              "iron_filter",
              "uv",
              "well_water",
              "drinking_water",
              "water_testing",
              "repair",
              "other"
            ]
          },
          "water_source": {
            "type": "string",
            "description": "Water source",
            "enum": [
              "municipal",
              "well",
              "unknown"
            ]
          },
          "problem": {
            "type": "array",
            "description": "Observed water problems",
            "items": {
              "type": "string",
              "enum": [
                "hard_water",
                "iron",
                "sulphur",
                "staining",
                "taste_odor",
                "bacteria",
                "sediment",
                "other"
              ]
            }
          },
          "urgency": {
            "type": "string",
            "description": "Requested timing",
            "enum": [
              "asap",
              "1_3_months",
              "researching"
            ]
          }
        }
      },
      "WizardRecommendRequest": {
        "type": "object",
        "required": [
          "source",
          "province"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "municipal",
              "well",
              "cottage"
            ]
          },
          "province": {
            "type": "string",
            "description": "Canadian province/territory code",
            "enum": [
              "AB",
              "BC",
              "MB",
              "NB",
              "NL",
              "NS",
              "NT",
              "NU",
              "ON",
              "PE",
              "QC",
              "SK",
              "YT"
            ]
          },
          "postal": {
            "type": "string",
            "description": "Optional Canadian postal code"
          },
          "postal_code": {
            "type": "string",
            "description": "Alias for postal"
          },
          "smell": {
            "type": "string",
            "enum": [
              "none",
              "rotten_eggs",
              "chlorine",
              "musty"
            ],
            "default": "none"
          },
          "colour": {
            "type": "string",
            "enum": [
              "clear",
              "yellow_orange",
              "cloudy",
              "black_brown"
            ],
            "default": "clear"
          },
          "color": {
            "type": "string",
            "enum": [
              "clear",
              "yellow_orange",
              "cloudy",
              "black_brown"
            ],
            "description": "US spelling alias for colour"
          },
          "hardness": {
            "type": "boolean",
            "default": false
          },
          "iron_stains": {
            "type": "boolean",
            "default": false
          },
          "bacteria_concern": {
            "type": "boolean",
            "default": false
          },
          "has_test": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "WizardRecommendResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "summary": {
            "type": "string"
          },
          "stack": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "why": {
                  "type": "string"
                },
                "cost_low": {
                  "type": "number"
                },
                "cost_high": {
                  "type": "number"
                },
                "optional": {
                  "type": "boolean"
                }
              }
            }
          },
          "total_low": {
            "type": "number"
          },
          "total_high": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "enum": [
              "CAD"
            ]
          },
          "primary_service": {
            "type": "string"
          },
          "urgency_hint": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "quote_handoff": {
            "type": "object"
          },
          "quote_endpoint": {
            "type": "string"
          },
          "human_wizard_url": {
            "type": "string"
          }
        }
      }
    }
  }
}
