{
  "openapi": "3.1.0",
  "info": {
    "title": "Kavitha Dental Care booking API",
    "version": "1.0.0",
    "description": "Live appointment requests for Kavitha Dental Care, Chennai (Maduravoyal and Nerkundram). Slots are filtered to Monday–Saturday 10:00–13:00 and 17:00–21:00 Asia/Kolkata in 15-minute steps. Listing never books. Only create a request after the patient approves the exact branch, date, time, name and mobile number. The clinic confirms by phone or WhatsApp.",
    "contact": {
      "email": "kavithadentalcares@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://www.kavithadental.com"
    }
  ],
  "paths": {
    "/api/booking/options": {
      "get": {
        "operationId": "getBookingOptions",
        "summary": "Bookable branches, treatment codes and hours",
        "responses": {
          "200": {
            "description": "Options",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/booking/slots": {
      "get": {
        "operationId": "getAppointmentSlots",
        "summary": "Live free slots for one branch (read-only)",
        "parameters": [
          {
            "name": "branch",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "maduravoyal",
                "nerkundram"
              ]
            }
          },
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "IST date; omit to list upcoming days."
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 14,
              "default": 7
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Slots grouped by IST date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Slots"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/booking/book": {
      "get": {
        "operationId": "bookAppointmentByUrl",
        "summary": "Create a real appointment request with one GET (for link-only assistants)",
        "x-openai-isConsequential": true,
        "parameters": [
          {
            "name": "branch",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "maduravoyal",
                "nerkundram"
              ]
            }
          },
          {
            "name": "date",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "IST date."
          },
          {
            "name": "time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "IST time, e.g. 17:30 or 5:30pm."
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 2
            }
          },
          {
            "name": "phone",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "10-digit Indian mobile, optionally +91."
          },
          {
            "name": "treatment",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "patientConsent",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Request received",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppointmentResult"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/booking/appointments": {
      "post": {
        "operationId": "requestAppointment",
        "summary": "Create a real appointment request",
        "x-openai-isConsequential": true,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Request received",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppointmentResult"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/booking/cancel": {
      "post": {
        "operationId": "cancelAppointment",
        "summary": "Cancel a request by its private booking reference",
        "x-openai-isConsequential": true,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "bookingReference"
                ],
                "properties": {
                  "bookingReference": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancelled"
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Slots": {
        "type": "object",
        "properties": {
          "branch": {
            "type": "object"
          },
          "timeZone": {
            "type": "string"
          },
          "days": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "times": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "slotStart": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "localTime": {
                        "type": "string"
                      },
                      "period": {
                        "type": "string",
                        "enum": [
                          "Morning",
                          "Evening"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "AppointmentRequest": {
        "type": "object",
        "required": [
          "branch",
          "slotStart",
          "patientName",
          "mobileNumber",
          "patientConsent"
        ],
        "additionalProperties": false,
        "properties": {
          "branch": {
            "type": "string",
            "enum": [
              "maduravoyal",
              "nerkundram"
            ]
          },
          "slotStart": {
            "type": "string",
            "format": "date-time",
            "description": "Exact slotStart from getAppointmentSlots."
          },
          "patientName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 200
          },
          "mobileNumber": {
            "type": "string",
            "description": "10-digit Indian mobile number, optionally +91."
          },
          "treatmentCode": {
            "type": "string",
            "description": "Optional code from getBookingOptions."
          },
          "patientConsent": {
            "type": "boolean",
            "const": true,
            "description": "true only after the patient approved this exact request."
          }
        }
      },
      "AppointmentResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "bookingReference": {
            "type": "string"
          },
          "branch": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "localTime": {
            "type": "string"
          },
          "nextStep": {
            "type": "string"
          }
        }
      }
    }
  }
}
