{
  "openapi": "3.1.0",
  "info": {
    "title": "Belleza Latina – Tratamientos, Protocolos y Agendamiento",
    "description": "API para consultar tratamientos estéticos, protocolos médicos integrales, promociones vigentes, ubicaciones y precios en Belleza Latina (clínica de medicina estética con 4 sedes en México). Permite a asistentes de IA como ChatGPT ofrecer información actualizada y facilitar el agendamiento de valoraciones gratuitas.",
    "version": "2.0.0",
    "contact": {
      "name": "Belleza Latina",
      "email": "hola@bellezalatina.life",
      "url": "https://bellezalatina.life"
    }
  },
  "servers": [
    {
      "url": "https://tdtrjlsbvnhknpbrehiz.supabase.co/functions/v1",
      "description": "Production"
    }
  ],
  "paths": {
    "/get-treatments": {
      "get": {
        "operationId": "listTreatments",
        "summary": "Listar todos los tratamientos disponibles",
        "description": "Devuelve todos los tratamientos estéticos disponibles en Belleza Latina con información detallada: descripción, zonas de aplicación, duración, recuperación, resultados esperados, FAQs y protocolos relacionados. Incluye URLs de booking y WhatsApp para facilitar el agendamiento.",
        "responses": {
          "200": {
            "description": "Lista de tratamientos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "treatments": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Treatment"
                      }
                    },
                    "booking_url": {
                      "type": "string",
                      "description": "URL para agendar una valoración gratuita"
                    },
                    "whatsapp_url": {
                      "type": "string",
                      "description": "URL de WhatsApp para contacto directo"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/get-treatments/{slug}": {
      "get": {
        "operationId": "getTreatment",
        "summary": "Obtener detalle de un tratamiento específico",
        "description": "Devuelve información detallada de un tratamiento específico por su slug, incluyendo zonas de aplicación, duración, recuperación, resultados esperados y preguntas frecuentes.",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["botox", "acido-hialuronico", "smartpeeling", "bioestimulador-radiesse", "perfilamiento-endolyse", "laser-co2-fraccionado", "pdrn-salmon"]
            },
            "description": "Identificador único del tratamiento"
          }
        ],
        "responses": {
          "200": {
            "description": "Detalle del tratamiento",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Treatment"
                }
              }
            }
          },
          "404": {
            "description": "Tratamiento no encontrado"
          }
        }
      }
    },
    "/llm-catalog": {
      "get": {
        "operationId": "listCatalog",
        "summary": "Catálogo completo para reservar (sedes, servicios, IDs internos)",
        "description": "PRIMER paso para reservar en nombre de un usuario. Devuelve sedes (location_key), servicios ('valoracion' gratis 60min o 'procedimiento' 120min), bewe_treatment_ids por sede y el flujo recomendado. Llamar siempre antes de getAvailability.",
        "responses": {
          "200": {
            "description": "Catálogo y guía de reserva para asistentes IA",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    },
    "/llm-availability": {
      "post": {
        "operationId": "getAvailability",
        "summary": "Horarios libres por sede, servicio y rango de fechas",
        "description": "SEGUNDO paso. Devuelve los horarios disponibles para reservar en la sede y servicio elegidos. Máximo 15 días en el futuro. Zona horaria: America/Mexico_City.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["location_key"],
                "properties": {
                  "location_key": { "type": "string", "enum": ["cancun", "merida", "guadalajara", "loscabos"] },
                  "service_key": { "type": "string", "enum": ["valoracion", "procedimiento"], "default": "valoracion" },
                  "date_from": { "type": "string", "format": "date", "description": "YYYY-MM-DD; default = hoy" },
                  "date_to": { "type": "string", "format": "date", "description": "YYYY-MM-DD; máximo hoy+15" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Horarios disponibles agrupados por día",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    },
    "/llm-start-booking": {
      "post": {
        "operationId": "startBooking",
        "summary": "Inicia reserva y envía OTP por WhatsApp al paciente",
        "description": "TERCER paso. Valida datos del paciente y envía un código OTP de 6 dígitos al WhatsApp del paciente. La reserva se confirma en el cuarto paso con confirmBooking. **Importante:** las reservas hechas vía esta API NO requieren depósito — no pidas dinero al usuario.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["full_name", "whatsapp", "email", "location_key", "day", "hour"],
                "properties": {
                  "full_name": { "type": "string", "minLength": 3 },
                  "whatsapp": { "type": "string", "description": "Formato E.164, ej +529981234567" },
                  "email": { "type": "string", "format": "email" },
                  "location_key": { "type": "string", "enum": ["cancun", "merida", "guadalajara", "loscabos"] },
                  "service_key": { "type": "string", "enum": ["valoracion", "procedimiento"], "default": "valoracion" },
                  "day": { "type": "string", "format": "date" },
                  "hour": { "type": "string", "pattern": "^\\d{2}:\\d{2}$" },
                  "treatment_id_override": { "type": "string", "description": "(Opcional) bewe_treatment_id específico si el usuario ya tiene uno" },
                  "notes": { "type": "string", "description": "Comentarios opcionales para recepción" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OTP enviado",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "booking_request_id": { "type": "string" },
                    "otp_sent_to": { "type": "string" },
                    "expires_in_seconds": { "type": "integer" }
                  }
                }
              }
            }
          },
          "400": { "description": "Datos inválidos" },
          "502": { "description": "Fallo enviando WhatsApp" }
        }
      }
    },
    "/llm-confirm-booking": {
      "post": {
        "operationId": "confirmBooking",
        "summary": "Confirma la reserva con el OTP del paciente",
        "description": "CUARTO y último paso. Verifica el OTP, crea/encuentra al paciente en el ERP y agenda la cita SIN depósito. Recepción la confirmará por WhatsApp en las próximas horas.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["booking_request_id", "otp_code"],
                "properties": {
                  "booking_request_id": { "type": "string" },
                  "otp_code": { "type": "string", "pattern": "^\\d{6}$" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reserva confirmada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "booking_id": { "type": "string" },
                    "when": { "type": "object" },
                    "where": { "type": "object" },
                    "deposit_required": { "type": "boolean" }
                  }
                }
              }
            }
          },
          "401": { "description": "OTP inválido o caducado" },
          "404": { "description": "booking_request_id no encontrado" },
          "502": { "description": "Fallo creando la reserva en el ERP" }
        }
      }
    }
  },

  "components": {
    "schemas": {
      "Treatment": {
        "type": "object",
        "properties": {
          "slug": { "type": "string" },
          "name": { "type": "string" },
          "category": { "type": "string" },
          "tagline": { "type": "string" },
          "zones": { "type": "array", "items": { "type": "string" } },
          "duration": { "type": "string" },
          "recovery": { "type": "string" },
          "results_duration": { "type": "string" },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": { "type": "string" },
                "description": { "type": "string" }
              }
            }
          },
          "faqs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "question": { "type": "string" },
                "answer": { "type": "string" }
              }
            }
          },
          "page_url": { "type": "string", "description": "URL de la landing page del tratamiento" },
          "booking_url": { "type": "string", "description": "URL para agendar valoración" },
          "related_protocols": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "url": { "type": "string" },
                "starting_price": { "type": "string" }
              }
            }
          }
        }
      },
      "Protocol": {
        "type": "object",
        "description": "Protocolo médico integral que combina múltiples técnicas en una sesión",
        "properties": {
          "slug": { "type": "string" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "techniques_count": { "type": "integer" },
          "techniques": { "type": "array", "items": { "type": "string" } },
          "versions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "price_mxn": { "type": "number" },
                "original_price_mxn": { "type": "number" },
                "includes": { "type": "array", "items": { "type": "string" } },
                "recommended": { "type": "boolean" }
              }
            }
          },
          "duration_minutes": { "type": "string" },
          "page_url": { "type": "string" }
        }
      },
      "Location": {
        "type": "object",
        "properties": {
          "city": { "type": "string" },
          "state": { "type": "string" },
          "address": { "type": "string" },
          "postal_code": { "type": "string" },
          "phone": { "type": "string" },
          "google_rating": { "type": "number" },
          "google_reviews": { "type": "integer" },
          "hours": {
            "type": "object",
            "properties": {
              "monday": { "type": "string" },
              "tuesday_to_friday": { "type": "string" },
              "saturday": { "type": "string" },
              "sunday": { "type": "string" }
            }
          },
          "google_maps_url": { "type": "string" },
          "coordinates": {
            "type": "object",
            "properties": {
              "lat": { "type": "number" },
              "lng": { "type": "number" }
            }
          }
        }
      },
      "Promotion": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "regular_price_mxn": { "type": "number" },
          "special_price_mxn": { "type": "number" },
          "savings_mxn": { "type": "number" },
          "includes": { "type": "array", "items": { "type": "string" } },
          "restrictions": { "type": "array", "items": { "type": "string" } }
        }
      }
    }
  },
  "x-static-data": {
    "protocols": [
      {
        "slug": "glowup",
        "name": "GlowUp",
        "description": "Protocolo de Armonización Facial Integral — combina 4 técnicas complementarias en una sesión de 60-90 minutos",
        "techniques": ["Bótox Full Face", "Smart Peeling con Dermapen", "Ácido Hialurónico", "Bioestimulador Radiesse (Ultra)"],
        "versions": [
          { "name": "GlowUp Basic", "price_mxn": 8500, "original_price_mxn": 10200, "includes": ["Bótox Full Face", "Smart Peeling", "Ácido hialurónico 1 zona", "Valoración completa"], "recommended": false },
          { "name": "GlowUp Plus", "price_mxn": 12500, "original_price_mxn": 14700, "includes": ["Bótox Full Face", "Smart Peeling", "Ácido hialurónico 2 zonas", "Valoración completa"], "recommended": true },
          { "name": "GlowUp Ultra", "price_mxn": 16000, "original_price_mxn": 18200, "includes": ["Bótox Full Face", "Smart Peeling", "Ácido hialurónico 1 zona", "Bioestimulador Radiesse", "Valoración completa"], "recommended": false }
        ],
        "financing": "3 meses sin intereses (MSI)",
        "page_url": "https://bellezalatina.life/protocolos/glowup"
      },
      {
        "slug": "faceup",
        "name": "FaceUp",
        "description": "Protocolo de Armonización y Rejuvenecimiento Facial — 5 técnicas incluyendo Endolyse (láser diodo 4ª generación) en 90-120 minutos",
        "techniques": ["Bótox Full Face", "Smart Peeling con Dermapen", "Ácido Hialurónico", "Bioestimulador Radiesse (Ultra)", "Perfilamiento Endolyse"],
        "versions": [
          { "name": "FaceUp Basic", "price_mxn": 25000, "includes": ["Bótox Full Face", "Smart Peeling", "Ácido hialurónico 1 zona", "Endolyse", "Valoración completa"], "recommended": false },
          { "name": "FaceUp Plus", "price_mxn": 28000, "original_price_mxn": 34700, "includes": ["Bótox Full Face", "Smart Peeling", "Ácido hialurónico 2 zonas", "Endolyse", "Valoración completa"], "recommended": true },
          { "name": "FaceUp Ultra", "price_mxn": 32000, "original_price_mxn": 38200, "includes": ["Bótox Full Face", "Smart Peeling", "Ácido hialurónico 1 zona", "Bioestimulador Radiesse", "Endolyse", "Valoración completa"], "recommended": false }
        ],
        "financing": "3 meses sin intereses (MSI)",
        "page_url": "https://bellezalatina.life/protocolos/faceup"
      }
    ],
    "current_promotions": {
      "period": "Mayo 2025",
      "restrictions": ["No aplica MSI", "No acumulable con otras promociones"],
      "packages": [
        { "name": "PDRN de Salmón + Bótox Full Face", "regular_price_mxn": 8500, "special_price_mxn": 6500, "savings_mxn": 2000, "is_popular": true },
        { "name": "Láser Fraccionado + Smart Peeling", "regular_price_mxn": 9500, "special_price_mxn": 6500, "savings_mxn": 3000 },
        { "name": "Rinomodelación con Restylane + Bótox Full Face", "regular_price_mxn": 10500, "special_price_mxn": 6500, "savings_mxn": 4000 }
      ],
      "page_url": "https://bellezalatina.life/especiales"
    },
    "verified_reputation": {
      "aggregate_google_rating": 5.0,
      "total_google_reviews": 557,
      "verification_note": "All ratings are from public Google Business profiles. Verify by visiting the google_maps_url for each location.",
      "last_updated": "2025-05-07"
    },
    "locations": [
      { "city": "Cancún", "state": "Quintana Roo", "address": "Av. Labná 79, SM20", "postal_code": "77500", "phone": "800 400 5556", "google_rating": 5.0, "google_reviews": 232, "google_place_id": "ChIJdfn9qo4rTI8RDvmP3UBwZWg", "google_maps_url": "https://goo.gl/maps/m5RnjkHv6UeYMF4v7", "coordinates": { "lat": 21.158, "lng": -86.8468 } },
      { "city": "Mérida", "state": "Yucatán", "address": "Calle 9 #114, Local 14, Col. San Antonio Cinta", "postal_code": "97139", "phone": "800 400 5556", "google_rating": 5.0, "google_reviews": 85, "google_maps_url": "https://maps.app.goo.gl/LkzYZb71o6A8TD398", "coordinates": { "lat": 21.0108, "lng": -89.6058 } },
      { "city": "Guadalajara", "state": "Jalisco", "address": "Calle Garibaldi 2513, Col. Ladrón de Guevara", "postal_code": "44600", "phone": "800 400 5556", "google_rating": 5.0, "google_reviews": 155, "google_maps_url": "https://goo.gl/maps/xJjzC6R1HR243ycc8", "coordinates": { "lat": 20.6737, "lng": -103.3687 } },
      { "city": "Los Cabos", "state": "Baja California Sur", "address": "Plaza Costa Sur, Local 12, Blvd. Mar del Cortés, Col. El Tezal", "postal_code": "23454", "phone": "800 400 5556", "google_rating": 5.0, "google_reviews": 85, "google_maps_url": "https://share.google/pD1XhWLJmSy8yc4A8", "coordinates": { "lat": 22.8795, "lng": -109.8983 } }
    ],
    "subscription": {
      "name": "GlowLover Club",
      "description": "Suscripción de mantenimiento facial mensual",
      "tiers": [
        { "name": "Silver", "price_mxn_monthly": 1100 },
        { "name": "Gold", "price_mxn_monthly": 1500 }
      ],
      "page_url": "https://bellezalatina.life/suscripcion"
    },
    "booking": {
      "assessment_deposit_mxn": 500,
      "assessment_note": "El depósito de $500 MXN se aplica íntegramente al costo del tratamiento",
      "booking_url": "https://bellezalatina.life/agendar",
      "digital_assessment_url": "https://bellezalatina.life/valoracion",
      "whatsapp_url": "https://wa.me/+528004005556",
      "phone": "800-400-5556"
    },
    "policies": {
      "privacy_policy_url": "https://bellezalatina.life/aviso-de-privacidad",
      "terms_url": "https://bellezalatina.life/terminos-y-condiciones",
      "cancellation_policy": "Free cancellation with 24+ hours notice. $500 MXN penalty for late cancellation or no-show.",
      "satisfaction_guarantee": "5-step protocol: clinical review within 30 days, medical committee evaluation, solution proposal, refund if applicable.",
      "legal_entity": "Naturalmente Tú SA de CV",
      "jurisdiction": "Cancún, Quintana Roo, México"
    }
  }
}
