{"openapi":"3.1.0","info":{"title":"API de CallChat IA","version":"1.0.0","description":"Consulta huecos, haz y anula reservas y habla con la secretaria desde tu web o tu programa. Las fechas y horas van en la hora del negocio (AAAA-MM-DD HH:MM). Úsala desde tu servidor: la clave no debe ir nunca en una página web."},"servers":[{"url":"https://chat.callchatia.com"}],"security":[{"clave":[]}],"components":{"securitySchemes":{"clave":{"type":"http","scheme":"bearer","description":"Clave creada en el panel: API y claves (empieza por cc_)."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"codigo":{"type":"string"},"mensaje":{"type":"string"}}}}},"Negocio":{"type":"object","properties":{"nombre":{"type":"string"},"sector":{"type":"string"},"modo":{"type":"string","enum":["cita","mesa"]},"direccion":{"type":["string","null"]},"telefono":{"type":["string","null"]},"web":{"type":["string","null"]},"zona_horaria":{"type":"string"},"hoy":{"type":"string"},"horario":{"type":"array","items":{"type":"object","properties":{"dia":{"type":"integer","description":"1 = lunes … 7 = domingo"},"dia_nombre":{"type":"string"},"desde":{"type":"string"},"hasta":{"type":"string"}}}},"cierres":{"type":"array","items":{"type":"object"}}}},"Servicios":{"type":"object","properties":{"servicios":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"nombre":{"type":"string"},"descripcion":{"type":["string","null"]},"duracion_min":{"type":"integer"},"precio":{"type":["number","null"]},"precio_texto":{"type":["string","null"]},"por_personas":{"type":"boolean","description":"true: reserva de mesa (se indica el número de personas)"}}}}}},"Huecos":{"type":"object","properties":{"fecha":{"type":"string"},"dia":{"type":"string"},"personas":{"type":"integer"},"huecos":{"type":"array","items":{"type":"object","properties":{"hora":{"type":"string","example":"21:30"},"inicio":{"type":"string","example":"2026-11-27 21:30"}}}}}},"Reserva":{"type":"object","properties":{"id":{"type":"integer"},"servicio":{"type":"string"},"servicio_id":{"type":"integer"},"inicio":{"type":"string"},"fin":{"type":"string"},"personas":{"type":"integer"},"estado":{"type":"string","enum":["pendiente","confirmada","cancelada","completada","no_presentado"]},"nombre":{"type":["string","null"]},"telefono":{"type":["string","null"]},"origen":{"type":"string"},"notas":{"type":["string","null"]}}},"Reservas":{"type":"object","properties":{"desde":{"type":"string"},"hasta":{"type":"string"},"hay_mas":{"type":"boolean"},"reservas":{"type":"array","items":{"$ref":"#/components/schemas/Reserva"}}}},"NuevaReserva":{"type":"object","required":["servicio","inicio","nombre","telefono"],"properties":{"servicio":{"type":"integer"},"inicio":{"type":"string","example":"2026-11-27 21:30"},"personas":{"type":"integer","default":1},"nombre":{"type":"string"},"telefono":{"type":"string","example":"+34 600 123 456"},"notas":{"type":"string"}}},"Mensaje":{"type":"object","required":["telefono","texto"],"properties":{"telefono":{"type":"string","description":"Identifica la conversación del cliente"},"nombre":{"type":"string"},"texto":{"type":"string"}}},"Respuesta":{"type":"object","properties":{"conversacion_id":{"type":"integer"},"respuestas":{"type":"array","items":{"type":"object","properties":{"texto":{"type":"string"},"botones":{"type":"array","items":{"type":"string"}}}}},"documentos":{"type":"array","items":{"type":"object","properties":{"nombre":{"type":"string"},"url":{"type":"string"}}}},"reservas":{"type":"array","items":{"type":"object","properties":{"tipo":{"type":"string"},"id":{"type":"integer"},"servicio":{"type":"string"},"inicio":{"type":"string"}}}},"con_persona":{"type":"boolean","description":"true: la conversación la lleva una persona del equipo y la secretaria no contesta"}}}}},"paths":{"/api/v1/negocio":{"get":{"summary":"Datos del negocio, horario y cierres (permiso leer)","responses":{"200":{"description":"Correcto","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Negocio"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/servicios":{"get":{"summary":"Servicios que se pueden reservar (permiso leer)","responses":{"200":{"description":"Correcto","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Servicios"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/huecos":{"get":{"summary":"Horas libres de un día (permiso leer)","parameters":[{"name":"servicio","in":"query","required":true,"schema":{"type":"integer"}},{"name":"fecha","in":"query","required":true,"schema":{"type":"string","example":"2026-11-27"}},{"name":"personas","in":"query","schema":{"type":"integer","default":1}}],"responses":{"200":{"description":"Correcto","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Huecos"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/reservas":{"get":{"summary":"Reservas de un periodo (permiso reservas; como mucho 92 días y 500 reservas: hay_mas = true si hay más)","parameters":[{"name":"desde","in":"query","schema":{"type":"string"}},{"name":"hasta","in":"query","schema":{"type":"string"}},{"name":"telefono","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Correcto","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Reservas"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Hacer una reserva (permiso reservar)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NuevaReserva"}}}},"responses":{"201":{"description":"Creada (confirmada, o pendiente si el negocio aprueba las reservas a mano)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Reserva"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/reservas/{id}":{"get":{"summary":"Una reserva (permiso reservas)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Correcto","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Reserva"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/reservas/{id}/anular":{"post":{"summary":"Anular una reserva (permiso reservar). Con el teléfono de la reserva.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["telefono"],"properties":{"telefono":{"type":"string"}}}}}},"responses":{"200":{"description":"Correcto","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Reserva"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/mensajes":{"get":{"summary":"Lo nuevo de la conversación de un cliente (permiso mensajes)","parameters":[{"name":"telefono","in":"query","required":true,"schema":{"type":"string"}},{"name":"desde","in":"query","schema":{"type":"integer","description":"Último id de mensaje que ya tienes"}}],"responses":{"200":{"description":"Mensajes nuevos","content":{"application/json":{"schema":{"type":"object","properties":{"conversacion_id":{"type":["integer","null"]},"con_persona":{"type":"boolean"},"mensajes":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"de":{"type":"string","enum":["cliente","secretaria","equipo"]},"texto":{"type":"string"},"cuando":{"type":"string"}}}}}}}}}}},"post":{"summary":"Hablar con la secretaria por escrito (permiso mensajes; gasta IA)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Mensaje"}}}},"responses":{"200":{"description":"Correcto","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Respuesta"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}