{
  "openapi": "3.1.0",
  "info": {
    "title": "PlumberHelp.ca Agent Quote API",
    "version": "1.0",
    "description": "Discover services and locations, validate with dry-run, and submit consented plumbing quote requests."
  },
  "servers": [
    {
      "url": "https://plumberhelp.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 plumbing 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"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "QuoteRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "consent",
          "name",
          "email",
          "phone",
          "address",
          "city",
          "province",
          "country",
          "service_type",
          "property_type",
          "access_type",
          "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": "Plumbing service needed",
            "enum": [
              "drain_cleaning",
              "sewer_backup",
              "water_pressure",
              "leak_repair",
              "plumbing_inspection",
              "water_heater_repipe",
              "pipe_repair",
              "other"
            ]
          },
          "property_type": {
            "type": "string",
            "description": "Property type",
            "enum": [
              "house_townhouse",
              "condo_apartment",
              "commercial",
              "other"
            ]
          },
          "access_type": {
            "type": "string",
            "description": "Plumbing access",
            "enum": [
              "easy",
              "finished_tight_space",
              "crawl_space",
              "unknown"
            ]
          },
          "urgency": {
            "type": "string",
            "description": "Requested timing",
            "enum": [
              "emergency",
              "soon",
              "week",
              "flexible"
            ]
          }
        }
      }
    }
  }
}
