{
  "openapi": "3.0.3",
  "info": {
    "title": "WaclisCAL Event-Scoped REST API v1",
    "version": "1.2.0-verified-2026-11-12",
    "description": "Contrato OpenAPI 3.0.3 verificado en vivo contra **WaclisCAL** (`https://cal.waclis.com`).\n\n### Reconciliación Oficial de Superficie Pública\n- **6 endpoints REST funcionales de negocio** bajo `/api/wacliscal/v1/event-types/{externalEventKey}` (`GET /info`, `GET /availability`, `POST /bookings`, `GET /bookings/{uid}`, `POST /bookings/{uid}/reschedule`, `POST /bookings/{uid}/cancel`).\n- **1 endpoint público de contrato en vivo:** `GET /api/wacliscal/v1/openapi.json` (sin autenticación).\n- **1 endpoint de Servidor MCP Stateless (`JSON-RPC 2.0`):** `POST /api/wacliscal/mcp/{externalEventKey}` con **6 herramientas MCP** (`get_event_info`, `get_availability`, `create_booking`, `find_booking`, `reschedule_booking`, `cancel_booking`).\n- **8 eventos de Webhooks HTTP `POST` salientes** configurables en `Ajustes > Desarrollador > Webhooks` y firmados con **`X-Cal-Signature-256`** (`BOOKING_CREATED`, `BOOKING_RESCHEDULED`, `BOOKING_CANCELLED`, `BOOKING_REJECTED`, `BOOKING_REQUESTED`, `BOOKING_PAID`, `OOO_CREATED`, `PING`).\n- *(Nota: no existen rutas `/health` ni `/docs` bajo `/api/wacliscal/v1`, y el conector interno M2M de Capitán no forma parte de la API pública para desarrolladores).*"
  },
  "servers": [
    {
      "url": "https://cal.waclis.com",
      "description": "Servidor productivo oficial de WaclisCAL"
    }
  ],
  "security": [
    {
      "EventBearerToken": []
    }
  ],
  "components": {
    "securitySchemes": {
      "EventBearerToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Token con prefijo `wcal_evt_...` con scopes granulares por Tipo de Evento."
      }
    },
    "schemas": {
      "CalErrorResponse": {
        "type": "object",
        "required": [
          "ok",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error_code": {
            "type": "string",
            "example": "SLOT_NOT_AVAILABLE"
          },
          "message": {
            "type": "string",
            "example": "El horario seleccionado ya no se encuentra disponible."
          },
          "request_id": {
            "type": "string",
            "example": "req_9a8b7c6d5e4f"
          }
        }
      },
      "EventTypeInfoResponse": {
        "type": "object",
        "required": [
          "ok",
          "data"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "data": {
            "type": "object",
            "required": [
              "external_event_key",
              "id",
              "title",
              "slug",
              "duration_minutes",
              "time_zone",
              "scopes_authorized"
            ],
            "properties": {
              "external_event_key": {
                "type": "string"
              },
              "id": {
                "type": "integer"
              },
              "title": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              },
              "duration_minutes": {
                "type": "integer"
              },
              "description": {
                "type": "string"
              },
              "time_zone": {
                "type": "string",
                "example": "America/Argentina/Buenos_Aires"
              },
              "scopes_authorized": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "AvailabilityResponse": {
        "type": "object",
        "required": [
          "ok",
          "data"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "data": {
            "type": "object",
            "required": [
              "time_zone",
              "slots"
            ],
            "properties": {
              "time_zone": {
                "type": "string",
                "example": "America/Argentina/Buenos_Aires"
              },
              "slots": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "time"
                  ],
                  "properties": {
                    "time": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2026-11-16T15:00:00-03:00"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "CreateBookingRequest": {
        "type": "object",
        "required": [
          "start",
          "attendee"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-16T15:00:00-03:00"
          },
          "time_zone": {
            "type": "string",
            "example": "America/Argentina/Buenos_Aires"
          },
          "idempotency_key": {
            "type": "string",
            "example": "idem_20261116_001"
          },
          "notes": {
            "type": "string"
          },
          "participants": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "attendee": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "example": "Martín Gómez"
              },
              "email": {
                "type": "string",
                "nullable": true,
                "example": "martin@empresa-demo.com"
              },
              "phone_number": {
                "type": "string",
                "nullable": true,
                "example": "+5491144445555"
              },
              "time_zone": {
                "type": "string",
                "example": "America/Argentina/Buenos_Aires"
              }
            }
          }
        }
      },
      "BookingResponse": {
        "type": "object",
        "required": [
          "ok",
          "data"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "data": {
            "type": "object",
            "required": [
              "uid",
              "status",
              "start",
              "end"
            ],
            "properties": {
              "uid": {
                "type": "string",
                "example": "bk_987654321"
              },
              "status": {
                "type": "string",
                "enum": [
                  "ACCEPTED",
                  "PENDING",
                  "CANCELLED",
                  "REJECTED"
                ]
              },
              "start": {
                "type": "string",
                "format": "date-time"
              },
              "end": {
                "type": "string",
                "format": "date-time"
              },
              "time_zone": {
                "type": "string"
              },
              "meeting_url": {
                "type": "string",
                "nullable": true
              }
            }
          }
        }
      },
      "RescheduleBookingRequest": {
        "type": "object",
        "required": [
          "new_start"
        ],
        "properties": {
          "new_start": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-18T16:00:00-03:00"
          },
          "time_zone": {
            "type": "string",
            "example": "America/Argentina/Buenos_Aires"
          },
          "reason": {
            "type": "string",
            "example": "Cambio de agenda solicitado por el cliente"
          }
        }
      },
      "CancelBookingRequest": {
        "type": "object",
        "required": [
          "confirmed"
        ],
        "properties": {
          "confirmed": {
            "type": "boolean",
            "example": true,
            "description": "Debe ser explícitamente `true` para confirmar la cancelación."
          },
          "reason": {
            "type": "string",
            "example": "Cancelación solicitada por el cliente"
          }
        }
      },
      "McpJsonRpcRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "example": "2.0"
          },
          "id": {
            "type": "integer",
            "example": 1
          },
          "method": {
            "type": "string",
            "enum": [
              "initialize",
              "tools/list",
              "tools/call"
            ],
            "example": "tools/list"
          },
          "params": {
            "type": "object",
            "example": {}
          }
        }
      },
      "McpJsonRpcResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "example": "2.0"
          },
          "id": {
            "type": "integer",
            "example": 1
          },
          "result": {
            "type": "object",
            "description": "Resultado JSON-RPC de cualquiera de las 6 herramientas MCP (`get_event_info`, `get_availability`, `create_booking`, `find_booking`, `reschedule_booking`, `cancel_booking`)."
          }
        }
      }
    }
  },
  "paths": {
    "/api/wacliscal/v1/openapi.json": {
      "get": {
        "security": [],
        "summary": "Obtener especificación OpenAPI 3.0.3 oficial en vivo",
        "responses": {
          "200": {
            "description": "Documento OpenAPI 3.0.3"
          }
        }
      }
    },
    "/api/wacliscal/v1/event-types/{externalEventKey}/info": {
      "get": {
        "summary": "Consultar información y duración del Tipo de Evento (scope: availability.read)",
        "parameters": [
          {
            "name": "externalEventKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Metadatos del evento"
          }
        }
      }
    },
    "/api/wacliscal/v1/event-types/{externalEventKey}/availability": {
      "get": {
        "summary": "Consultar horarios disponibles en un rango de fechas (scope: availability.read)",
        "parameters": [
          {
            "name": "externalEventKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2026-11-16"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2026-11-20"
            }
          },
          {
            "name": "time_zone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "America/Argentina/Buenos_Aires"
            }
          },
          {
            "name": "after_time",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "09:00"
            }
          },
          {
            "name": "before_time",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "18:00"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Horarios libres"
          }
        }
      }
    },
    "/api/wacliscal/v1/event-types/{externalEventKey}/bookings": {
      "post": {
        "summary": "Crear una reserva en el Tipo de Evento (scope: booking.create)",
        "parameters": [
          {
            "name": "externalEventKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "start",
                  "attendee"
                ],
                "properties": {
                  "start": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "time_zone": {
                    "type": "string",
                    "example": "America/Argentina/Buenos_Aires"
                  },
                  "attendee": {
                    "type": "object",
                    "required": [
                      "name",
                      "email"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email"
                      },
                      "phone": {
                        "type": "string"
                      }
                    }
                  },
                  "notes": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Reserva creada con `uid`"
          }
        }
      }
    },
    "/api/wacliscal/v1/event-types/{externalEventKey}/bookings/{uid}": {
      "get": {
        "summary": "Consultar estado de una reserva por UID (scope: booking.read)",
        "parameters": [
          {
            "name": "externalEventKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "uid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Detalle de la reserva"
          }
        }
      }
    },
    "/api/wacliscal/v1/event-types/{externalEventKey}/bookings/{uid}/reschedule": {
      "post": {
        "summary": "Reprogramar una reserva existente (scope: booking.reschedule)",
        "parameters": [
          {
            "name": "externalEventKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "uid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "new_start"
                ],
                "properties": {
                  "new_start": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "time_zone": {
                    "type": "string",
                    "example": "America/Argentina/Buenos_Aires"
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reserva reprogramada"
          }
        }
      }
    },
    "/api/wacliscal/v1/event-types/{externalEventKey}/bookings/{uid}/cancel": {
      "post": {
        "summary": "Cancelar una reserva existente (scope: booking.cancel; método POST con confirmed: true)",
        "parameters": [
          {
            "name": "externalEventKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "uid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirmed"
                ],
                "properties": {
                  "confirmed": {
                    "type": "boolean",
                    "example": true
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reserva cancelada"
          }
        }
      }
    },
    "/api/wacliscal/mcp/{externalEventKey}": {
      "post": {
        "operationId": "wacliscal_mcp_rpc",
        "summary": "Servidor MCP Stateless por Tipo de Evento (JSON-RPC 2.0: 6 herramientas)",
        "description": "Endpoint Model Context Protocol (`JSON-RPC 2.0`, `protocolVersion: '2026-07-28'`) autenticado con `Authorization: Bearer wcal_evt_<TOKEN>`.\n\n### 6 Herramientas MCP disponibles (`tools/call`)\n1. `get_event_info` (scope: `availability.read`)\n2. `get_availability` (scope: `availability.read`)\n3. `create_booking` (scope: `booking.create`)\n4. `find_booking` (scope: `booking.read`)\n5. `reschedule_booking` (scope: `booking.reschedule`)\n6. `cancel_booking` (scope: `booking.cancel`)",
        "parameters": [
          {
            "name": "externalEventKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "UUID externo del Tipo de Evento (`externalEventKey`)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/McpJsonRpcRequest"
              },
              "example": {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "tools/list",
                "params": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta JSON-RPC 2.0 del Servidor MCP",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpJsonRpcResponse"
                }
              }
            }
          },
          "401": {
            "description": "Token `wcal_evt_` inválido o sin el scope requerido por la herramienta."
          },
          "405": {
            "description": "Método no permitido (solo acepta `POST`)."
          },
          "429": {
            "description": "Límite de tasa superado (`120 solicitudes / minuto`)."
          }
        }
      }
    }
  }
}