{
  "openapi": "3.1.0",
  "info": {
    "title": "API de MiHoraYa",
    "version": "2026-11-24",
    "summary": "Conecta tu sitio web, CRM, ERP o automatizaciones con tu agenda de MiHoraYa.",
    "description": "API REST para los negocios que usan MiHoraYa y sus desarrolladores. Con ella puedes leer tu catálogo,\nconsultar disponibilidad, crear y gestionar reservas y clientes, y recibir webhooks firmados cuando algo cambia.\n\n- **Base:** `https://api.mihoraya.com/v1` (la versión va en la ruta).\n- **Formato:** JSON en UTF-8. Fechas en RFC 3339 con el desfase de la zona horaria del negocio\n  (por ejemplo `2026-12-01T10:00:00-03:00`). Montos como enteros en la unidad mínima de la moneda\n  (`{\"amount\": 15000, \"currency\": \"CLP\"}`; para USD, `1999` = US$ 19,99).\n- **Autenticación:** `Authorization: Bearer mhy_live_…` con una API key creada en el panel.\n- **Errores:** siempre `{\"error\": {\"type\", \"code\", \"message\", \"param\", \"request_id\"}}`.\n- **Cada respuesta** trae `X-Request-Id`: inclúyelo si nos escribes a soporte.\n\nDisponible en el Plan Total (función `api_access`; los webhooks, función `webhooks`).\n",
    "contact": {
      "name": "Soporte MiHoraYa",
      "email": "contacto@mihoraya.com",
      "url": "https://mihoraya.com/desarrolladores"
    },
    "termsOfService": "https://mihoraya.com/terminos"
  },
  "servers": [
    {
      "url": "https://api.mihoraya.com/v1",
      "description": "Producción (las claves mhy_test_ simulan las escrituras)"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Negocio",
      "description": "Datos del negocio dueño de la API key y sus locales.",
      "x-slug": "negocio"
    },
    {
      "name": "Catálogo",
      "description": "Servicios, categorías y profesionales.",
      "x-slug": "catalogo"
    },
    {
      "name": "Disponibilidad",
      "description": "Horas libres para reservar.",
      "x-slug": "disponibilidad"
    },
    {
      "name": "Reservas",
      "description": "Crear, consultar, reagendar, confirmar y cancelar reservas.",
      "x-slug": "reservas"
    },
    {
      "name": "Clientes",
      "description": "Clientes del negocio (búsqueda por email o teléfono, alta y edición).",
      "x-slug": "clientes"
    },
    {
      "name": "Webhooks",
      "description": "Endpoints que reciben eventos firmados y el registro de eventos.",
      "x-slug": "webhooks-api"
    },
    {
      "name": "Especificación",
      "description": "Este documento en formato JSON.",
      "x-slug": "especificacion"
    }
  ],
  "paths": {
    "/openapi.json": {
      "get": {
        "operationId": "getOpenAPI",
        "tags": [
          "Especificación"
        ],
        "summary": "Obtener la especificación OpenAPI",
        "description": "Devuelve esta especificación OpenAPI 3.1 en JSON. No requiere autenticación.",
        "security": [],
        "responses": {
          "200": {
            "description": "Especificación OpenAPI 3.1.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/business": {
      "get": {
        "operationId": "getBusiness",
        "tags": [
          "Negocio"
        ],
        "summary": "Obtener el negocio",
        "description": "Devuelve el negocio al que pertenece la API key (zona horaria, moneda y enlace de reservas).",
        "x-scopes": [
          "business:read"
        ],
        "responses": {
          "200": {
            "description": "El negocio.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Business"
                },
                "example": {
                  "id": 42,
                  "object": "business",
                  "name": "Estudio Lumière",
                  "slug": "estudio-lumiere",
                  "description": "Peluquería y estética en Providencia.",
                  "industry": "peluqueria",
                  "country": "CL",
                  "time_zone": "America/Santiago",
                  "currency": {
                    "code": "CLP",
                    "decimals": 0
                  },
                  "logo_url": "",
                  "booking_url": "https://mihoraya.com/estudio-lumiere",
                  "livemode": true,
                  "created_at": "2026-03-02T09:15:00-03:00"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/locations": {
      "get": {
        "operationId": "listLocations",
        "tags": [
          "Negocio"
        ],
        "summary": "Listar locales",
        "description": "Locales (sucursales) del negocio con su horario semanal.",
        "x-scopes": [
          "business:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Página de locales.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 7,
                      "object": "location",
                      "name": "Providencia",
                      "address": "Av. Providencia 1234, Santiago",
                      "phone": "+56 2 2345 6789",
                      "email": "providencia@example.com",
                      "description": "",
                      "time_zone": "America/Santiago",
                      "hours": [
                        {
                          "weekday": 1,
                          "opens": "09:00",
                          "closes": "20:00",
                          "closed": false
                        },
                        {
                          "weekday": 0,
                          "opens": "09:00",
                          "closes": "14:00",
                          "closed": true
                        }
                      ],
                      "created_at": "2026-03-02T09:15:00-03:00"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/locations/{id}": {
      "get": {
        "operationId": "getLocation",
        "tags": [
          "Negocio"
        ],
        "summary": "Obtener un local",
        "x-scopes": [
          "business:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "El local.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Location"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/service_categories": {
      "get": {
        "operationId": "listServiceCategories",
        "tags": [
          "Catálogo"
        ],
        "summary": "Listar categorías de servicios",
        "x-scopes": [
          "services:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Página de categorías.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategoryList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 3,
                      "object": "service_category",
                      "name": "Cortes",
                      "position": 0
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/services": {
      "get": {
        "operationId": "listServices",
        "tags": [
          "Catálogo"
        ],
        "summary": "Listar servicios",
        "description": "Servicios del negocio con su duración, precio y los profesionales que los atienden.",
        "x-scopes": [
          "services:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "active",
            "in": "query",
            "description": "Solo activos (`true`) o inactivos (`false`).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "category_id",
            "in": "query",
            "description": "Filtra por categoría.",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "professional_id",
            "in": "query",
            "description": "Solo los servicios que atiende ese profesional.",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de servicios.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 15,
                      "object": "service",
                      "name": "Corte y peinado",
                      "description": "Lavado, corte y brushing.",
                      "category_id": 3,
                      "duration_minutes": 60,
                      "price": {
                        "amount": 15000,
                        "currency": "CLP"
                      },
                      "active": true,
                      "online_booking": true,
                      "video": false,
                      "photo_url": "",
                      "professional_ids": [
                        21,
                        22
                      ],
                      "created_at": "2026-03-02T09:20:00-03:00"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/services/{id}": {
      "get": {
        "operationId": "getService",
        "tags": [
          "Catálogo"
        ],
        "summary": "Obtener un servicio",
        "x-scopes": [
          "services:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "El servicio.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Service"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/professionals": {
      "get": {
        "operationId": "listProfessionals",
        "tags": [
          "Catálogo"
        ],
        "summary": "Listar profesionales",
        "description": "Profesionales del equipo (sin datos de contacto personales).",
        "x-scopes": [
          "professionals:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "location_id",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "service_id",
            "in": "query",
            "description": "Solo los que atienden ese servicio.",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de profesionales.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfessionalList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 21,
                      "object": "professional",
                      "name": "Camila Rojas",
                      "initials": "CR",
                      "bio": "Estilista con 10 años de experiencia.",
                      "photo_url": "",
                      "active": true,
                      "accepts_online": true,
                      "location_id": 7,
                      "service_ids": [
                        15,
                        16
                      ],
                      "created_at": "2026-03-02T09:18:00-03:00"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/professionals/{id}": {
      "get": {
        "operationId": "getProfessional",
        "tags": [
          "Catálogo"
        ],
        "summary": "Obtener un profesional",
        "x-scopes": [
          "professionals:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "El profesional.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Professional"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/availability": {
      "get": {
        "operationId": "getAvailability",
        "tags": [
          "Disponibilidad"
        ],
        "summary": "Consultar horas libres",
        "description": "Horas de inicio libres por día para un servicio, en la zona horaria del negocio (máximo 31 días por consulta).\nCada hora indica qué profesionales están libres. `channel=online` (por defecto) aplica las reglas de la\nreserva en línea del negocio (anticipación mínima, ventana máxima, profesionales que aceptan reservas en\nlínea); `channel=staff` usa las de la agenda interna.\n",
        "x-scopes": [
          "availability:read"
        ],
        "parameters": [
          {
            "name": "service_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "professional_id",
            "in": "query",
            "description": "Un profesional en particular (omítelo para \"cualquiera\").",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "location_id",
            "in": "query",
            "description": "Local (por defecto, el principal).",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "description": "Primer día (YYYY-MM-DD, zona del negocio). Por defecto, hoy.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "description": "Último día, inclusive (YYYY-MM-DD). Por defecto, igual a date_from.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "online",
                "staff"
              ],
              "default": "online"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Disponibilidad por día.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Availability"
                },
                "example": {
                  "object": "availability",
                  "service_id": 15,
                  "professional_id": null,
                  "location_id": 7,
                  "channel": "online",
                  "time_zone": "America/Santiago",
                  "duration_minutes": 60,
                  "days": [
                    {
                      "date": "2026-12-01",
                      "slots": [
                        {
                          "starts_at": "2026-12-01T10:00:00-03:00",
                          "ends_at": "2026-12-01T11:00:00-03:00",
                          "professional_ids": [
                            21,
                            22
                          ]
                        },
                        {
                          "starts_at": "2026-12-01T10:30:00-03:00",
                          "ends_at": "2026-12-01T11:30:00-03:00",
                          "professional_ids": [
                            22
                          ]
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/appointments": {
      "get": {
        "operationId": "listAppointments",
        "tags": [
          "Reservas"
        ],
        "summary": "Listar reservas",
        "description": "Reservas ordenadas por hora de inicio (y luego por id). Usa `updated_since` para sincronizar cambios.",
        "x-scopes": [
          "appointments:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "date_from",
            "in": "query",
            "description": "Desde (inclusive). Fecha YYYY-MM-DD (medianoche del negocio) o instante RFC 3339.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "description": "Hasta. Con fecha YYYY-MM-DD incluye todo ese día; con instante RFC 3339, excluye ese instante.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Uno o varios estados separados por coma.",
            "schema": {
              "type": "string",
              "example": "scheduled,confirmed"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "description": "Solo reservas modificadas desde este instante (RFC 3339).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "professional_id",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "location_id",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "service_id",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "$ref": "#/components/parameters/ExpandAppointment"
          }
        ],
        "responses": {
          "200": {
            "description": "Página de reservas.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppointmentList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 987,
                      "object": "appointment",
                      "status": "scheduled",
                      "starts_at": "2026-12-01T10:00:00-03:00",
                      "ends_at": "2026-12-01T11:00:00-03:00",
                      "duration_minutes": 60,
                      "time_zone": "America/Santiago",
                      "service_id": 15,
                      "professional_id": 21,
                      "location_id": 7,
                      "client_id": 3301,
                      "price": {
                        "amount": 15000,
                        "currency": "CLP"
                      },
                      "notes": "Reservado desde el sitio web",
                      "source": "api",
                      "confirmed_at": null,
                      "attended_at": null,
                      "no_show_at": null,
                      "cancellation": null,
                      "created_at": "2026-11-24T12:00:00-03:00",
                      "updated_at": "2026-11-24T12:00:00-03:00",
                      "livemode": true
                    }
                  ],
                  "has_more": true,
                  "next_cursor": "eyJpIjo5ODcsInQiOiIyMDI2LTEyLTAxVDEzOjAwOjAwWiJ9"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "createAppointment",
        "tags": [
          "Reservas"
        ],
        "summary": "Crear una reserva",
        "description": "Crea una reserva con la misma garantía que la agenda: dos reservas nunca se superponen, aunque lleguen\nal mismo tiempo. Si la hora ya se tomó responde `409` con `code: slot_unavailable`.\n\nExige la cabecera `Idempotency-Key`: si repites la petición (por ejemplo, tras un corte de red) con la\nmisma clave y los mismos datos, recibes la reserva ya creada (`200` con `Idempotent-Replayed: true`)\nen vez de crear otra. Con la misma clave y otros datos, `422 idempotency_key_reused`.\n\nSin `professional_id` se asigna el primer profesional libre a esa hora. El cliente se identifica con\n`client_id` o con `client` (se busca por email o teléfono y, si no existe, se crea).\n\nCon una clave de prueba (`mhy_test_`) la reserva se valida completa pero **no se guarda** ni se notifica\n(cabecera `MiHoraYa-Simulated: true`, `livemode: false`).\n",
        "x-scopes": [
          "appointments:write"
        ],
        "x-idempotency": "required",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentCreate"
              },
              "example": {
                "service_id": 15,
                "professional_id": 21,
                "starts_at": "2026-12-01T10:00:00-03:00",
                "client": {
                  "name": "Martina Soto",
                  "email": "martina.soto@example.com",
                  "phone": "+56 9 6123 4587"
                },
                "notes": "Reservado desde el sitio web"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Reserva creada.",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                },
                "description": "Ruta de la reserva creada."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                },
                "examples": {
                  "creada": {
                    "$ref": "#/components/examples/AppointmentExample"
                  }
                }
              }
            }
          },
          "200": {
            "description": "Reintento con la misma Idempotency-Key (se devuelve la reserva ya creada).",
            "headers": {
              "Idempotent-Replayed": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "La hora ya no está disponible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "slot_unavailable",
                    "message": "La hora pedida ya no está disponible. Consulta GET /v1/availability y elige otra.",
                    "param": "starts_at",
                    "request_id": "api-1/abc123-000042"
                  }
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/appointments/{id}": {
      "get": {
        "operationId": "getAppointment",
        "tags": [
          "Reservas"
        ],
        "summary": "Obtener una reserva",
        "x-scopes": [
          "appointments:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/ExpandAppointment"
          }
        ],
        "responses": {
          "200": {
            "description": "La reserva.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                },
                "examples": {
                  "reserva": {
                    "$ref": "#/components/examples/AppointmentExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "updateAppointment",
        "tags": [
          "Reservas"
        ],
        "summary": "Reagendar o editar una reserva",
        "description": "Cambia la hora (`starts_at`) o el profesional (reagendar, con la misma garantía anti-superposición: `409\nslot_unavailable` si no se puede) y las notas. Al reagendar, una reserva confirmada vuelve a `scheduled` y\nel cliente recibe el aviso de cambio. Genera el evento `appointment.rescheduled` (o `appointment.updated`).\n",
        "x-scopes": [
          "appointments:write"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentUpdate"
              },
              "example": {
                "starts_at": "2026-12-02T16:00:00-03:00"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reserva actualizada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/appointments/{id}/cancel": {
      "post": {
        "operationId": "cancelAppointment",
        "tags": [
          "Reservas"
        ],
        "summary": "Cancelar una reserva",
        "description": "Cancela la reserva a nombre del negocio y libera la hora. Por defecto el cliente recibe el aviso de cancelación.",
        "x-scopes": [
          "appointments:write"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentCancel"
              },
              "example": {
                "reason": "El cliente pidió cancelar por teléfono"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reserva cancelada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/appointments/{id}/confirm": {
      "post": {
        "operationId": "confirmAppointment",
        "tags": [
          "Reservas"
        ],
        "summary": "Confirmar una reserva",
        "description": "Marca la asistencia como confirmada (sin correo al cliente). Si ya estaba confirmada, la devuelve igual.",
        "x-scopes": [
          "appointments:write"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Reserva confirmada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/clients": {
      "get": {
        "operationId": "listClients",
        "tags": [
          "Clientes"
        ],
        "summary": "Listar o buscar clientes",
        "description": "Busca por `email` (exacto), `phone` (compara los dígitos) o `q` (nombre o email que contiene el texto).",
        "x-scopes": [
          "clients:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "email",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "email"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "created_since",
            "in": "query",
            "description": "Solo clientes creados desde esta fecha o instante.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de clientes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 3301,
                      "object": "client",
                      "name": "Martina Soto",
                      "email": "martina.soto@example.com",
                      "phone": "+56961234587",
                      "national_id": "",
                      "address": "",
                      "district": "",
                      "city": "",
                      "birthdate": null,
                      "gender": "",
                      "notes": "",
                      "tags": [
                        "web"
                      ],
                      "source": "api",
                      "blocked": false,
                      "created_at": "2026-11-24T12:00:00-03:00",
                      "last_activity_at": "2026-11-24T12:00:00-03:00",
                      "livemode": true
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "createClient",
        "tags": [
          "Clientes"
        ],
        "summary": "Crear un cliente",
        "description": "Crea un cliente. Si ya existe uno con el mismo email responde `409 client_exists` con `existing_id`.\nAcepta `Idempotency-Key` (opcional): el reintento con la misma clave y el mismo cuerpo devuelve la misma respuesta.\n",
        "x-scopes": [
          "clients:write"
        ],
        "x-idempotency": "optional",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientCreate"
              },
              "example": {
                "name": "Martina Soto",
                "email": "martina.soto@example.com",
                "phone": "+56 9 6123 4587",
                "tags": [
                  "web"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Cliente creado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Client"
                },
                "examples": {
                  "cliente": {
                    "$ref": "#/components/examples/ClientExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/clients/{id}": {
      "get": {
        "operationId": "getClient",
        "tags": [
          "Clientes"
        ],
        "summary": "Obtener un cliente",
        "x-scopes": [
          "clients:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "El cliente.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Client"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "updateClient",
        "tags": [
          "Clientes"
        ],
        "summary": "Editar un cliente",
        "description": "Solo cambian los campos enviados. `tags` reemplaza la lista completa.",
        "x-scopes": [
          "clients:write"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientUpdate"
              },
              "example": {
                "phone": "+56 9 8765 4321",
                "tags": [
                  "web",
                  "frecuente"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cliente actualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Client"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "listEvents",
        "tags": [
          "Webhooks"
        ],
        "summary": "Listar eventos",
        "description": "Eventos de los últimos 30 días, del más nuevo al más antiguo. Sirve para recuperar lo que tu sistema no\nalcanzó a procesar. Solo aparecen los tipos que la clave puede leer (reservas con `appointments:read`,\nclientes con `clients:read`).\n",
        "x-scopes": [
          "webhooks:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/EventType"
            }
          },
          {
            "name": "created_since",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de eventos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/events/{id}": {
      "get": {
        "operationId": "getEvent",
        "tags": [
          "Webhooks"
        ],
        "summary": "Obtener un evento",
        "x-scopes": [
          "webhooks:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "El evento.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                },
                "examples": {
                  "evento": {
                    "$ref": "#/components/examples/EventExample"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhook_endpoints": {
      "get": {
        "operationId": "listWebhookEndpoints",
        "tags": [
          "Webhooks"
        ],
        "summary": "Listar endpoints de webhook",
        "x-scopes": [
          "webhooks:read"
        ],
        "responses": {
          "200": {
            "description": "Todos los endpoints del negocio (máximo 10).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "createWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Crear un endpoint de webhook",
        "description": "Registra una URL `https://` pública que recibirá los eventos elegidos (`[\"*\"]` = todos). La respuesta\nincluye `secret` (whsec_…) para verificar la firma: guárdalo, no se vuelve a mostrar por la API.\nPara suscribirte a eventos de reservas la clave necesita `appointments:read`; a los de clientes, `clients:read`.\nNo se aceptan direcciones privadas, locales ni reservadas.\n",
        "x-scopes": [
          "webhooks:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointCreate"
              },
              "example": {
                "url": "https://crm.example.com/webhooks/mihoraya",
                "events": [
                  "appointment.created",
                  "appointment.cancelled",
                  "appointment.rescheduled"
                ],
                "description": "CRM"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Endpoint creado (con su secreto).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                },
                "example": {
                  "id": 5,
                  "object": "webhook_endpoint",
                  "url": "https://crm.example.com/webhooks/mihoraya",
                  "description": "CRM",
                  "events": [
                    "appointment.created",
                    "appointment.cancelled",
                    "appointment.rescheduled"
                  ],
                  "status": "enabled",
                  "disabled_reason": "",
                  "consecutive_failures": 0,
                  "last_success_at": null,
                  "last_failure_at": null,
                  "created_at": "2026-11-24T12:00:00-03:00",
                  "updated_at": "2026-11-24T12:00:00-03:00",
                  "secret": "whsec_3kT9pQ2xV7mN1bL8cR4sY6dF0gH5jK2a",
                  "livemode": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhook_endpoints/{id}": {
      "get": {
        "operationId": "getWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Obtener un endpoint de webhook",
        "x-scopes": [
          "webhooks:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "El endpoint (sin el secreto).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "updateWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Editar un endpoint de webhook",
        "description": "Cambia URL, eventos, descripción o estado. `status=enabled` reactiva un endpoint desactivado (por ti o por fallos) y reinicia el contador de fallos.",
        "x-scopes": [
          "webhooks:write"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointUpdate"
              },
              "example": {
                "status": "enabled"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Endpoint actualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "deleteWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Eliminar un endpoint de webhook",
        "x-scopes": [
          "webhooks:write"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Eliminado.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "example": {
                  "id": 5,
                  "object": "webhook_endpoint",
                  "deleted": true,
                  "livemode": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhook_endpoints/{id}/test": {
      "post": {
        "operationId": "testWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Enviar un evento de prueba",
        "description": "Envía al endpoint, en el acto, un evento de prueba firmado (`livemode: false`): `ping` por defecto o un\nejemplo ficticio del tipo pedido. Devuelve el resultado de la entrega. Máximo 10 pruebas por minuto.\n",
        "x-scopes": [
          "webhooks:write"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "type": {
                    "description": "`ping` o un tipo de evento.",
                    "type": "string",
                    "default": "ping"
                  }
                }
              },
              "example": {
                "type": "appointment.created"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resultado de la entrega de prueba.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                },
                "example": {
                  "id": 77,
                  "object": "webhook_delivery",
                  "endpoint_id": 5,
                  "event_id": 1201,
                  "event_type": "ping",
                  "status": "succeeded",
                  "attempts": 1,
                  "response_status": 200,
                  "response_body": "ok",
                  "error": "",
                  "duration_ms": 182,
                  "created_at": "2026-11-24T12:01:00-03:00",
                  "last_attempt_at": "2026-11-24T12:01:00-03:00",
                  "next_attempt_at": null,
                  "delivered_at": "2026-11-24T12:01:00-03:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "webhooks": {
    "appointmentEvent": {
      "post": {
        "operationId": "receiveEvent",
        "summary": "Evento enviado a tu endpoint",
        "description": "MiHoraYa hace un `POST` con el evento en JSON a cada endpoint suscrito. Responde con un código `2xx` en menos\nde 15 segundos; si no, se reintenta con espera creciente (1 min, 5 min, 30 min, 1 h, 2 h, 4 h, 6 h y 10 h:\n9 intentos en unas 24 horas). Verifica la cabecera `MiHoraYa-Signature` antes de procesarlo y deduplica por\n`id` (un mismo evento puede llegar más de una vez).\n",
        "security": [],
        "parameters": [
          {
            "name": "MiHoraYa-Signature",
            "in": "header",
            "required": true,
            "description": "`t=<unix>,v1=<hex HMAC-SHA256(secreto, t + \".\" + cuerpo)>`",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "MiHoraYa-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "MiHoraYa-Event-Type",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "MiHoraYa-Delivery-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "MiHoraYa-Delivery-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Event"
              },
              "examples": {
                "evento": {
                  "$ref": "#/components/examples/EventExample"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recibido (cualquier 2xx)."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mhy_live_… / mhy_test_…",
        "description": "API key del negocio, creada en el panel (Integraciones > API y webhooks)."
      }
    },
    "headers": {
      "X-Request-Id": {
        "description": "Identificador de la petición (inclúyelo al escribir a soporte).",
        "schema": {
          "type": "string"
        }
      },
      "RateLimit-Limit": {
        "description": "Llamadas permitidas por minuto para esta API key.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Remaining": {
        "description": "Llamadas que quedan en la ventana actual.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimit-Reset": {
        "description": "Segundos hasta que se reinicia la ventana.",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Segundos que debes esperar antes de reintentar.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "parameters": {
      "Id": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "description": "Elementos por página (1 a 100).",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 25
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "description": "Valor `next_cursor` de la página anterior.",
        "schema": {
          "type": "string"
        }
      },
      "ExpandAppointment": {
        "name": "expand",
        "in": "query",
        "description": "Agrega los objetos relacionados (separados por coma).",
        "style": "form",
        "explode": false,
        "schema": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "client",
              "service",
              "professional",
              "location"
            ]
          }
        }
      },
      "IdempotencyKeyRequired": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Clave única por intento (p. ej. un UUID v4), hasta 80 caracteres ASCII.",
        "schema": {
          "type": "string",
          "maxLength": 80
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Opcional. Clave única por intento (p. ej. un UUID v4), hasta 80 caracteres ASCII.",
        "schema": {
          "type": "string",
          "maxLength": 80
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Parámetros inválidos (`parameter_invalid`, `parameter_missing`, `parameter_unknown`, `invalid_body`, `idempotency_key_required`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "invalid_request_error",
                "code": "parameter_invalid",
                "message": "limit debe ser un entero entre 1 y 100.",
                "param": "limit",
                "request_id": "api-1/abc123-000042"
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "API key ausente, inválida (`invalid_api_key`), revocada (`api_key_revoked`) o vencida (`api_key_expired`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "authentication_error",
                "code": "api_key_revoked",
                "message": "Esta API key fue revocada. Crea una nueva en Integraciones > API y webhooks.",
                "request_id": "api-1/abc123-000043"
              }
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "El plan del negocio no incluye la API (`feature_locked`) o se alcanzó un límite del plan (`limit_reached`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "plan_error",
                "code": "feature_locked",
                "message": "Esta función está disponible en el Plan Total.",
                "feature": "api_access",
                "required_plan": "plan50",
                "request_id": "api-1/abc123-000044"
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "La API key no tiene el permiso necesario (`insufficient_scope`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "permission_error",
                "code": "insufficient_scope",
                "message": "Esta API key no tiene el permiso appointments:write.",
                "required_scope": "appointments:write",
                "request_id": "api-1/abc123-000045"
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "El recurso no existe o es de otro negocio (`resource_not_found`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "invalid_request_error",
                "code": "resource_not_found",
                "message": "Reserva no encontrado.",
                "request_id": "api-1/abc123-000046"
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflicto con el estado actual (`slot_unavailable`, `appointment_cancelled`, `client_exists`, `idempotency_in_progress`, `conflict`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "La Idempotency-Key ya se usó con otros datos (`idempotency_key_reused`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Se superó el límite por minuto (`rate_limited`) o la cuota mensual del plan (`quota_exceeded`).",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          },
          "RateLimit-Limit": {
            "$ref": "#/components/headers/RateLimit-Limit"
          },
          "RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimit-Remaining"
          },
          "RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimit-Reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "rate_limit_error",
                "code": "rate_limited",
                "message": "Superaste el límite de 120 llamadas por minuto de esta API key. Reintenta en 12 s.",
                "request_id": "api-1/abc123-000047"
              }
            }
          }
        }
      }
    },
    "examples": {
      "AppointmentExample": {
        "summary": "Reserva",
        "value": {
          "id": 987,
          "object": "appointment",
          "status": "scheduled",
          "starts_at": "2026-12-01T10:00:00-03:00",
          "ends_at": "2026-12-01T11:00:00-03:00",
          "duration_minutes": 60,
          "time_zone": "America/Santiago",
          "service_id": 15,
          "professional_id": 21,
          "location_id": 7,
          "client_id": 3301,
          "price": {
            "amount": 15000,
            "currency": "CLP"
          },
          "notes": "Reservado desde el sitio web",
          "source": "api",
          "confirmed_at": null,
          "attended_at": null,
          "no_show_at": null,
          "cancellation": null,
          "created_at": "2026-11-24T12:00:00-03:00",
          "updated_at": "2026-11-24T12:00:00-03:00",
          "livemode": true
        }
      },
      "ClientExample": {
        "summary": "Cliente",
        "value": {
          "id": 3301,
          "object": "client",
          "name": "Martina Soto",
          "email": "martina.soto@example.com",
          "phone": "+56961234587",
          "national_id": "",
          "address": "",
          "district": "",
          "city": "",
          "birthdate": null,
          "gender": "",
          "notes": "",
          "tags": [
            "web"
          ],
          "source": "api",
          "blocked": false,
          "created_at": "2026-11-24T12:00:00-03:00",
          "last_activity_at": "2026-11-24T12:00:00-03:00",
          "livemode": true
        }
      },
      "EventExample": {
        "summary": "Evento appointment.rescheduled",
        "value": {
          "id": 1200,
          "object": "event",
          "type": "appointment.rescheduled",
          "api_version": "2026-11-24",
          "created_at": "2026-11-24T15:30:00-03:00",
          "livemode": true,
          "data": {
            "object": {
              "id": 987,
              "object": "appointment",
              "status": "scheduled",
              "starts_at": "2026-12-02T16:00:00-03:00",
              "ends_at": "2026-12-02T17:00:00-03:00",
              "duration_minutes": 60,
              "time_zone": "America/Santiago",
              "service_id": 15,
              "professional_id": 21,
              "location_id": 7,
              "client_id": 3301,
              "price": {
                "amount": 15000,
                "currency": "CLP"
              },
              "notes": "Reservado desde el sitio web",
              "source": "api",
              "confirmed_at": null,
              "attended_at": null,
              "no_show_at": null,
              "cancellation": null,
              "created_at": "2026-11-24T12:00:00-03:00",
              "updated_at": "2026-11-24T15:30:00-03:00",
              "livemode": true
            },
            "previous_attributes": {
              "starts_at": "2026-12-01T10:00:00-03:00"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "type",
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "invalid_request_error",
                  "authentication_error",
                  "permission_error",
                  "plan_error",
                  "rate_limit_error",
                  "api_error"
                ]
              },
              "code": {
                "type": "string",
                "description": "Código estable, pensado para tu código (ver la página de errores)."
              },
              "message": {
                "type": "string",
                "description": "Explicación en español, para personas."
              },
              "param": {
                "type": "string",
                "description": "Parámetro o campo relacionado, si aplica."
              },
              "request_id": {
                "type": "string"
              }
            },
            "additionalProperties": true
          }
        }
      },
      "Money": {
        "type": "object",
        "required": [
          "amount",
          "currency"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Monto en la unidad mínima de la moneda (CLP sin decimales; USD en centavos)."
          },
          "currency": {
            "type": "string",
            "description": "Código ISO 4217.",
            "example": "CLP"
          }
        }
      },
      "Business": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "business"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "industry": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "description": "ISO 3166-1 alfa-2"
          },
          "time_zone": {
            "type": "string",
            "description": "Zona IANA del negocio."
          },
          "currency": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "decimals": {
                "type": "integer"
              }
            }
          },
          "logo_url": {
            "type": "string"
          },
          "booking_url": {
            "type": "string",
            "format": "uri"
          },
          "livemode": {
            "type": "boolean",
            "description": "false con una clave de prueba."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OpeningHours": {
        "type": "object",
        "properties": {
          "weekday": {
            "type": "integer",
            "minimum": 0,
            "maximum": 6,
            "description": "0 = domingo … 6 = sábado"
          },
          "opens": {
            "type": "string",
            "example": "09:00"
          },
          "closes": {
            "type": "string",
            "example": "20:00"
          },
          "closed": {
            "type": "boolean"
          }
        }
      },
      "Location": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "location"
          },
          "name": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "time_zone": {
            "type": "string"
          },
          "hours": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpeningHours"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ServiceCategory": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "service_category"
          },
          "name": {
            "type": "string"
          },
          "position": {
            "type": "integer"
          }
        }
      },
      "Service": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "service"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "category_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "duration_minutes": {
            "type": "integer"
          },
          "price": {
            "$ref": "#/components/schemas/Money"
          },
          "active": {
            "type": "boolean"
          },
          "online_booking": {
            "type": "boolean",
            "description": "Se puede reservar en el sitio público."
          },
          "video": {
            "type": "boolean",
            "description": "Se atiende por videollamada."
          },
          "photo_url": {
            "type": "string"
          },
          "professional_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Professional": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "professional"
          },
          "name": {
            "type": "string"
          },
          "initials": {
            "type": "string"
          },
          "bio": {
            "type": "string"
          },
          "photo_url": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "accepts_online": {
            "type": "boolean"
          },
          "location_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "service_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AvailabilitySlot": {
        "type": "object",
        "properties": {
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "professional_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            }
          }
        }
      },
      "AvailabilityDay": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AvailabilitySlot"
            }
          }
        }
      },
      "Availability": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "availability"
          },
          "service_id": {
            "type": "integer",
            "format": "int64"
          },
          "professional_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "location_id": {
            "type": "integer",
            "format": "int64"
          },
          "channel": {
            "type": "string",
            "enum": [
              "online",
              "staff"
            ]
          },
          "time_zone": {
            "type": "string"
          },
          "duration_minutes": {
            "type": "integer"
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AvailabilityDay"
            }
          }
        }
      },
      "AppointmentStatus": {
        "type": "string",
        "enum": [
          "scheduled",
          "confirmed",
          "pending",
          "waiting",
          "attended",
          "no_show",
          "cancelled"
        ],
        "description": "`scheduled` agendada · `confirmed` asistencia confirmada · `pending` pendiente (p. ej. de pago) ·\n`waiting` en sala de espera · `attended` asistió · `no_show` no asistió · `cancelled` cancelada.\n"
      },
      "Cancellation": {
        "type": "object",
        "properties": {
          "cancelled_at": {
            "type": "string",
            "format": "date-time"
          },
          "reason": {
            "type": "string"
          },
          "cancelled_by": {
            "type": "string",
            "enum": [
              "business",
              "client"
            ]
          },
          "late": {
            "type": "boolean",
            "description": "Cancelación tardía según la política del negocio."
          }
        }
      },
      "Appointment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "appointment"
          },
          "status": {
            "$ref": "#/components/schemas/AppointmentStatus"
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "duration_minutes": {
            "type": "integer"
          },
          "time_zone": {
            "type": "string"
          },
          "service_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "professional_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "location_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "client_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "price": {
            "$ref": "#/components/schemas/Money"
          },
          "notes": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "online",
              "agenda",
              "api"
            ],
            "description": "Dónde se creó."
          },
          "confirmed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "attended_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "no_show_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "cancellation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Cancellation"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "livemode": {
            "type": "boolean"
          },
          "client": {
            "$ref": "#/components/schemas/Client",
            "description": "Con expand=client."
          },
          "service": {
            "$ref": "#/components/schemas/Service",
            "description": "Con expand=service."
          },
          "professional": {
            "$ref": "#/components/schemas/Professional",
            "description": "Con expand=professional."
          },
          "location": {
            "$ref": "#/components/schemas/Location",
            "description": "Con expand=location."
          }
        }
      },
      "AppointmentCreate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "service_id",
          "starts_at"
        ],
        "properties": {
          "service_id": {
            "type": "integer",
            "format": "int64"
          },
          "starts_at": {
            "type": "string",
            "format": "date-time",
            "description": "Inicio en RFC 3339 con desfase (una de las horas de GET /availability)."
          },
          "professional_id": {
            "type": "integer",
            "format": "int64",
            "description": "Omítelo para asignar el primer profesional libre."
          },
          "location_id": {
            "type": "integer",
            "format": "int64"
          },
          "client_id": {
            "type": "integer",
            "format": "int64",
            "description": "Cliente existente. Si no lo envías, usa `client`."
          },
          "client": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name"
            ],
            "description": "Se busca por email o teléfono; si no existe, se crea.",
            "properties": {
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "phone": {
                "type": "string"
              }
            }
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "status": {
            "type": "string",
            "enum": [
              "scheduled",
              "confirmed"
            ],
            "default": "scheduled"
          },
          "channel": {
            "type": "string",
            "enum": [
              "online",
              "staff"
            ],
            "default": "online",
            "description": "Reglas de disponibilidad que se aplican (ver GET /availability)."
          },
          "send_notifications": {
            "type": "boolean",
            "default": true,
            "description": "false = no envía los correos de confirmación al cliente ni al negocio."
          }
        }
      },
      "AppointmentUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "starts_at": {
            "type": "string",
            "format": "date-time",
            "description": "Nueva hora (reagendar)."
          },
          "professional_id": {
            "type": "integer",
            "format": "int64",
            "description": "Cambiar de profesional."
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          }
        }
      },
      "AppointmentCancel": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 500
          },
          "send_notifications": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "Client": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "client"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "national_id": {
            "type": "string",
            "description": "Documento de identidad (en Chile, RUT)."
          },
          "address": {
            "type": "string"
          },
          "district": {
            "type": "string",
            "description": "Comuna o barrio."
          },
          "city": {
            "type": "string"
          },
          "birthdate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "gender": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "source": {
            "type": "string",
            "enum": [
              "agenda",
              "online",
              "import",
              "whatsapp",
              "api"
            ]
          },
          "blocked": {
            "type": "boolean",
            "description": "Bloqueado para reservar en línea."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_activity_at": {
            "type": "string",
            "format": "date-time"
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "ClientCreate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "description": "Requiere email o phone.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "national_id": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "maxLength": 200
          },
          "district": {
            "type": "string",
            "maxLength": 80
          },
          "city": {
            "type": "string",
            "maxLength": 80
          },
          "birthdate": {
            "type": "string",
            "format": "date"
          },
          "gender": {
            "type": "string",
            "maxLength": 30
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "tags": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "maxLength": 40
            }
          }
        }
      },
      "ClientUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "national_id": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "maxLength": 200
          },
          "district": {
            "type": "string",
            "maxLength": 80
          },
          "city": {
            "type": "string",
            "maxLength": 80
          },
          "birthdate": {
            "type": "string",
            "description": "YYYY-MM-DD, o \"\" para borrarla."
          },
          "gender": {
            "type": "string",
            "maxLength": 30
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "tags": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "maxLength": 40
            }
          }
        }
      },
      "EventType": {
        "type": "string",
        "enum": [
          "appointment.created",
          "appointment.updated",
          "appointment.rescheduled",
          "appointment.confirmed",
          "appointment.cancelled",
          "appointment.deleted",
          "client.created",
          "client.updated"
        ]
      },
      "Event": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Úsalo para no procesar dos veces el mismo evento."
          },
          "object": {
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Tipo de evento (o `ping` en las pruebas).",
            "type": "string"
          },
          "api_version": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "livemode": {
            "type": "boolean",
            "description": "false en los eventos de prueba."
          },
          "data": {
            "type": "object",
            "properties": {
              "object": {
                "description": "El recurso tal como quedó (Appointment o Client).",
                "type": "object"
              },
              "previous_attributes": {
                "description": "Valores anteriores (en appointment.rescheduled).",
                "type": "object"
              }
            }
          }
        }
      },
      "WebhookEndpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "webhook_endpoint"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          },
          "disabled_reason": {
            "type": "string",
            "enum": [
              "",
              "manual",
              "failures"
            ]
          },
          "consecutive_failures": {
            "type": "integer"
          },
          "last_success_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_failure_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "secret": {
            "type": "string",
            "description": "Solo al crear. Clave para verificar MiHoraYa-Signature."
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "WebhookEndpointCreate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "url",
          "events"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "https:// pública"
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "description": "Un tipo de evento o \"*\" (todos)."
            }
          },
          "description": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "WebhookEndpointUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            }
          },
          "description": {
            "type": "string",
            "maxLength": 200
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string",
            "const": "webhook_delivery"
          },
          "endpoint_id": {
            "type": "integer",
            "format": "int64"
          },
          "event_id": {
            "type": "integer",
            "format": "int64"
          },
          "event_type": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "failed"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "response_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "response_body": {
            "type": "string",
            "description": "Primeros 1.024 bytes de la respuesta."
          },
          "error": {
            "type": "string"
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "next_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "delivered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Deleted": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "object": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean",
            "const": true
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "ListBase": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pásalo como `cursor` para la página siguiente (null si no hay más)."
          }
        }
      },
      "LocationList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Location"
                }
              }
            }
          }
        ]
      },
      "ServiceCategoryList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ServiceCategory"
                }
              }
            }
          }
        ]
      },
      "ServiceList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Service"
                }
              }
            }
          }
        ]
      },
      "ProfessionalList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Professional"
                }
              }
            }
          }
        ]
      },
      "AppointmentList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          }
        ]
      },
      "ClientList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Client"
                }
              }
            }
          }
        ]
      },
      "EventList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          }
        ]
      },
      "WebhookEndpointList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListBase"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          }
        ]
      }
    }
  }
}
