{
  "openapi": "3.1.0",
  "info": {
    "title": "Connor Well & Pump API",
    "version": "1.0.0",
    "summary": "Lead intake API for Connor Well & Pump, a well and pump service company in Western North Carolina.",
    "description": "Public endpoints for submitting a contact enquiry or a quote request. Endpoints are oRPC procedures: every request body is wrapped in a top-level `json` envelope.",
    "contact": {
      "name": "Connor Well & Pump",
      "url": "https://connorwellandpump.com/contact",
      "phone": "(828) 593-1069"
    }
  },
  "servers": [{ "url": "https://connorwellandpump.com" }],
  "paths": {
    "/api/rpc/contact/submit": {
      "post": {
        "operationId": "submitContact",
        "summary": "Submit a contact enquiry or quote request",
        "description": "Persists the submission and emails the business owner. Returns success once the submission is stored; email delivery is best-effort and does not affect the response.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/SubmissionEnvelope" },
              "example": {
                "json": {
                  "name": "Sandra Whitmore",
                  "email": "sandra@example.com",
                  "phone": "(828) 452-7714",
                  "city": "Waynesville",
                  "service": "Well Pump Repair",
                  "message": "No water since this morning and the pressure tank is short-cycling.",
                  "kind": "quote"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Submission accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "json": {
                      "type": "object",
                      "properties": { "success": { "type": "boolean" } },
                      "required": ["success"]
                    }
                  }
                },
                "example": { "json": { "success": true } }
              }
            }
          },
          "400": { "description": "Input validation failed" }
        }
      }
    },
    "/api/rpc/ping": {
      "post": {
        "operationId": "ping",
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "Service is up",
            "content": {
              "application/json": {
                "example": { "json": { "message": "Pong! 1788211462000" } }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SubmissionEnvelope": {
        "type": "object",
        "required": ["json"],
        "properties": {
          "json": { "$ref": "#/components/schemas/Submission" }
        }
      },
      "Submission": {
        "type": "object",
        "required": ["name", "email", "phone", "message"],
        "properties": {
          "name": { "type": "string", "minLength": 1, "maxLength": 120 },
          "email": { "type": "string", "format": "email", "maxLength": 160 },
          "phone": { "type": "string", "minLength": 1, "maxLength": 40 },
          "city": { "type": "string", "maxLength": 120, "default": "" },
          "service": { "type": "string", "maxLength": 120, "default": "" },
          "message": { "type": "string", "minLength": 1, "maxLength": 4000 },
          "kind": {
            "type": "string",
            "enum": ["contact", "quote"],
            "default": "contact",
            "description": "Use `quote` for quote requests so the notification is labelled correctly."
          }
        }
      }
    }
  }
}
