{
  "openapi": "3.1.0",
  "info": {
    "title": "FoleyIT Booking API",
    "version": "1.0.0",
    "description": "Request an IT service appointment with FoleyIT (Chester / Fort Smith, Arkansas). Submissions are REQUESTS, not confirmed bookings: Blake Foley contacts the customer to confirm the exact time. Same-day service is not bookable online; for urgent needs call (479) 370-0397. Collect every field from the customer and get their explicit go-ahead before submitting. The same capabilities are available as MCP tools at https://foleyit.com/mcp (Streamable HTTP, no auth).",
    "contact": {
      "name": "FoleyIT",
      "email": "tech@foleyit.com",
      "url": "https://foleyit.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://foleyit.com"
    }
  ],
  "paths": {
    "/api/booking/slots": {
      "get": {
        "operationId": "checkAvailability",
        "summary": "List dates and time-of-day preferences that can be requested online",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "How many bookable days to return (1-60, default 30).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 60,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Bookable days, earliest first. Never includes today.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Availability"
                }
              }
            }
          }
        }
      }
    },
    "/api/schedule": {
      "post": {
        "operationId": "requestAppointment",
        "summary": "Submit an appointment request (not a confirmed booking)",
        "description": "Use a preferred_date_iso returned by checkAvailability. Retrying the same phone + date + service returns the original reference instead of creating a duplicate.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Request recorded as pending.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppointmentReceipt"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed; the error text says what to fix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; tell the customer to phone instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/business-hours": {
      "get": {
        "operationId": "getBusinessHours",
        "summary": "Current business hours and onsite-visit hours",
        "responses": {
          "200": {
            "description": "Hours as display strings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Availability": {
        "type": "object",
        "properties": {
          "timezone": {
            "type": "string",
            "example": "America/Chicago"
          },
          "today": {
            "type": "string",
            "format": "date"
          },
          "same_day_booking": {
            "type": "boolean",
            "const": false
          },
          "same_day_note": {
            "type": "string"
          },
          "booking_horizon_days": {
            "type": "integer",
            "example": 90
          },
          "services": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "Home Network Setup / UniFi",
                "Smart Home Setup",
                "PC Repair / Cleanup",
                "Data Protection / Backup",
                "Tech Education",
                "Cloud / Servers / Business IT",
                "Websites & Domains",
                "AI, Apps & Custom Software",
                "AI Setup & Guidance",
                "Managed Services Plan",
                "Other / Not Sure"
              ]
            }
          },
          "days": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "weekday": {
                  "type": "string"
                },
                "time_preferences": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "5:30 – 6:30 PM",
                      "6:30 – 7:30 PM",
                      "7:30 – 8:30 PM",
                      "8:30 – 9:30 PM",
                      "Morning (9 AM – 12)",
                      "Afternoon (12 – 4 PM)",
                      "Flexible — any time"
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "AppointmentRequest": {
        "type": "object",
        "required": [
          "service_type",
          "preferred_date_iso",
          "first_name",
          "phone"
        ],
        "properties": {
          "service_type": {
            "type": "string",
            "enum": [
              "Home Network Setup / UniFi",
              "Smart Home Setup",
              "PC Repair / Cleanup",
              "Data Protection / Backup",
              "Tech Education",
              "Cloud / Servers / Business IT",
              "Websites & Domains",
              "AI, Apps & Custom Software",
              "AI Setup & Guidance",
              "Managed Services Plan",
              "Other / Not Sure"
            ]
          },
          "preferred_date_iso": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD, from checkAvailability. Tomorrow or later."
          },
          "preferred_time": {
            "type": "string",
            "enum": [
              "5:30 – 6:30 PM",
              "6:30 – 7:30 PM",
              "7:30 – 8:30 PM",
              "8:30 – 9:30 PM",
              "Morning (9 AM – 12)",
              "Afternoon (12 – 4 PM)",
              "Flexible — any time"
            ],
            "description": "Time-of-day preference offered for that date. Defaults to flexible. This is a preference, not an exact slot."
          },
          "first_name": {
            "type": "string",
            "maxLength": 100
          },
          "last_name": {
            "type": "string",
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "description": "10-digit US number; Blake may call or text it."
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "What's going on / what the customer needs."
          }
        }
      },
      "AppointmentReceipt": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "reference": {
            "type": "string",
            "example": "FIT-00042"
          },
          "status": {
            "type": "string",
            "const": "pending"
          },
          "duplicate": {
            "type": "boolean",
            "description": "True if this matched an existing pending request."
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}