{
    "openapi": "3.1.0",
    "info": {
        "title": "Innalytica · API para partners",
        "version": "1.0.0",
        "summary": "Alta y gobierno de cuentas de clientes, salud de su conexión y tableros embebidos.",
        "description": "La API con la que un PMS, RMS, channel manager o motor de reserva da de alta a sus clientes en Innalytica, sigue su estado y la salud de su conexión, y les enseña los tableros dentro de su propio panel.\n\n**Autenticación.** Cada llamada lleva `Authorization: Bearer <credencial>`: una llave (`pk_live_…` o `pk_test_…`) o un token de OAuth 2.0 *client credentials* (`pat_live_…` o `pat_test_…`, se pide en `POST /partners/oauth/token`). Las credenciales viven en vuestro servidor: una de producción usada desde un navegador se rechaza.\n\n**Entornos.** La credencial decide el entorno. `live` es producción. `test` es el sandbox: cuentas de ejemplo con datos ficticios y las cuentas de prueba que creéis, que se validan igual que en producción pero nunca crean clientes, ni conexiones, ni contratos, ni mandan correos. `GET /partners/me` dice en qué entorno estáis.\n\n**Permisos.** Cada credencial tiene sus permisos (scopes) y cada operación dice cuál pide; sin él, `403` de tipo `insufficient-scope`.\n\n**Límites.** Por partner y entorno: 120 llamadas por minuto si no se acordó otra cifra, y una cuota diaria opcional. Cada respuesta lleva `RateLimit-Limit`, `RateLimit-Remaining` y `RateLimit-Reset`; pasado el límite, `429` con `Retry-After`.\n\n**Idempotencia.** Las llamadas que escriben aceptan `Idempotency-Key`: la misma clave con la misma petición devuelve la misma respuesta (`Idempotent-Replayed: true`) sin repetir nada.\n\n**Versiones.** Cada respuesta lleva `Innalytica-Version`. Los cambios compatibles (campos nuevos en las respuestas, campos opcionales nuevos, operaciones nuevas) llegan sin aviso dentro de la v1; un cambio incompatible es una versión nueva de la ruta (`/v2`). Lo que se vaya a retirar se avisa con `Deprecation` y `Sunset` al menos seis meses antes.\n\n**Errores.** JSON con `type`, `title` y `detail` (RFC 9457). Los de validación son `422` y traen `errors` por campo.",
        "contact": {
            "name": "Innalytica",
            "url": "https://innalytica.com"
        }
    },
    "servers": [
        {
            "url": "https://api.innalytica.com/v1",
            "description": "Producción: llaves pk_live_… y tokens pat_live_…."
        },
        {
            "url": "https://api.innalytica.com/v1",
            "description": "Sandbox: llaves pk_test_… y tokens pat_test_…; datos ficticios."
        }
    ],
    "security": [
        {
            "partnerKey": []
        },
        {
            "partnerOAuth": []
        }
    ],
    "tags": [
        {
            "name": "Conexión",
            "description": "Comprobar la credencial y pedir tokens de OAuth."
        },
        {
            "name": "Cuentas",
            "description": "Las cuentas de vuestros clientes en Innalytica: alta, cambios, estado, conexión con el PMS y salud."
        },
        {
            "name": "Embebido",
            "description": "Los tableros de una cuenta dentro de vuestro panel. Vuestro servidor pide un enlace de un solo uso y vuestro panel lo pinta en un iframe o con una línea de HTML:\n\n```html\n<div data-innalytica=\"overview\" data-token=\"emb_…\"></div>\n<script src=\"https://app.innalytica.com/embed.js\" async></script>\n```\n\nSolo vuestros dominios dados de alta pueden enmarcar el tablero. La sesión es de solo lectura y se renueva sola mientras el cliente mira (hasta 12 horas)."
        },
        {
            "name": "Interesados",
            "description": "Pasar a Innalytica a alguien interesado sin abrirle cuenta."
        },
        {
            "name": "Webhooks",
            "description": "Avisos a vuestro servidor de lo que pasa en vuestras cuentas: un `POST` firmado a la URL que registréis, con reintentos durante 24 horas.\n\n- Cada entrega lleva `Innalytica-Signature: t=<segundos>,v1=<HMAC-SHA256 de \"<t>.<cuerpo>\">` con el secreto del endpoint (`whsec_…`) e `Innalytica-Event-Id`, el mismo en los reintentos: usadlo para no procesar dos veces.\n- Contestad `2xx` en menos de 5 segundos; si no, se reintenta con espera creciente. Tras 3 días seguidos sin un `2xx` el endpoint se desactiva solo y se avisa a su `alert_email`.\n- El cuerpo es mínimo (`id`, `type`, `version`, `created_at`, `account.external_ref`, `data`) y nunca lleva datos de huéspedes.\n\nTodas estas operaciones piden el permiso `webhooks:manage`. Con una llave de prueba todavía no están disponibles (`409`)."
        },
        {
            "name": "Contrato",
            "description": "Este documento."
        }
    ],
    "paths": {
        "/partners/me": {
            "get": {
                "operationId": "partners.me",
                "summary": "Quién soy",
                "description": "El partner de la credencial, el entorno (`live` o `test`), sus permisos y su cuota. No pide permiso: sirve para comprobar que la conexión funciona. Lo que queda de la cuota va en las cabeceras `RateLimit-*` de la respuesta.",
                "tags": [
                    "Conexión"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "La credencial y su entorno.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Me"
                                },
                                "example": {
                                    "partner": {
                                        "code": "mi-pms",
                                        "name": "Mi PMS",
                                        "pms": "mi-pms"
                                    },
                                    "environment": "test",
                                    "credential": {
                                        "type": "api_key",
                                        "id": "0199f3c2-7d1e-7a8b-9c0d-1e2f3a4b5c6d",
                                        "prefix": "pk_test_AbCd",
                                        "label": "Integración",
                                        "client_id": null,
                                        "expires_at": null
                                    },
                                    "scopes": [
                                        "accounts:read",
                                        "accounts:write",
                                        "embed:write",
                                        "leads:write"
                                    ],
                                    "rate_limit": {
                                        "per_minute": 120,
                                        "daily_quota": null
                                    },
                                    "api_version": "1.0.0"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/oauth/token": {
            "post": {
                "operationId": "partners.oauth.token",
                "summary": "Pedir un token de acceso (OAuth 2.0 client credentials)",
                "description": "Para vuestros servidores: con el `client_id` y el `client_secret` de vuestro cliente OAuth (os lo da Innalytica), un token Bearer que vale una hora en esta API y en el servidor MCP de partners, con los permisos del cliente. `scope` (opcional, separados por espacios) pide solo una parte. Las credenciales van en el cuerpo o en `Authorization: Basic`. Errores según RFC 6749: `invalid_request`, `invalid_client` (401), `invalid_scope`, `unsupported_grant_type`.",
                "tags": [
                    "Conexión"
                ],
                "security": [],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/x-www-form-urlencoded": {
                            "schema": {
                                "$ref": "#/components/schemas/TokenRequest"
                            },
                            "example": {
                                "grant_type": "client_credentials",
                                "client_id": "pci_live_abc123",
                                "client_secret": "pcs_live_…",
                                "scope": "accounts:read embed:write"
                            }
                        },
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/TokenRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "El token.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/AccessToken"
                                },
                                "example": {
                                    "access_token": "pat_live_xYz…",
                                    "token_type": "Bearer",
                                    "expires_in": 3600,
                                    "scope": "accounts:read embed:write"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Petición o permisos no válidos.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/OAuthError"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Cliente desconocido, revocado o secreto incorrecto.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/OAuthError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/partners/accounts": {
            "get": {
                "operationId": "partners.accounts.index",
                "summary": "Listar cuentas",
                "description": "Las cuentas de vuestro partner, para conciliar. Filtros por estado, consentimiento del cliente, salud de la conexión, referencia y fecha del último cambio. Paginado con cursor: pasad en `cursor` el `meta.next_cursor` de la página anterior.\n\nPermiso: `accounts:read`.",
                "tags": [
                    "Cuentas"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:read"
                        ]
                    }
                ],
                "x-required-scope": "accounts:read",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "description": "Estado de la cuenta.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "enum": [
                                "active",
                                "suspended",
                                "cancelled",
                                null
                            ]
                        }
                    },
                    {
                        "name": "link_status",
                        "in": "query",
                        "description": "Solo cuentas enlazadas: consentimiento del cliente.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "enum": [
                                "pending",
                                "approved",
                                "rejected",
                                "revoked",
                                null
                            ]
                        }
                    },
                    {
                        "name": "health",
                        "in": "query",
                        "description": "Salud de la conexión: `ok`, `sin_estrenar`, `parada`, `error`, `pausada`, `sin_credencial`, `caducada`, `por_caducar` o `manual`.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "maxLength": 20
                        }
                    },
                    {
                        "name": "external_ref",
                        "in": "query",
                        "description": "Una referencia concreta.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "maxLength": 120
                        }
                    },
                    {
                        "name": "updated_since",
                        "in": "query",
                        "description": "Solo las cambiadas desde esta fecha (ISO 8601).",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "format": "date-time"
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "description": "El `meta.next_cursor` de la página anterior.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Cuentas por página (máximo 200; 50 por defecto).",
                        "schema": {
                            "type": [
                                "integer",
                                "null"
                            ],
                            "minimum": 1,
                            "maximum": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Una página de cuentas.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/AccountList"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            },
            "post": {
                "operationId": "partners.accounts.store",
                "summary": "Dar de alta una cuenta",
                "description": "Alta completa de un cliente: compañía, marca, administrador (con una invitación de 7 días para poner su contraseña), conexión con vuestro PMS y el plan.\n\n- Idempotente por `external_ref`: repetirla devuelve la cuenta que ya existe (`200`).\n- `connection.credential_owner = partner` usa vuestra credencial del PMS, que ya tiene Innalytica; `client` exige `connection.credentials` con las claves que pide ese PMS (se guardan cifradas y nunca se devuelven).\n- Si Innalytica ya tenía a ese cliente, la cuenta se **enlaza** (`linked: true`) y puede quedar pendiente de que el cliente lo apruebe (`link.status: pending`): hasta entonces no enseña nada de la compañía.\n\nEn el sandbox se valida igual, pero no se crea nada real ni sale ningún correo (`invitation.sent: false`).\n\nPermiso: `accounts:write`.",
                "tags": [
                    "Cuentas"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:write"
                        ]
                    }
                ],
                "x-required-scope": "accounts:write",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "external_ref": {
                                        "type": "string",
                                        "maxLength": 120,
                                        "description": "Vuestra referencia de la cuenta (el owner o la propiedad en vuestro sistema)."
                                    },
                                    "company": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": "string",
                                                "maxLength": 120,
                                                "description": "Razón social."
                                            },
                                            "tax_id": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 40
                                            },
                                            "country": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "minLength": 2,
                                                "maxLength": 2,
                                                "description": "Código ISO de dos letras."
                                            },
                                            "city": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120
                                            },
                                            "locale": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 10,
                                                "description": "Idioma: es, en, fr, pt…"
                                            },
                                            "billing_email": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "format": "email",
                                                "maxLength": 180
                                            }
                                        },
                                        "required": [
                                            "name"
                                        ]
                                    },
                                    "brand": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120,
                                                "description": "Nombre de la marca; por defecto, el de la compañía."
                                            }
                                        }
                                    },
                                    "admin": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": "string",
                                                "maxLength": 120
                                            },
                                            "email": {
                                                "type": "string",
                                                "format": "email",
                                                "maxLength": 180,
                                                "description": "Recibe la invitación. No puede tener ya cuenta en otra empresa."
                                            },
                                            "phone": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 40
                                            }
                                        },
                                        "required": [
                                            "name",
                                            "email"
                                        ]
                                    },
                                    "connection": {
                                        "type": "object",
                                        "properties": {
                                            "pms": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 40,
                                                "description": "El PMS; tiene que ser el vuestro."
                                            },
                                            "external_ref": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120,
                                                "description": "La referencia en el PMS; por defecto, la de la cuenta."
                                            },
                                            "credential_owner": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "enum": [
                                                    "partner",
                                                    "client",
                                                    null
                                                ],
                                                "description": "`partner`: vuestra credencial; `client`: la del cliente, en `credentials`."
                                            },
                                            "credentials": {
                                                "type": [
                                                    "array",
                                                    "null"
                                                ],
                                                "items": {
                                                    "type": "string"
                                                },
                                                "description": "Solo con `credential_owner = client`: las claves que pide ese PMS."
                                            },
                                            "properties": {
                                                "type": [
                                                    "array",
                                                    "null"
                                                ],
                                                "items": {
                                                    "type": "string",
                                                    "maxLength": 60
                                                },
                                                "description": "Ids de propiedades en el PMS."
                                            },
                                            "units": {
                                                "type": [
                                                    "integer",
                                                    "null"
                                                ],
                                                "minimum": 0,
                                                "maximum": 100000,
                                                "description": "Alojamientos declarados."
                                            },
                                            "config": {
                                                "type": [
                                                    "array",
                                                    "null"
                                                ],
                                                "items": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    },
                                    "plan": {
                                        "type": "object",
                                        "properties": {
                                            "code": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 60,
                                                "description": "Código del plan; sin él, vuestro plan por defecto."
                                            },
                                            "payer": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "enum": [
                                                    "partner",
                                                    "client",
                                                    null
                                                ],
                                                "description": "`partner`: se suma a vuestra factura; `client`: se le factura al cliente."
                                            },
                                            "started_at": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "format": "date-time"
                                            },
                                            "ends_at": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "format": "date-time"
                                            },
                                            "trial_days": {
                                                "type": [
                                                    "integer",
                                                    "null"
                                                ],
                                                "minimum": 0,
                                                "maximum": 730,
                                                "description": "Días de prueba (0 = sin prueba). Sin esto ni `trial_ends_at`, la del plan."
                                            },
                                            "trial_ends_at": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "format": "date-time"
                                            }
                                        }
                                    },
                                    "consent": {
                                        "type": "object",
                                        "properties": {
                                            "terms_accepted_at": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "format": "date-time",
                                                "description": "Cuándo aceptó el cliente las condiciones."
                                            },
                                            "source": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120,
                                                "description": "Dónde las aceptó."
                                            }
                                        }
                                    }
                                },
                                "required": [
                                    "external_ref",
                                    "company",
                                    "admin",
                                    "connection"
                                ]
                            },
                            "example": {
                                "external_ref": "2179",
                                "company": {
                                    "name": "Apartamentos del Puerto, S.L.",
                                    "tax_id": "B00000000",
                                    "country": "ES",
                                    "city": "Valencia",
                                    "locale": "es",
                                    "billing_email": "facturas@example.com"
                                },
                                "brand": {
                                    "name": "Apartamentos del Puerto"
                                },
                                "admin": {
                                    "name": "Persona de ejemplo",
                                    "email": "admin@example.com",
                                    "phone": "+34 600 000 000"
                                },
                                "connection": {
                                    "pms": "mi-pms",
                                    "credential_owner": "partner",
                                    "external_ref": "2179",
                                    "units": 11,
                                    "properties": [
                                        "11821",
                                        "11822"
                                    ]
                                },
                                "plan": {
                                    "code": "innalytica-mensual",
                                    "payer": "partner",
                                    "trial_days": 30
                                },
                                "consent": {
                                    "terms_accepted_at": "2026-11-27T10:00:00Z",
                                    "source": "alta-en-mi-pms"
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "La cuenta ya existía con esa referencia: se devuelve tal cual.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Account"
                                }
                            }
                        }
                    },
                    "201": {
                        "description": "Cuenta creada (o enlazada).",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/AccountCreated"
                                },
                                "examples": {
                                    "ejemplo": {
                                        "$ref": "#/components/examples/Account"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/accounts/{ref}": {
            "get": {
                "operationId": "partners.accounts.show",
                "summary": "Ver una cuenta",
                "description": "Estado de la cuenta y salud de su conexión: si los datos llegan (`ok`), si la conexión está parada, con error o sin credencial, alojamientos declarados y vistos, y reservas de los últimos 30 días. Una cuenta enlazada pendiente de aprobación no enseña nada de la compañía.\n\nPermiso: `accounts:read`.",
                "tags": [
                    "Cuentas"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:read"
                        ]
                    }
                ],
                "x-required-scope": "accounts:read",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia de la cuenta (`external_ref`).",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "La cuenta.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Account"
                                },
                                "examples": {
                                    "ejemplo": {
                                        "$ref": "#/components/examples/Account"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            },
            "patch": {
                "operationId": "partners.accounts.update",
                "summary": "Cambiar datos de una cuenta",
                "description": "Solo lo que se manda: datos de la compañía y de facturación, nombre y teléfono del administrador, nombre de la marca, alojamientos declarados y plan (un plan nuevo cierra hoy la línea vigente y abre otra). En una cuenta enlazada solo `connection.units` y `consent`: lo demás es del cliente (`403`); pendiente, nada (`409`).\n\nPermiso: `accounts:write`.",
                "tags": [
                    "Cuentas"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:write"
                        ]
                    }
                ],
                "x-required-scope": "accounts:write",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia de la cuenta (`external_ref`).",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "company": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120
                                            },
                                            "tax_id": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 40
                                            },
                                            "country": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "minLength": 2,
                                                "maxLength": 2
                                            },
                                            "city": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120
                                            },
                                            "locale": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 10
                                            },
                                            "billing_email": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "format": "email",
                                                "maxLength": 180
                                            }
                                        }
                                    },
                                    "brand": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120
                                            }
                                        }
                                    },
                                    "admin": {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 120
                                            },
                                            "phone": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 40
                                            }
                                        }
                                    },
                                    "connection": {
                                        "type": "object",
                                        "properties": {
                                            "units": {
                                                "type": [
                                                    "integer",
                                                    "null"
                                                ],
                                                "minimum": 0,
                                                "maximum": 100000,
                                                "description": "Alojamientos declarados."
                                            }
                                        }
                                    },
                                    "plan": {
                                        "type": "object",
                                        "properties": {
                                            "code": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "maxLength": 60,
                                                "description": "Código del plan nuevo."
                                            }
                                        }
                                    },
                                    "consent": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "example": {
                                "company": {
                                    "billing_email": "administracion@example.com"
                                },
                                "connection": {
                                    "units": 14
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "La cuenta cambiada.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Account"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/accounts/{ref}/status": {
            "put": {
                "operationId": "partners.accounts.status",
                "summary": "Activar, suspender o dar de baja",
                "description": "`active`: se vuelven a traer datos. `suspended`: se dejan de traer (el cliente sigue entrando). `cancelled`: además se cierran sus tableros y se deja de facturar el mes siguiente. El histórico nunca se borra. Con `effective_at` futuro la respuesta es `202` y el cambio queda en `pending_status` hasta su fecha.\n\nEn una cuenta enlazada actúa solo sobre la relación con vosotros: `cancelled` desenlaza sin tocar nada del cliente, y volver a `active` le pide de nuevo su aprobación.\n\nPermiso: `accounts:write`.",
                "tags": [
                    "Cuentas"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:write"
                        ]
                    }
                ],
                "x-required-scope": "accounts:write",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia de la cuenta (`external_ref`).",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "active",
                                            "suspended",
                                            "cancelled"
                                        ]
                                    },
                                    "reason": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 200,
                                        "description": "El motivo, para el histórico."
                                    },
                                    "effective_at": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "date-time",
                                        "description": "Cuándo surte efecto (ISO 8601). Sin ella, ahora."
                                    }
                                },
                                "required": [
                                    "status"
                                ]
                            },
                            "example": {
                                "status": "suspended",
                                "reason": "impago",
                                "effective_at": "2026-12-31T23:59:59Z"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Cambio aplicado.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Account"
                                }
                            }
                        }
                    },
                    "202": {
                        "description": "Cambio programado (`pending_status`).",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Account"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/accounts/{ref}/connection": {
            "put": {
                "operationId": "partners.accounts.connection",
                "summary": "Cambiar la conexión de una cuenta",
                "description": "Otra referencia en el PMS (cambio de owner: el histórico del cliente se queda), otras propiedades, otra credencial o alojamientos declarados. Una referencia que ya es de otra conexión da `409`. En una cuenta enlazada la conexión es del cliente: `403`.\n\nPermiso: `accounts:write`.",
                "tags": [
                    "Cuentas"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:write"
                        ]
                    }
                ],
                "x-required-scope": "accounts:write",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia de la cuenta (`external_ref`).",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "external_ref": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 120,
                                        "description": "La referencia nueva en el PMS."
                                    },
                                    "credential_owner": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "partner",
                                            "client",
                                            null
                                        ],
                                        "description": "`partner` o `client`."
                                    },
                                    "credentials": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "items": {
                                            "type": "string"
                                        },
                                        "description": "Las claves del cliente, con `credential_owner = client`."
                                    },
                                    "properties": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "items": {
                                            "type": "string",
                                            "maxLength": 60
                                        },
                                        "description": "Ids de propiedades en el PMS; sustituyen a las anteriores."
                                    },
                                    "units": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 0,
                                        "maximum": 100000,
                                        "description": "Alojamientos declarados."
                                    },
                                    "config": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "example": {
                                "external_ref": "2190",
                                "units": 11,
                                "properties": [
                                    "11821",
                                    "11822",
                                    "11830"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "La cuenta con la conexión cambiada.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Account"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/accounts/{ref}/embed-tokens": {
            "post": {
                "operationId": "partners.accounts.embed-tokens",
                "summary": "Enlace para embeber los tableros",
                "description": "Un enlace de un solo uso (5 minutos) para enseñar los tableros de la cuenta en vuestro panel. `url` es lo que va en el iframe (o el `token`, en `data-token` con `embed.js`).\n\n- `layout`: `menu` (menú lateral con los tableros) o `single` (una sola pantalla).\n- `pages` acota las páginas del menú y nunca da más de las que el cliente ve en su portal.\n- Lo que no se manda sale de lo configurado para vuestro partner.\n- Con `viewer` el enlace es de una persona concreta (modo persona): queda en el registro de accesos de la cuenta y `restrictions` acota lo que ve (alojamientos, grupos y páginas), siempre dentro de lo que permite la cuenta.\n\nUna cuenta enlazada sin el visto bueno del cliente no tiene tableros (`409`). En el sandbox, los tableros son los de una cuenta de ejemplo con datos ficticios.\n\nPermiso: `embed:write`.",
                "tags": [
                    "Embebido"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "embed:write"
                        ]
                    }
                ],
                "x-required-scope": "embed:write",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia de la cuenta (`external_ref`).",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "dashboard": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "overview",
                                            "business_overview",
                                            "sales",
                                            "pace",
                                            "pickup",
                                            "guests",
                                            "channels",
                                            "booking_window",
                                            "events",
                                            "units",
                                            "occupancy",
                                            "quality",
                                            "web",
                                            "pnl",
                                            "budget",
                                            "summary",
                                            null
                                        ],
                                        "description": "La página de inicio; por defecto, `overview`."
                                    },
                                    "theme": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "light",
                                            "dark",
                                            null
                                        ],
                                        "description": "`light` o `dark`."
                                    },
                                    "locale": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 10,
                                        "description": "Idioma: es, en, fr…"
                                    },
                                    "layout": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "menu",
                                            "single",
                                            null
                                        ],
                                        "description": "`menu` o `single`."
                                    },
                                    "pages": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "items": {
                                            "type": "string",
                                            "enum": [
                                                "overview",
                                                "business_overview",
                                                "sales",
                                                "pace",
                                                "pickup",
                                                "guests",
                                                "channels",
                                                "booking_window",
                                                "events",
                                                "units",
                                                "occupancy",
                                                "quality",
                                                "web",
                                                "pnl",
                                                "budget",
                                                "summary"
                                            ]
                                        },
                                        "maxItems": 40,
                                        "description": "Las páginas del menú."
                                    },
                                    "menu": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "collapsed",
                                            "expanded",
                                            null
                                        ],
                                        "description": "Cómo arranca el menú lateral: `collapsed` o `expanded`."
                                    },
                                    "viewer": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "string",
                                                "pattern": "^[A-Za-z0-9._:@+|\\-]+$",
                                                "minLength": 1,
                                                "maxLength": 128,
                                                "description": "Id estable de la persona en vuestro sistema (1-128: letras, dígitos y `._:@+-|`)."
                                            },
                                            "name": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 120,
                                                "description": "Su nombre, para el registro de accesos."
                                            },
                                            "email": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "format": "email",
                                                "maxLength": 180,
                                                "description": "Su correo (opcional)."
                                            },
                                            "locale": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ],
                                                "pattern": "^[a-z]{2}([_-][A-Za-z]{2})?$",
                                                "maxLength": 10,
                                                "description": "Su idioma (opcional)."
                                            }
                                        },
                                        "description": "Quién va a mirar (modo persona). Sin él, modo compañía. La identidad la afirma vuestro servidor con su credencial: el navegador nunca la lleva."
                                    },
                                    "restrictions": {
                                        "type": "object",
                                        "properties": {
                                            "units": {
                                                "type": [
                                                    "array",
                                                    "null"
                                                ],
                                                "items": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 120
                                                },
                                                "maxItems": 1000,
                                                "description": "Alojamientos: id o código (`GET /partners/accounts/{ref}/units`)."
                                            },
                                            "groups": {
                                                "type": [
                                                    "array",
                                                    "null"
                                                ],
                                                "items": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 120
                                                },
                                                "maxItems": 200,
                                                "description": "Grupos de alojamientos: id o nombre. Se guardan como sus alojamientos de ese momento."
                                            },
                                            "pages": {
                                                "type": [
                                                    "array",
                                                    "null"
                                                ],
                                                "items": {
                                                    "type": "string",
                                                    "enum": [
                                                        "overview",
                                                        "business_overview",
                                                        "sales",
                                                        "pace",
                                                        "pickup",
                                                        "guests",
                                                        "channels",
                                                        "booking_window",
                                                        "events",
                                                        "units",
                                                        "occupancy",
                                                        "quality",
                                                        "web",
                                                        "pnl",
                                                        "budget",
                                                        "summary"
                                                    ]
                                                },
                                                "maxItems": 40,
                                                "description": "Páginas: se cruzan con las del enlace."
                                            }
                                        },
                                        "description": "Lo que puede ver esa persona, siempre dentro de lo que ya permite la cuenta: nunca suma."
                                    }
                                }
                            },
                            "example": {
                                "dashboard": "overview",
                                "layout": "menu",
                                "pages": [
                                    "overview",
                                    "pace",
                                    "channels"
                                ],
                                "menu": "collapsed",
                                "theme": "light",
                                "locale": "es",
                                "viewer": {
                                    "id": "usr-1042",
                                    "name": "Persona de ejemplo",
                                    "email": "persona@example.com",
                                    "locale": "es"
                                },
                                "restrictions": {
                                    "units": [
                                        "PUERTO-1A",
                                        "PUERTO-1B"
                                    ]
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "El enlace.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/EmbedToken"
                                },
                                "example": {
                                    "token": "emb_…",
                                    "expires_at": "2026-11-27T10:05:00+00:00",
                                    "dashboard": "overview",
                                    "page": "overview",
                                    "layout": "menu",
                                    "pages": null,
                                    "menu": "collapsed",
                                    "url": "https://app.innalytica.com/embed/overview?token=emb_…&theme=light&locale=es",
                                    "mode": "viewer",
                                    "viewer": {
                                        "id": "usr-1042",
                                        "name": "Persona de ejemplo"
                                    },
                                    "restrictions": {
                                        "units": 2,
                                        "unmatched": [],
                                        "pages": null
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/accounts/{ref}/units": {
            "get": {
                "operationId": "partners.accounts.units",
                "summary": "Alojamientos de una cuenta",
                "description": "Los alojamientos de la cuenta con su id, su código, su nombre, su establecimiento y sus grupos: para casar vuestros ids con los de Innalytica al acotar lo que ve una persona en el embebido (`restrictions.units` y `restrictions.groups` del enlace). Solo lectura. En una cuenta enlazada, solo con el enlace aprobado (`409`). Con una llave de prueba todavía no está disponible (`409`).\n\nPermiso: `accounts:read`.",
                "tags": [
                    "Embebido"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:read"
                        ]
                    }
                ],
                "x-required-scope": "accounts:read",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia de la cuenta (`external_ref`).",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Los alojamientos.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/UnitList"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": "0199f3c2-0000-7000-8000-000000000010",
                                            "code": "PUERTO-1A",
                                            "name": "Ático 1A",
                                            "status": "active",
                                            "property": {
                                                "id": "0199f3c2-0000-7000-8000-000000000011",
                                                "name": "Edificio del Puerto"
                                            },
                                            "groups": [
                                                {
                                                    "id": "0199f3c2-0000-7000-8000-000000000012",
                                                    "axis": 1,
                                                    "name": "Primera línea"
                                                }
                                            ]
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/accounts/{ref}/authorizations": {
            "post": {
                "operationId": "partners.accounts.authorizations",
                "summary": "URL para que el cliente apruebe el enlace",
                "description": "Para una cuenta **enlazada y pendiente** de aprobación: una URL de Innalytica a la que mandar a vuestro usuario. Entra con su usuario de Innalytica (tiene que administrar la compañía), aprueba o rechaza y vuelve a `redirect_uri` con `state`, `external_ref` y `link_status` (`approved`, `rejected` con `error=access_denied`, o `pending` con `error=cancelled` si vuelve sin decidir).\n\n- `redirect_uri`: https, sin usuario ni fragmento, y de uno de vuestros dominios dados de alta en Innalytica.\n- `state`: vuestro valor opaco contra CSRF; vuelve tal cual.\n- La URL vale 30 minutos y una sola vez, y no se deja enmarcar: abridla con una navegación completa o en una ventana nueva.\n\nLa vuelta es informativa: confirmad siempre con `GET /partners/accounts/{ref}`. Una cuenta que no es enlazada, o que ya no está pendiente, da `409`. Con una llave de prueba todavía no está disponible (`409`).\n\nPermiso: `accounts:write`.",
                "tags": [
                    "Cuentas"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "accounts:write"
                        ]
                    }
                ],
                "x-required-scope": "accounts:write",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia de la cuenta (`external_ref`).",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "redirect_uri": {
                                        "type": "string",
                                        "maxLength": 2000,
                                        "description": "Adónde vuelve el navegador tras decidir: https y de uno de vuestros dominios."
                                    },
                                    "state": {
                                        "type": "string",
                                        "minLength": 8,
                                        "maxLength": 500,
                                        "description": "Vuestro valor opaco (8-500 caracteres): vuelve tal cual."
                                    }
                                },
                                "required": [
                                    "redirect_uri",
                                    "state"
                                ]
                            },
                            "example": {
                                "redirect_uri": "https://panel.example.com/innalytica/vuelta",
                                "state": "c2f1e0b6-5a4d-4c1e-9f0a-7b8c9d0e1f2a"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "La URL de autorización.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/LinkAuthorization"
                                },
                                "example": {
                                    "authorize_url": "https://app.innalytica.com/autorizar-partner/pla_…",
                                    "expires_at": "2026-11-27T10:30:00+00:00",
                                    "external_ref": "2179",
                                    "link_status": "pending"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/leads": {
            "post": {
                "operationId": "partners.leads.store",
                "summary": "Pasar un interesado",
                "description": "Pasa a Innalytica a alguien interesado sin abrirle cuenta. No crea cuenta, no invita a nadie y no vale como consentimiento para comunicaciones comerciales. Idempotente por `external_ref` (`200` si ya lo pasasteis). Hasta que Innalytica lo active para vosotros responde `403`; en el sandbox se acepta siempre.\n\nPermiso: `leads:write`.",
                "tags": [
                    "Interesados"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "leads:write"
                        ]
                    }
                ],
                "x-required-scope": "leads:write",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "external_ref": {
                                        "type": "string",
                                        "pattern": "^[A-Za-z0-9._:@\\/-]+$",
                                        "maxLength": 120,
                                        "description": "Vuestra referencia del interesado: repetirla no crea otro."
                                    },
                                    "name": {
                                        "type": "string",
                                        "maxLength": 200
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "maxLength": 180
                                    },
                                    "phone": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 60
                                    },
                                    "company": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 200
                                    },
                                    "website": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 300
                                    },
                                    "country": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "minLength": 2,
                                        "maxLength": 2,
                                        "description": "Código ISO de dos letras."
                                    },
                                    "pms": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 80
                                    },
                                    "units": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 0,
                                        "maximum": 100000
                                    },
                                    "message": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 4000
                                    }
                                },
                                "required": [
                                    "external_ref",
                                    "name",
                                    "email"
                                ]
                            },
                            "example": {
                                "external_ref": "opp-1042",
                                "name": "Persona de contacto",
                                "email": "persona@example.com",
                                "company": "Empresa de ejemplo",
                                "country": "ES",
                                "units": 40,
                                "message": "Quiere ver una demo"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Ya lo habíais pasado.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Lead"
                                }
                            }
                        }
                    },
                    "201": {
                        "description": "Recibido.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Lead"
                                },
                                "example": {
                                    "data": {
                                        "external_ref": "opp-1042",
                                        "status": "received"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/leads/{ref}": {
            "get": {
                "operationId": "partners.leads.show",
                "summary": "En qué quedó un interesado",
                "description": "`received`, `in_progress`, `won` o `lost`.\n\nPermiso: `leads:write`.",
                "tags": [
                    "Interesados"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "leads:write"
                        ]
                    }
                ],
                "x-required-scope": "leads:write",
                "parameters": [
                    {
                        "name": "ref",
                        "in": "path",
                        "description": "La referencia con la que se pasó.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Su estado.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/Lead"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/webhooks/events": {
            "get": {
                "operationId": "partners.webhooks.events",
                "summary": "Catálogo de eventos",
                "description": "Los tipos de evento que se pueden suscribir, con su versión y qué significan.\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "responses": {
                    "200": {
                        "description": "Los eventos.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookEventList"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "type": "account.created",
                                            "version": 1,
                                            "description": "Alta de una cuenta (también la enlazada a un cliente que ya estaba: linked = true)."
                                        },
                                        {
                                            "type": "account.status_changed",
                                            "version": 1,
                                            "description": "La cuenta pasó a active, suspended o cancelled."
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/webhooks": {
            "get": {
                "operationId": "partners.webhooks.index",
                "summary": "Listar endpoints",
                "description": "Vuestros endpoints, con su estado y el resumen de sus entregas. Nunca devuelve el secreto: solo su pista (`secret_hint`).\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "responses": {
                    "200": {
                        "description": "Los endpoints.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookEndpointList"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": "0199f3c2-0000-7000-8000-000000000020",
                                            "url": "https://hooks.example.com/innalytica",
                                            "description": "Producción",
                                            "events": [
                                                "*"
                                            ],
                                            "status": "active",
                                            "secret_hint": "whsec_…3f9a",
                                            "secret_rotated_at": null,
                                            "previous_secret_expires_at": null,
                                            "alert_email": "equipo-tecnico@example.com",
                                            "disabled_at": null,
                                            "disabled_by": null,
                                            "disabled_reason": null,
                                            "failing_since": null,
                                            "last_success_at": "2026-11-27T10:02:11+00:00",
                                            "last_failure_at": null,
                                            "deliveries": {
                                                "pending": 0,
                                                "failed": 0,
                                                "succeeded_24h": 12
                                            },
                                            "created_via": "api",
                                            "created_at": "2026-11-27T10:00:00+00:00",
                                            "updated_at": "2026-11-27T10:00:00+00:00"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            },
            "post": {
                "operationId": "partners.webhooks.store",
                "summary": "Registrar un endpoint",
                "description": "Da de alta la URL que recibirá los eventos. Devuelve el secreto de firma (`secret`, `whsec_…`) **una sola vez**: guardadlo.\n\n- Solo `https://` y nunca a la red interna (IP privadas, loopback o nombres que resuelvan a ellas): `422`.\n- `events`: tipos del catálogo (`GET /partners/webhooks/events`) o `[\"*\"]` para todos.\n- Una URL que ya tiene un endpoint activo da `409`.\n\nNo acepta `Idempotency-Key`: la respuesta lleva el secreto y no se guarda.\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "url": {
                                        "type": "string",
                                        "maxLength": 2048,
                                        "description": "La URL que recibe los eventos: https y accesible desde internet."
                                    },
                                    "events": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "maxLength": 80
                                        },
                                        "minItems": 1,
                                        "maxItems": 50,
                                        "description": "Tipos del catálogo o `[\"*\"]`."
                                    },
                                    "description": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 200,
                                        "description": "Para reconocerlo."
                                    },
                                    "alert_email": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "email",
                                        "maxLength": 180,
                                        "description": "Correo técnico al que avisar si el endpoint se desactiva solo."
                                    }
                                },
                                "required": [
                                    "url",
                                    "events"
                                ]
                            },
                            "example": {
                                "url": "https://hooks.example.com/innalytica",
                                "events": [
                                    "*"
                                ],
                                "description": "Producción",
                                "alert_email": "equipo-tecnico@example.com"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "El endpoint, con su secreto.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookEndpointWithSecret"
                                },
                                "example": {
                                    "data": {
                                        "id": "0199f3c2-0000-7000-8000-000000000020",
                                        "url": "https://hooks.example.com/innalytica",
                                        "description": "Producción",
                                        "events": [
                                            "*"
                                        ],
                                        "status": "active",
                                        "secret_hint": "whsec_…3f9a",
                                        "secret_rotated_at": null,
                                        "previous_secret_expires_at": null,
                                        "alert_email": "equipo-tecnico@example.com",
                                        "disabled_at": null,
                                        "disabled_by": null,
                                        "disabled_reason": null,
                                        "failing_since": null,
                                        "last_success_at": "2026-11-27T10:02:11+00:00",
                                        "last_failure_at": null,
                                        "deliveries": {
                                            "pending": 0,
                                            "failed": 0,
                                            "succeeded_24h": 12
                                        },
                                        "created_via": "api",
                                        "created_at": "2026-11-27T10:00:00+00:00",
                                        "updated_at": "2026-11-27T10:00:00+00:00",
                                        "secret": "whsec_…"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/webhooks/{id}": {
            "get": {
                "operationId": "partners.webhooks.show",
                "summary": "Ver un endpoint",
                "description": "Un endpoint, con su estado y el resumen de sus entregas.\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "El id del endpoint.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "El endpoint.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookEndpointResponse"
                                },
                                "example": {
                                    "data": {
                                        "id": "0199f3c2-0000-7000-8000-000000000020",
                                        "url": "https://hooks.example.com/innalytica",
                                        "description": "Producción",
                                        "events": [
                                            "*"
                                        ],
                                        "status": "active",
                                        "secret_hint": "whsec_…3f9a",
                                        "secret_rotated_at": null,
                                        "previous_secret_expires_at": null,
                                        "alert_email": "equipo-tecnico@example.com",
                                        "disabled_at": null,
                                        "disabled_by": null,
                                        "disabled_reason": null,
                                        "failing_since": null,
                                        "last_success_at": "2026-11-27T10:02:11+00:00",
                                        "last_failure_at": null,
                                        "deliveries": {
                                            "pending": 0,
                                            "failed": 0,
                                            "succeeded_24h": 12
                                        },
                                        "created_via": "api",
                                        "created_at": "2026-11-27T10:00:00+00:00",
                                        "updated_at": "2026-11-27T10:00:00+00:00"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            },
            "patch": {
                "operationId": "partners.webhooks.update",
                "summary": "Cambiar un endpoint",
                "description": "Solo lo que se manda: `url`, `events`, `description`, `alert_email` y `status` (`active` reactiva uno desactivado, también el que se desactivó solo; `disabled` lo desactiva).\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "El id del endpoint.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "url": {
                                        "type": "string",
                                        "maxLength": 2048
                                    },
                                    "events": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "maxLength": 80
                                        },
                                        "minItems": 1,
                                        "maxItems": 50
                                    },
                                    "description": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 200
                                    },
                                    "alert_email": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "email",
                                        "maxLength": 180
                                    },
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "active",
                                            "disabled"
                                        ],
                                        "description": "`active` o `disabled`."
                                    }
                                }
                            },
                            "example": {
                                "events": [
                                    "account.created",
                                    "account.status_changed"
                                ],
                                "status": "active"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "El endpoint cambiado.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookEndpointResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            },
            "delete": {
                "operationId": "partners.webhooks.destroy",
                "summary": "Desactivar un endpoint",
                "description": "No lo borra: deja de recibir eventos y sus entregas pendientes se cancelan. Se reactiva con `PATCH` y `{\"status\": \"active\"}`.\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "El id del endpoint.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "El endpoint desactivado.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookEndpointResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/webhooks/{id}/rotate-secret": {
            "post": {
                "operationId": "partners.webhooks.rotate-secret",
                "summary": "Rotar el secreto",
                "description": "Devuelve el secreto nuevo **una sola vez**. Con `overlap_hours` (0-24) el anterior sigue firmando hasta entonces (dos `v1=` en la cabecera), para cambiarlo sin perder entregas. No acepta `Idempotency-Key`.\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "El id del endpoint.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "overlap_hours": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 0,
                                        "maximum": 24,
                                        "description": "Horas (0-24) en que el secreto anterior sigue firmando."
                                    }
                                }
                            },
                            "example": {
                                "overlap_hours": 24
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "El endpoint, con su secreto nuevo.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookEndpointWithSecret"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/webhooks/{id}/test": {
            "post": {
                "operationId": "partners.webhooks.test",
                "summary": "Mandar un evento de prueba",
                "description": "`webhook.test`, solo a este endpoint, firmado como cualquier otro y sin reintentos. Responde con la entrega y el resultado del intento.\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "El id del endpoint.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "La entrega de prueba.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookDeliveryResponse"
                                },
                                "example": {
                                    "data": {
                                        "id": "0199f3c2-0000-7000-8000-000000000030",
                                        "endpoint_id": "0199f3c2-0000-7000-8000-000000000020",
                                        "event_id": "0199f3c2-0000-7000-8000-000000000031",
                                        "event_type": "webhook.test",
                                        "status": "succeeded",
                                        "attempts": 1,
                                        "next_attempt_at": null,
                                        "last_attempt_at": "2026-11-27T10:05:00+00:00",
                                        "last_status_code": 200,
                                        "last_duration_ms": 182,
                                        "last_error": null,
                                        "succeeded_at": "2026-11-27T10:05:00+00:00",
                                        "created_at": "2026-11-27T10:05:00+00:00",
                                        "attempt_log": [
                                            {
                                                "attempt": 1,
                                                "trigger": "test",
                                                "at": "2026-11-27T10:05:00+00:00",
                                                "status_code": 200,
                                                "duration_ms": 182,
                                                "error": null,
                                                "succeeded": true
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/webhooks/{id}/deliveries": {
            "get": {
                "operationId": "partners.webhooks.deliveries",
                "summary": "Entregas de un endpoint",
                "description": "De la más nueva a la más vieja, con cada intento (código HTTP, duración y error). Paginado con cursor: pasad en `cursor` el `meta.next_cursor` de la página anterior.\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "El id del endpoint.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "`pending`, `succeeded`, `failed` o `cancelled`.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "enum": [
                                "pending",
                                "succeeded",
                                "failed",
                                "cancelled",
                                null
                            ]
                        }
                    },
                    {
                        "name": "event_type",
                        "in": "query",
                        "description": "Solo las de este tipo de evento.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "maxLength": 80
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "description": "El `meta.next_cursor` de la página anterior.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Entregas por página (máximo 200).",
                        "schema": {
                            "type": [
                                "integer",
                                "null"
                            ],
                            "minimum": 1,
                            "maximum": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Una página de entregas.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookDeliveryList"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": "0199f3c2-0000-7000-8000-000000000030",
                                            "endpoint_id": "0199f3c2-0000-7000-8000-000000000020",
                                            "event_id": "0199f3c2-0000-7000-8000-000000000031",
                                            "event_type": "webhook.test",
                                            "status": "succeeded",
                                            "attempts": 1,
                                            "next_attempt_at": null,
                                            "last_attempt_at": "2026-11-27T10:05:00+00:00",
                                            "last_status_code": 200,
                                            "last_duration_ms": 182,
                                            "last_error": null,
                                            "succeeded_at": "2026-11-27T10:05:00+00:00",
                                            "created_at": "2026-11-27T10:05:00+00:00",
                                            "attempt_log": [
                                                {
                                                    "attempt": 1,
                                                    "trigger": "test",
                                                    "at": "2026-11-27T10:05:00+00:00",
                                                    "status_code": 200,
                                                    "duration_ms": 182,
                                                    "error": null,
                                                    "succeeded": true
                                                }
                                            ]
                                        }
                                    ],
                                    "meta": {
                                        "next_cursor": null
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "422": {
                        "$ref": "#/components/responses/422"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/partners/webhooks/{id}/deliveries/{deliveryId}/retry": {
            "post": {
                "operationId": "partners.webhooks.deliveries.retry",
                "summary": "Reenviar una entrega",
                "description": "Un intento ahora, con el mismo `Innalytica-Event-Id` (vuestro endpoint debe ignorar un id que ya procesó). Responde con la entrega tal como queda. El endpoint tiene que estar activo (`409` si no).\n\nPermiso: `webhooks:manage`.",
                "tags": [
                    "Webhooks"
                ],
                "security": [
                    {
                        "partnerKey": []
                    },
                    {
                        "partnerOAuth": [
                            "webhooks:manage"
                        ]
                    }
                ],
                "x-required-scope": "webhooks:manage",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "El id del endpoint.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "deliveryId",
                        "in": "path",
                        "description": "El id de la entrega.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Hasta 200 caracteres. La misma clave con la misma petición devuelve la respuesta guardada sin repetir nada; con otra petición, 422.",
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "La entrega.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/WebhookDeliveryResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/401"
                    },
                    "403": {
                        "$ref": "#/components/responses/403"
                    },
                    "404": {
                        "$ref": "#/components/responses/404"
                    },
                    "409": {
                        "$ref": "#/components/responses/409"
                    },
                    "429": {
                        "$ref": "#/components/responses/429"
                    }
                }
            }
        },
        "/public/openapi.json": {
            "get": {
                "operationId": "public.openapi",
                "summary": "Descargar este contrato",
                "description": "El contrato OpenAPI 3.1 de la API pública v1. Sin autenticación y con CORS abierto.",
                "tags": [
                    "Contrato"
                ],
                "security": [],
                "responses": {
                    "200": {
                        "description": "El documento OpenAPI.",
                        "headers": {
                            "Innalytica-Version": {
                                "$ref": "#/components/headers/Innalytica-Version"
                            },
                            "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/OpenApiDocument"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "partnerKey": {
                "type": "http",
                "scheme": "bearer",
                "description": "Llave de partner: `pk_live_…` (producción) o `pk_test_…` (sandbox). Se enseña una sola vez al crearla y lleva sus permisos."
            },
            "partnerOAuth": {
                "type": "oauth2",
                "description": "OAuth 2.0 client credentials para vuestros servidores: el token (`pat_live_…` / `pat_test_…`) vale una hora y lleva los permisos del cliente.",
                "flows": {
                    "clientCredentials": {
                        "tokenUrl": "https://api.innalytica.com/v1/partners/oauth/token",
                        "scopes": {
                            "accounts:read": "Leer las cuentas: listado, estado y salud de la conexión.",
                            "accounts:write": "Dar de alta cuentas y cambiar sus datos, su estado y su conexión.",
                            "embed:write": "Pedir enlaces de un solo uso para embeber los tableros de una cuenta.",
                            "leads:write": "Pasar interesados y ver en qué quedaron.",
                            "webhooks:manage": "Gestionar los webhooks: registrar endpoints, rotar el secreto, probar y reenviar entregas.",
                            "usage:read": "Leer el uso por cuenta y mes (reservado: todavía sin llamadas)."
                        }
                    }
                }
            }
        },
        "schemas": {
            "Me": {
                "type": "object",
                "required": [
                    "partner",
                    "environment",
                    "credential",
                    "scopes",
                    "rate_limit",
                    "api_version"
                ],
                "properties": {
                    "partner": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            },
                            "pms": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            }
                        }
                    },
                    "environment": {
                        "type": "string",
                        "enum": [
                            "live",
                            "test"
                        ],
                        "description": "`live` producción; `test` sandbox."
                    },
                    "credential": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": [
                                    "api_key",
                                    "oauth_token"
                                ]
                            },
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "prefix": {
                                "type": "string"
                            },
                            "label": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "client_id": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "expires_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        }
                    },
                    "scopes": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "accounts:read",
                                "accounts:write",
                                "embed:write",
                                "leads:write",
                                "webhooks:manage",
                                "usage:read"
                            ]
                        }
                    },
                    "rate_limit": {
                        "type": "object",
                        "properties": {
                            "per_minute": {
                                "type": "integer"
                            },
                            "daily_quota": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            }
                        }
                    },
                    "api_version": {
                        "type": "string"
                    }
                }
            },
            "TokenRequest": {
                "type": "object",
                "required": [
                    "grant_type"
                ],
                "properties": {
                    "grant_type": {
                        "type": "string",
                        "enum": [
                            "client_credentials"
                        ]
                    },
                    "client_id": {
                        "type": "string",
                        "description": "Si no va en Authorization: Basic."
                    },
                    "client_secret": {
                        "type": "string",
                        "description": "Si no va en Authorization: Basic."
                    },
                    "scope": {
                        "type": "string",
                        "description": "Permisos pedidos, separados por espacios. Sin él, todos los del cliente."
                    }
                }
            },
            "AccessToken": {
                "type": "object",
                "required": [
                    "access_token",
                    "token_type",
                    "expires_in",
                    "scope"
                ],
                "properties": {
                    "access_token": {
                        "type": "string"
                    },
                    "token_type": {
                        "type": "string",
                        "enum": [
                            "Bearer"
                        ]
                    },
                    "expires_in": {
                        "type": "integer",
                        "description": "Segundos de vida."
                    },
                    "scope": {
                        "type": "string"
                    }
                }
            },
            "OAuthError": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string",
                        "enum": [
                            "invalid_request",
                            "invalid_client",
                            "invalid_scope",
                            "unsupported_grant_type"
                        ]
                    },
                    "error_description": {
                        "type": "string"
                    }
                }
            },
            "AccountSummary": {
                "type": "object",
                "required": [
                    "account_id",
                    "external_ref",
                    "status",
                    "linked",
                    "link",
                    "company",
                    "tenant",
                    "connection",
                    "links"
                ],
                "properties": {
                    "account_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Id de la cuenta en Innalytica."
                    },
                    "external_ref": {
                        "type": "string",
                        "description": "Vuestra referencia."
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "active",
                            "suspended",
                            "cancelled"
                        ]
                    },
                    "status_reason": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "status_effective_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "pending_status": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Un cambio de estado programado.",
                        "properties": {
                            "status": {
                                "type": "string",
                                "enum": [
                                    "active",
                                    "suspended",
                                    "cancelled"
                                ]
                            },
                            "reason": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "effective_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        }
                    },
                    "linked": {
                        "type": "boolean",
                        "description": "`true` si el cliente ya estaba en Innalytica y la cuenta se enlazó."
                    },
                    "link": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Solo cuentas enlazadas: el consentimiento del cliente.",
                        "properties": {
                            "status": {
                                "type": "string",
                                "enum": [
                                    "pending",
                                    "approved",
                                    "rejected",
                                    "revoked"
                                ]
                            },
                            "requested_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "decided_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "decided_by": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "enum": [
                                    "client",
                                    "staff",
                                    "legacy",
                                    "partner_company",
                                    "partner_trusted",
                                    "preapproved",
                                    null
                                ],
                                "description": "Quién decidió: el cliente, el equipo de Innalytica en su nombre, aprobación por antigüedad, compañía del propio partner, partner de confianza o compañía anterior a la fecha de corte."
                            }
                        }
                    },
                    "company": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "slug": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "tenant": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "La marca.",
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "slug": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "connection": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "pms": {
                                "type": "string"
                            },
                            "external_ref": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "credential_owner": {
                                "type": "string",
                                "enum": [
                                    "partner",
                                    "client"
                                ]
                            },
                            "status": {
                                "type": "string"
                            },
                            "health": {
                                "type": "string",
                                "enum": [
                                    "ok",
                                    "sin_estrenar",
                                    "parada",
                                    "error",
                                    "pausada",
                                    "sin_credencial",
                                    "caducada",
                                    "por_caducar",
                                    "manual"
                                ],
                                "description": "`ok` los datos llegan; `sin_estrenar` sin credencial activa todavía; `parada` sin sincronizar en el plazo esperado; `error` la última sincronización falló; `sin_credencial`, `caducada` o `por_caducar` problema con la credencial; `pausada` suspendida o dada de baja."
                            },
                            "last_sync_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "first_sync_eta": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "properties": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "units_declared": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            },
                            "last_error": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "units_seen": {
                                "type": "integer",
                                "description": "Alojamientos que llegan del PMS."
                            },
                            "reservations_30d": {
                                "type": "integer",
                                "description": "Reservas hechas en los últimos 30 días."
                            }
                        }
                    },
                    "created_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "links": {
                        "type": "object",
                        "properties": {
                            "self": {
                                "type": "string"
                            },
                            "portal": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "Account": {
                "type": "object",
                "required": [
                    "account_id",
                    "external_ref",
                    "status",
                    "linked",
                    "link",
                    "company",
                    "tenant",
                    "connection",
                    "links"
                ],
                "properties": {
                    "account_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Id de la cuenta en Innalytica."
                    },
                    "external_ref": {
                        "type": "string",
                        "description": "Vuestra referencia."
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "active",
                            "suspended",
                            "cancelled"
                        ]
                    },
                    "status_reason": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "status_effective_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "pending_status": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Un cambio de estado programado.",
                        "properties": {
                            "status": {
                                "type": "string",
                                "enum": [
                                    "active",
                                    "suspended",
                                    "cancelled"
                                ]
                            },
                            "reason": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "effective_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        }
                    },
                    "linked": {
                        "type": "boolean",
                        "description": "`true` si el cliente ya estaba en Innalytica y la cuenta se enlazó."
                    },
                    "link": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Solo cuentas enlazadas: el consentimiento del cliente.",
                        "properties": {
                            "status": {
                                "type": "string",
                                "enum": [
                                    "pending",
                                    "approved",
                                    "rejected",
                                    "revoked"
                                ]
                            },
                            "requested_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "decided_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "decided_by": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "enum": [
                                    "client",
                                    "staff",
                                    "legacy",
                                    "partner_company",
                                    "partner_trusted",
                                    "preapproved",
                                    null
                                ],
                                "description": "Quién decidió: el cliente, el equipo de Innalytica en su nombre, aprobación por antigüedad, compañía del propio partner, partner de confianza o compañía anterior a la fecha de corte."
                            }
                        }
                    },
                    "company": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "slug": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "tenant": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "La marca.",
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "slug": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "connection": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "pms": {
                                "type": "string"
                            },
                            "external_ref": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "credential_owner": {
                                "type": "string",
                                "enum": [
                                    "partner",
                                    "client"
                                ]
                            },
                            "status": {
                                "type": "string"
                            },
                            "health": {
                                "type": "string",
                                "enum": [
                                    "ok",
                                    "sin_estrenar",
                                    "parada",
                                    "error",
                                    "pausada",
                                    "sin_credencial",
                                    "caducada",
                                    "por_caducar",
                                    "manual"
                                ],
                                "description": "`ok` los datos llegan; `sin_estrenar` sin credencial activa todavía; `parada` sin sincronizar en el plazo esperado; `error` la última sincronización falló; `sin_credencial`, `caducada` o `por_caducar` problema con la credencial; `pausada` suspendida o dada de baja."
                            },
                            "last_sync_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "first_sync_eta": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "properties": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "units_declared": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            },
                            "last_error": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "units_seen": {
                                "type": "integer",
                                "description": "Alojamientos que llegan del PMS."
                            },
                            "reservations_30d": {
                                "type": "integer",
                                "description": "Reservas hechas en los últimos 30 días."
                            }
                        }
                    },
                    "created_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "links": {
                        "type": "object",
                        "properties": {
                            "self": {
                                "type": "string"
                            },
                            "portal": {
                                "type": "string"
                            }
                        }
                    },
                    "admin": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "email": {
                                "type": "string",
                                "format": "email"
                            },
                            "name": {
                                "type": "string"
                            },
                            "invitation": {
                                "type": "string",
                                "enum": [
                                    "pending",
                                    "accepted",
                                    "expired",
                                    "disabled",
                                    "none"
                                ]
                            },
                            "invitation_expires_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "last_login_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        }
                    },
                    "plan": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            },
                            "product": {
                                "type": "string"
                            },
                            "payer": {
                                "type": "string",
                                "enum": [
                                    "partner",
                                    "client"
                                ]
                            },
                            "contract_status": {
                                "type": "string"
                            },
                            "started_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date"
                            },
                            "trial_ends_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date"
                            },
                            "ends_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date"
                            }
                        }
                    }
                }
            },
            "AccountCreated": {
                "type": "object",
                "required": [
                    "account_id",
                    "external_ref",
                    "status",
                    "linked",
                    "link",
                    "company",
                    "tenant",
                    "connection",
                    "links"
                ],
                "properties": {
                    "account_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Id de la cuenta en Innalytica."
                    },
                    "external_ref": {
                        "type": "string",
                        "description": "Vuestra referencia."
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "active",
                            "suspended",
                            "cancelled"
                        ]
                    },
                    "status_reason": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "status_effective_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "pending_status": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Un cambio de estado programado.",
                        "properties": {
                            "status": {
                                "type": "string",
                                "enum": [
                                    "active",
                                    "suspended",
                                    "cancelled"
                                ]
                            },
                            "reason": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "effective_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        }
                    },
                    "linked": {
                        "type": "boolean",
                        "description": "`true` si el cliente ya estaba en Innalytica y la cuenta se enlazó."
                    },
                    "link": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Solo cuentas enlazadas: el consentimiento del cliente.",
                        "properties": {
                            "status": {
                                "type": "string",
                                "enum": [
                                    "pending",
                                    "approved",
                                    "rejected",
                                    "revoked"
                                ]
                            },
                            "requested_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "decided_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "decided_by": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "enum": [
                                    "client",
                                    "staff",
                                    "legacy",
                                    "partner_company",
                                    "partner_trusted",
                                    "preapproved",
                                    null
                                ],
                                "description": "Quién decidió: el cliente, el equipo de Innalytica en su nombre, aprobación por antigüedad, compañía del propio partner, partner de confianza o compañía anterior a la fecha de corte."
                            }
                        }
                    },
                    "company": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "slug": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "tenant": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "La marca.",
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "slug": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "connection": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "pms": {
                                "type": "string"
                            },
                            "external_ref": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "credential_owner": {
                                "type": "string",
                                "enum": [
                                    "partner",
                                    "client"
                                ]
                            },
                            "status": {
                                "type": "string"
                            },
                            "health": {
                                "type": "string",
                                "enum": [
                                    "ok",
                                    "sin_estrenar",
                                    "parada",
                                    "error",
                                    "pausada",
                                    "sin_credencial",
                                    "caducada",
                                    "por_caducar",
                                    "manual"
                                ],
                                "description": "`ok` los datos llegan; `sin_estrenar` sin credencial activa todavía; `parada` sin sincronizar en el plazo esperado; `error` la última sincronización falló; `sin_credencial`, `caducada` o `por_caducar` problema con la credencial; `pausada` suspendida o dada de baja."
                            },
                            "last_sync_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "first_sync_eta": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "properties": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "units_declared": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            },
                            "last_error": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "units_seen": {
                                "type": "integer",
                                "description": "Alojamientos que llegan del PMS."
                            },
                            "reservations_30d": {
                                "type": "integer",
                                "description": "Reservas hechas en los últimos 30 días."
                            }
                        }
                    },
                    "created_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "links": {
                        "type": "object",
                        "properties": {
                            "self": {
                                "type": "string"
                            },
                            "portal": {
                                "type": "string"
                            }
                        }
                    },
                    "admin": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "email": {
                                "type": "string",
                                "format": "email"
                            },
                            "name": {
                                "type": "string"
                            },
                            "invitation": {
                                "type": "string",
                                "enum": [
                                    "pending",
                                    "accepted",
                                    "expired",
                                    "disabled",
                                    "none"
                                ]
                            },
                            "invitation_expires_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "last_login_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        }
                    },
                    "plan": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            },
                            "product": {
                                "type": "string"
                            },
                            "payer": {
                                "type": "string",
                                "enum": [
                                    "partner",
                                    "client"
                                ]
                            },
                            "contract_status": {
                                "type": "string"
                            },
                            "started_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date"
                            },
                            "trial_ends_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date"
                            },
                            "ends_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date"
                            }
                        }
                    },
                    "invitation": {
                        "type": "object",
                        "description": "Solo en el alta de una cuenta nueva.",
                        "properties": {
                            "sent": {
                                "type": "boolean",
                                "description": "`false` en el sandbox: no sale ningún correo."
                            },
                            "sent_to": {
                                "type": "string"
                            },
                            "expires_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        }
                    }
                }
            },
            "AccountList": {
                "type": "object",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/AccountSummary"
                        }
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "next_cursor": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "description": "Para la página siguiente; `null` en la última."
                            },
                            "total": {
                                "type": "integer"
                            },
                            "limit": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "EmbedToken": {
                "type": "object",
                "required": [
                    "token",
                    "expires_at",
                    "dashboard",
                    "page",
                    "layout",
                    "pages",
                    "menu",
                    "url"
                ],
                "properties": {
                    "token": {
                        "type": "string",
                        "description": "Un solo uso, 5 minutos."
                    },
                    "expires_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "dashboard": {
                        "type": "string"
                    },
                    "page": {
                        "type": "string",
                        "description": "La página de inicio."
                    },
                    "layout": {
                        "type": "string",
                        "enum": [
                            "menu",
                            "single"
                        ]
                    },
                    "pages": {
                        "type": [
                            "array",
                            "null"
                        ],
                        "items": {
                            "type": "string"
                        },
                        "description": "`null` = todas las del cliente."
                    },
                    "menu": {
                        "type": "string",
                        "enum": [
                            "collapsed",
                            "expanded"
                        ]
                    },
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Lo que va en el iframe."
                    },
                    "mode": {
                        "type": "string",
                        "enum": [
                            "company",
                            "viewer"
                        ],
                        "description": "`viewer` si el enlace es de una persona (`viewer`)."
                    },
                    "viewer": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "restrictions": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Lo que acotó `restrictions`.",
                        "properties": {
                            "units": {
                                "type": [
                                    "integer",
                                    "null"
                                ],
                                "description": "Alojamientos que verá; `null` = todos los de la cuenta."
                            },
                            "unmatched": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                },
                                "description": "Lo pedido que no casó con ningún alojamiento o grupo."
                            },
                            "pages": {
                                "type": [
                                    "array",
                                    "null"
                                ],
                                "items": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "UnitList": {
                "type": "object",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "string",
                                    "format": "uuid"
                                },
                                "code": {
                                    "type": "string"
                                },
                                "name": {
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "status": {
                                    "type": "string"
                                },
                                "property": {
                                    "type": "object",
                                    "description": "El establecimiento.",
                                    "properties": {
                                        "id": {
                                            "type": "string",
                                            "format": "uuid"
                                        },
                                        "name": {
                                            "type": "string"
                                        }
                                    }
                                },
                                "groups": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "string",
                                                "format": "uuid"
                                            },
                                            "axis": {
                                                "type": "integer",
                                                "description": "El eje de agrupación (1, 2…)."
                                            },
                                            "name": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "LinkAuthorization": {
                "type": "object",
                "required": [
                    "authorize_url",
                    "expires_at",
                    "external_ref",
                    "link_status"
                ],
                "properties": {
                    "authorize_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Adónde mandar a vuestro usuario. Un solo uso."
                    },
                    "expires_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "external_ref": {
                        "type": "string"
                    },
                    "link_status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "approved",
                            "rejected",
                            "revoked"
                        ]
                    }
                }
            },
            "WebhookEvent": {
                "type": "object",
                "properties": {
                    "type": {
                        "type": "string"
                    },
                    "version": {
                        "type": "integer"
                    },
                    "description": {
                        "type": "string"
                    }
                }
            },
            "WebhookEventList": {
                "type": "object",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/WebhookEvent"
                        }
                    }
                }
            },
            "WebhookEndpoint": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "url": {
                        "type": "string"
                    },
                    "description": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Tipos suscritos, o `[\"*\"]`."
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "active",
                            "disabled"
                        ]
                    },
                    "secret_hint": {
                        "type": "string",
                        "description": "Pista del secreto; el secreto solo se enseña al crearlo o rotarlo."
                    },
                    "secret_rotated_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "previous_secret_expires_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time",
                        "description": "Hasta cuándo firma también el secreto anterior."
                    },
                    "alert_email": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "disabled_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "disabled_by": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "enum": [
                            "partner",
                            "staff",
                            "auto",
                            null
                        ],
                        "description": "`auto`: se desactivó solo tras días seguidos fallando."
                    },
                    "disabled_reason": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "failing_since": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "last_success_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "last_failure_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "deliveries": {
                        "type": "object",
                        "properties": {
                            "pending": {
                                "type": "integer"
                            },
                            "failed": {
                                "type": "integer"
                            },
                            "succeeded_24h": {
                                "type": "integer"
                            }
                        }
                    },
                    "created_via": {
                        "type": "string",
                        "enum": [
                            "api",
                            "staff"
                        ]
                    },
                    "created_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    }
                }
            },
            "WebhookEndpointResponse": {
                "type": "object",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                    }
                }
            },
            "WebhookEndpointWithSecret": {
                "type": "object",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "url": {
                                "type": "string"
                            },
                            "description": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "events": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                },
                                "description": "Tipos suscritos, o `[\"*\"]`."
                            },
                            "status": {
                                "type": "string",
                                "enum": [
                                    "active",
                                    "disabled"
                                ]
                            },
                            "secret_hint": {
                                "type": "string",
                                "description": "Pista del secreto; el secreto solo se enseña al crearlo o rotarlo."
                            },
                            "secret_rotated_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "previous_secret_expires_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time",
                                "description": "Hasta cuándo firma también el secreto anterior."
                            },
                            "alert_email": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "disabled_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "disabled_by": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "enum": [
                                    "partner",
                                    "staff",
                                    "auto",
                                    null
                                ],
                                "description": "`auto`: se desactivó solo tras días seguidos fallando."
                            },
                            "disabled_reason": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "failing_since": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "last_success_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "last_failure_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "deliveries": {
                                "type": "object",
                                "properties": {
                                    "pending": {
                                        "type": "integer"
                                    },
                                    "failed": {
                                        "type": "integer"
                                    },
                                    "succeeded_24h": {
                                        "type": "integer"
                                    }
                                }
                            },
                            "created_via": {
                                "type": "string",
                                "enum": [
                                    "api",
                                    "staff"
                                ]
                            },
                            "created_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "updated_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "secret": {
                                "type": "string",
                                "description": "El secreto de firma (`whsec_…`). Solo en esta respuesta: guardadlo."
                            }
                        }
                    }
                }
            },
            "WebhookEndpointList": {
                "type": "object",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/WebhookEndpoint"
                        }
                    }
                }
            },
            "WebhookDelivery": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "endpoint_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "event_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "El `Innalytica-Event-Id` de la entrega."
                    },
                    "event_type": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "succeeded",
                            "failed",
                            "cancelled"
                        ]
                    },
                    "attempts": {
                        "type": "integer"
                    },
                    "next_attempt_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "last_attempt_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "last_status_code": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "last_duration_ms": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "last_error": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "succeeded_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "created_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "attempt_log": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "attempt": {
                                    "type": "integer"
                                },
                                "trigger": {
                                    "type": "string",
                                    "enum": [
                                        "auto",
                                        "manual",
                                        "test",
                                        "staff"
                                    ]
                                },
                                "at": {
                                    "type": [
                                        "string",
                                        "null"
                                    ],
                                    "format": "date-time"
                                },
                                "status_code": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "duration_ms": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "error": {
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "succeeded": {
                                    "type": "boolean"
                                }
                            }
                        }
                    }
                }
            },
            "WebhookDeliveryResponse": {
                "type": "object",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                    }
                }
            },
            "WebhookDeliveryList": {
                "type": "object",
                "required": [
                    "data",
                    "meta"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/WebhookDelivery"
                        }
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "next_cursor": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "description": "Para la página siguiente; `null` en la última."
                            }
                        }
                    }
                }
            },
            "Lead": {
                "type": "object",
                "required": [
                    "data"
                ],
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "external_ref": {
                                "type": "string"
                            },
                            "status": {
                                "type": "string",
                                "enum": [
                                    "received",
                                    "in_progress",
                                    "won",
                                    "lost"
                                ]
                            }
                        }
                    }
                }
            },
            "Problem": {
                "type": "object",
                "description": "Error según RFC 9457.",
                "required": [
                    "type",
                    "title"
                ],
                "properties": {
                    "type": {
                        "type": "string",
                        "format": "uri"
                    },
                    "title": {
                        "type": "string"
                    },
                    "status": {
                        "type": "integer"
                    },
                    "detail": {
                        "type": "string"
                    }
                },
                "additionalProperties": true
            },
            "ValidationProblem": {
                "type": "object",
                "required": [
                    "message",
                    "errors"
                ],
                "properties": {
                    "message": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "OpenApiDocument": {
                "type": "object",
                "description": "Un documento OpenAPI 3.1."
            }
        },
        "responses": {
            "401": {
                "description": "Sin credencial o con una no válida, revocada o caducada.",
                "headers": {
                    "Innalytica-Version": {
                        "$ref": "#/components/headers/Innalytica-Version"
                    },
                    "RateLimit-Limit": {
                        "$ref": "#/components/headers/RateLimit-Limit"
                    },
                    "RateLimit-Remaining": {
                        "$ref": "#/components/headers/RateLimit-Remaining"
                    },
                    "RateLimit-Reset": {
                        "$ref": "#/components/headers/RateLimit-Reset"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "$ref": "#/components/schemas/Problem"
                        },
                        "example": {
                            "type": "https://innalytica.com/problems/unauthorized",
                            "title": "Llave no válida",
                            "status": 401,
                            "detail": "Manda la llave de partner o un token de OAuth en la cabecera Authorization: Bearer."
                        }
                    }
                }
            },
            "403": {
                "description": "La credencial no tiene el permiso que pide la operación, o la operación no está permitida para esta cuenta.",
                "headers": {
                    "Innalytica-Version": {
                        "$ref": "#/components/headers/Innalytica-Version"
                    },
                    "RateLimit-Limit": {
                        "$ref": "#/components/headers/RateLimit-Limit"
                    },
                    "RateLimit-Remaining": {
                        "$ref": "#/components/headers/RateLimit-Remaining"
                    },
                    "RateLimit-Reset": {
                        "$ref": "#/components/headers/RateLimit-Reset"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "$ref": "#/components/schemas/Problem"
                        },
                        "example": {
                            "type": "https://innalytica.com/problems/insufficient-scope",
                            "title": "Permiso insuficiente",
                            "status": 403,
                            "detail": "Esta llave no tiene el permiso «accounts:write», que pide esta llamada.",
                            "required_scope": "accounts:write",
                            "granted_scopes": [
                                "accounts:read"
                            ]
                        }
                    }
                }
            },
            "404": {
                "description": "No hay ninguna cuenta, interesado o webhook con esa referencia.",
                "headers": {
                    "Innalytica-Version": {
                        "$ref": "#/components/headers/Innalytica-Version"
                    },
                    "RateLimit-Limit": {
                        "$ref": "#/components/headers/RateLimit-Limit"
                    },
                    "RateLimit-Remaining": {
                        "$ref": "#/components/headers/RateLimit-Remaining"
                    },
                    "RateLimit-Reset": {
                        "$ref": "#/components/headers/RateLimit-Reset"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "$ref": "#/components/schemas/Problem"
                        },
                        "example": {
                            "type": "https://innalytica.com/problems/not-found",
                            "title": "Cuenta no encontrada",
                            "status": 404,
                            "detail": "No hay ninguna cuenta con la referencia «2179»."
                        }
                    }
                }
            },
            "409": {
                "description": "El estado no lo permite: enlace pendiente, rechazado o revocado, referencia o URL en uso, webhook desactivado, cuenta de ejemplo del sandbox u operación que el sandbox todavía no atiende.",
                "headers": {
                    "Innalytica-Version": {
                        "$ref": "#/components/headers/Innalytica-Version"
                    },
                    "RateLimit-Limit": {
                        "$ref": "#/components/headers/RateLimit-Limit"
                    },
                    "RateLimit-Remaining": {
                        "$ref": "#/components/headers/RateLimit-Remaining"
                    },
                    "RateLimit-Reset": {
                        "$ref": "#/components/headers/RateLimit-Reset"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "$ref": "#/components/schemas/Problem"
                        },
                        "example": {
                            "type": "https://innalytica.com/problems/link-pending",
                            "title": "Enlace pendiente de aprobación",
                            "status": 409,
                            "detail": "El cliente todavía no aprobó el enlace de esta cuenta."
                        }
                    }
                }
            },
            "422": {
                "description": "Datos no válidos: `errors` dice qué campo falla.",
                "headers": {
                    "Innalytica-Version": {
                        "$ref": "#/components/headers/Innalytica-Version"
                    },
                    "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/ValidationProblem"
                        },
                        "example": {
                            "message": "El plan «x» no existe.",
                            "errors": {
                                "plan.code": [
                                    "El plan «x» no existe."
                                ]
                            }
                        }
                    }
                }
            },
            "429": {
                "description": "Pasado el límite por minuto o la cuota diaria.",
                "headers": {
                    "Innalytica-Version": {
                        "$ref": "#/components/headers/Innalytica-Version"
                    },
                    "RateLimit-Limit": {
                        "$ref": "#/components/headers/RateLimit-Limit"
                    },
                    "RateLimit-Remaining": {
                        "$ref": "#/components/headers/RateLimit-Remaining"
                    },
                    "RateLimit-Reset": {
                        "$ref": "#/components/headers/RateLimit-Reset"
                    },
                    "Retry-After": {
                        "$ref": "#/components/headers/Retry-After"
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "$ref": "#/components/schemas/Problem"
                        },
                        "example": {
                            "type": "https://innalytica.com/problems/rate-limited",
                            "title": "Demasiadas llamadas",
                            "status": 429,
                            "detail": "Pasaste el límite de 120 llamadas por minuto de vuestro partner.",
                            "limit": 120,
                            "window": "minute",
                            "retry_after": 42
                        }
                    }
                }
            }
        },
        "headers": {
            "Innalytica-Version": {
                "description": "La versión del contrato que respondió.",
                "schema": {
                    "type": "string",
                    "example": "1.0.0"
                }
            },
            "RateLimit-Limit": {
                "description": "Llamadas permitidas en la ventana que antes se agota (minuto o día).",
                "schema": {
                    "type": "integer",
                    "minimum": 0
                }
            },
            "RateLimit-Remaining": {
                "description": "Llamadas que quedan en esa ventana.",
                "schema": {
                    "type": "integer",
                    "minimum": 0
                }
            },
            "RateLimit-Reset": {
                "description": "Segundos hasta que esa ventana se renueva.",
                "schema": {
                    "type": "integer",
                    "minimum": 0
                }
            },
            "Retry-After": {
                "description": "Segundos que esperar antes de reintentar.",
                "schema": {
                    "type": "integer",
                    "minimum": 0
                }
            },
            "Deprecation": {
                "description": "La operación está en retirada desde esta fecha (RFC 9745, `@<segundos>`).",
                "schema": {
                    "type": "string",
                    "example": "@1798761600"
                }
            },
            "Sunset": {
                "description": "Fecha a partir de la cual la operación deja de responder (RFC 8594).",
                "schema": {
                    "type": "string",
                    "example": "Thu, 01 Jul 2027 00:00:00 GMT"
                }
            },
            "Idempotent-Replayed": {
                "description": "`true` si la respuesta es la guardada de una Idempotency-Key ya usada.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "true"
                    ]
                }
            }
        },
        "examples": {
            "Account": {
                "summary": "Cuenta creada por el partner",
                "value": {
                    "account_id": "0199f3c2-7d1e-7a8b-9c0d-1e2f3a4b5c6d",
                    "external_ref": "2179",
                    "status": "active",
                    "status_reason": "alta",
                    "status_effective_at": "2026-11-27T10:00:00+00:00",
                    "pending_status": null,
                    "linked": false,
                    "link": null,
                    "company": {
                        "id": "0199f3c2-0000-7000-8000-000000000001",
                        "slug": "apartamentos-del-puerto-sl",
                        "name": "Apartamentos del Puerto, S.L."
                    },
                    "tenant": {
                        "id": "0199f3c2-0000-7000-8000-000000000002",
                        "slug": "apartamentos-del-puerto",
                        "name": "Apartamentos del Puerto"
                    },
                    "connection": {
                        "id": "0199f3c2-0000-7000-8000-000000000003",
                        "pms": "mi-pms",
                        "external_ref": "2179",
                        "credential_owner": "partner",
                        "status": "active",
                        "health": "parada",
                        "last_sync_at": null,
                        "first_sync_eta": "2026-11-27T11:00:00+00:00",
                        "properties": [
                            "11821",
                            "11822"
                        ],
                        "units_declared": 11,
                        "last_error": null,
                        "units_seen": 0,
                        "reservations_30d": 0
                    },
                    "created_at": "2026-11-27T10:00:00+00:00",
                    "updated_at": "2026-11-27T10:00:00+00:00",
                    "links": {
                        "self": "/v1/partners/accounts/2179",
                        "portal": "https://app.innalytica.com"
                    },
                    "admin": {
                        "email": "admin@example.com",
                        "name": "Persona de ejemplo",
                        "invitation": "pending",
                        "invitation_expires_at": "2026-12-04T10:00:00+00:00",
                        "last_login_at": null
                    },
                    "plan": {
                        "code": "innalytica-mensual",
                        "name": "Innalytica mensual",
                        "product": "reports",
                        "payer": "partner",
                        "contract_status": "draft",
                        "started_at": "2026-11-27",
                        "trial_ends_at": "2026-12-27",
                        "ends_at": null
                    },
                    "invitation": {
                        "sent": true,
                        "sent_to": "admin@example.com",
                        "expires_at": "2026-12-04T10:00:00+00:00"
                    }
                }
            }
        }
    }
}
