{
  "openapi": "3.0.3",
  "info": {
    "title": "WNC Emergency Plumbing Autonomous Estimate & Lead Dispatch API",
    "version": "2026.1",
    "description": "Real-time programmatic pricing and dispatch interface for WNC Emergency Plumbing across 8 Western North Carolina mountain corridors. Provides machine-readable estimates calibrated for Appalachian slopes, rock breaking, and weather extremes.",
    "contact": {
      "name": "WNC Emergency Plumbing Regional Dispatch",
      "url": "https://wncemergencyplumbing.com/",
      "phone": "(828) 845-8077"
    }
  },
  "servers": [
    {
      "url": "https://wncemergencyplumbing.com",
      "description": "Production Cloudflare Edge Server for wncemergencyplumbing.com"
    }
  ],
  "paths": {
    "/api/estimate": {
      "post": {
        "summary": "Calculate Instant Ballpark Mountain Estimate",
        "description": "Calculates real-time price ranges adjusted for WNC slope grades, bedrock conditions, and site dimensions. Automatically prepares an SMS dispatch payload.",
        "operationId": "calculateTradeEstimate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EstimateRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/EstimateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Estimate calculated successfully and local crew queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EstimateResponse"
                },
                "example": {
                  "success": true,
                  "confirmation_id": "WNC-PLUMB-828-9412",
                  "project_estimate": {
                    "low": 3400,
                    "high": 5800,
                    "currency": "USD"
                  },
                  "trade": "WNC Emergency Plumbing",
                  "corridor": "metro-asheville",
                  "local_dispatch_window": "Within 15-45 minutes",
                  "dispatch_status": "QUEUED_SMS",
                  "message": "Estimate calculated. Local WNC Emergency Plumbing corridor specialist notified via SMS dispatch."
                }
              }
            }
          },
          "400": {
            "description": "Missing required fields or invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string",
                      "example": "Missing required field: phone"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/leads": {
      "post": {
        "summary": "Dispatch Customer Lead & Schedule On-Site Assessment",
        "description": "Ingests direct customer service requests, applies honeypot screening, and dispatches real-time alerts to the corridor contractor team.",
        "operationId": "dispatchTradeLead",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/LeadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead received and dispatched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EstimateRequest": {
        "type": "object",
        "required": [
          "phone",
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Customer full name or contact person",
            "example": "Morgan Weaver"
          },
          "phone": {
            "type": "string",
            "description": "Direct customer mobile phone for SMS estimate confirmation",
            "example": "(828) 555-0199"
          },
          "corridor": {
            "type": "string",
            "enum": [
              "metro-asheville",
              "southern-plateau",
              "central-west",
              "luxury-crest",
              "high-country-mining",
              "far-west",
              "east-foothills",
              "yadkin-valley"
            ],
            "description": "Target WNC geographic corridor",
            "example": "metro-asheville"
          },
          "project_type": {
            "type": "string",
            "description": "Specific trade service sub-type",
            "example": "tankless_water_heater"
          },
          "units": {
            "type": "number",
            "description": "Quantity or dimension units (e.g. sq ft, linear ft, trees, acres, kw)",
            "example": 1
          },
          "unit_type": {
            "type": "string",
            "description": "Unit denomination",
            "example": "project"
          },
          "slope_factor": {
            "type": "number",
            "description": "Mountain terrain slope multiplier (1.0 = gentle grade, 1.18-1.25 = moderate ridge, 1.35-1.50 = steep slope/rock)",
            "example": 1.0
          },
          "notes": {
            "type": "string",
            "description": "Specific site access or geological obstacles",
            "example": "Steep driveway access with granite ledge"
          },
          "bot_field": {
            "type": "string",
            "description": "Honeypot field (leave empty for programmatic API calls)",
            "example": ""
          }
        }
      },
      "EstimateResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "confirmation_id": {
            "type": "string"
          },
          "project_estimate": {
            "type": "object",
            "properties": {
              "low": {
                "type": "number"
              },
              "high": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "example": "USD"
              }
            }
          },
          "trade": {
            "type": "string"
          },
          "corridor": {
            "type": "string"
          },
          "local_dispatch_window": {
            "type": "string"
          },
          "dispatch_status": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "LeadRequest": {
        "type": "object",
        "required": [
          "phone",
          "name"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "corridor": {
            "type": "string"
          },
          "service_requested": {
            "type": "string"
          },
          "details": {
            "type": "string"
          },
          "bot_field": {
            "type": "string"
          }
        }
      },
      "LeadResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "confirmation_id": {
            "type": "string"
          },
          "dispatch_status": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}