{"openapi":"3.1.0","info":{"title":"Ordyum API","version":"0.86.0","description":"API REST de Ordyum. Errores: `{ error: { code, message, details } }` con `code` estable. POST admite `Idempotency-Key`. Paginación por cursor (`next_cursor`)."},"servers":[{"url":"/"}],"components":{"securitySchemes":{"cookieAuth":{"type":"apiKey","in":"cookie","name":"ordyum.session_token","description":"Sesión web (Better Auth). Requiere cabecera `Ordyum-Workspace`."},"bearerAuth":{"type":"http","scheme":"bearer","description":"API key `ord_live_…` (workspace implícito) o token de sesión (apps nativas, con `Ordyum-Workspace`)."}},"schemas":{"DemoStarted":{"type":"object","properties":{"workspace":{"type":"string","description":"Slug del espacio de la demo"},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"reused":{"type":"boolean","description":"El navegador ya tenía una demo activa y se reutiliza"}},"required":["workspace","expires_at","reused"]},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"deal.next_step_required"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":{}}},"required":["code","message"]}},"required":["error"]},"DemoStart":{"type":"object","properties":{"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"],"description":"Idioma de los datos de ejemplo y de la interfaz"}}},"Unsubscribe":{"type":"object","properties":{"token":{"type":"string","minLength":10,"maxLength":600}},"required":["token"]},"Me":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/MeUser"},"workspaces":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceSummary"}},"organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"role":{"type":"string","enum":["owner","admin","member"]}},"required":["id","name","role"]},"description":"Agencias de las que es miembro (aunque no tenga ningún workspace asignado)"},"impersonation":{"$ref":"#/components/schemas/Impersonation"}},"required":["user","workspaces","organizations","impersonation"]},"MeUser":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"image":{"type":["string","null"]},"avatar_url":{"type":["string","null"],"description":"Foto de perfil lista para `<img>` (subida, ilustrada o del proveedor de acceso); null = iniciales"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"timezone":{"type":"string"},"platform_admin":{"type":"boolean","description":"Acceso a la consola de administración de la plataforma (/admin)"},"two_factor_enabled":{"type":"boolean","description":"Pide un código de la app de autenticación al entrar con contraseña"},"has_password":{"type":"boolean","description":"Tiene contraseña (las cuentas solo con Google/Microsoft no)"},"guide_answer":{"$ref":"#/components/schemas/GuideAnswer"},"onboarding_emails":{"type":"boolean","description":"Recibe los consejos de puesta en marcha (días 1, 3 y 7 tras el alta)"},"demo":{"type":"boolean","description":"Cuenta temporal de la demo pública"}},"required":["id","name","email","image","avatar_url","locale","timezone","platform_admin","two_factor_enabled","has_password","guide_answer","onboarding_emails","demo"]},"GuideAnswer":{"type":["string","null"],"enum":["new","experienced","skipped",null],"description":"Respuesta a «¿Es tu primera vez con un CRM?»; `null` = aún no se le ha preguntado"},"WorkspaceSummary":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"org_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"org_name":{"type":"string"},"org_role":{"type":["string","null"],"enum":["owner","admin","member",null],"description":"Rol del usuario en la agencia (owner/admin pueden crear workspaces de cliente)"},"name":{"type":"string"},"slug":{"type":"string"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"timezone":{"type":"string"},"country":{"type":["string","null"],"pattern":"^[A-Z]{2}$","example":"ES","description":"País del negocio: prefijo de los teléfonos que llegan sin él (null = sin definir)"},"settings":{"$ref":"#/components/schemas/WorkspaceSettings"},"role":{"type":"string","enum":["admin","manager","sales","viewer"]},"visibility":{"type":"string","enum":["all","own"]},"suspended":{"type":"boolean","description":"La agencia está suspendida: el workspace no responde (403 `organization.suspended`)"},"features":{"type":"array","items":{"type":"string","enum":["inbox","automations","scoring","ads_leads","ads_conversions","ads_spend","ads_audiences","client_reports","webhooks","report_exports"]},"description":"Funciones del plan de la agencia; sin una, configurarla devuelve 402 `plan.feature_unavailable`"},"billing_alert":{"type":["object","null"],"properties":{"status":{"type":"string","enum":["past_due","unpaid"]},"grace_ends_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Pasada esta fecha la agencia se suspende sola"}},"required":["status","grace_ends_at"],"description":"Pago pendiente de la agencia (null si está al día)"},"require_admin_2fa":{"type":"boolean","description":"La agencia exige la verificación en dos pasos a sus administradores"},"two_factor_required":{"type":"boolean","description":"Este usuario tiene que activar 2FA antes de usar el workspace: la API responde 403 `auth.two_factor_required`"},"demo_expires_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Espacio de la demo pública: se borra en esta fecha y no envía nada hacia fuera (null = cuenta real)"}},"required":["id","org_id","org_name","org_role","name","slug","currency","locale","timezone","country","settings","role","visibility","suspended","features","billing_alert","require_admin_2fa","two_factor_required","demo_expires_at"]},"WorkspaceSettings":{"type":"object","properties":{"avatar":{"$ref":"#/components/schemas/WorkspaceAvatar"},"stale_deal_days":{"type":"integer","minimum":1,"maximum":365,"description":"Días sin actividad para marcar un deal como estancado"},"lead_repeat_alert":{"type":"integer","minimum":0,"maximum":1000,"description":"Leads reenviados de un mismo origen en 24 h que avisan a los admins (0 = sin aviso)"},"sla_minutes":{"type":"integer","minimum":1,"maximum":1440,"description":"Speed-to-lead: minutos para el primer contacto"},"sla_channel_minutes":{"type":"object","additionalProperties":{"type":"integer","minimum":1,"maximum":1440},"description":"SLA por canal (`google_ads`, `meta_ads`…); sustituye al general para ese canal"},"sla_escalate_minutes":{"type":"integer","minimum":0,"maximum":2880,"description":"Minutos sin respuesta tras los que se escala (0 = sin escalado)"},"sla_reassign":{"type":"boolean","description":"Al escalar, reasigna el lead al comercial con menos pendientes"},"sla_notify_admins":{"type":"boolean","description":"Al escalar, avisa a los admins"},"score_hot":{"type":"integer","minimum":1,"maximum":100,"description":"Score desde el que un lead es Hot"},"score_warm":{"type":"integer","minimum":0,"maximum":99,"description":"Score desde el que un lead es Warm"},"commissions_enabled":{"type":"boolean","description":"Cada cobro de Stripe genera la comisión del responsable del cliente"},"commission_default_bp":{"type":"integer","minimum":0,"maximum":10000,"description":"% por defecto en puntos básicos (1000 = 10 %) para el rol Ventas; cada miembro puede tener el suyo"},"commission_tiers":{"type":"array","items":{"$ref":"#/components/schemas/CommissionTier"},"maxItems":10,"description":"Escala por tramos para quien cobra el % por defecto (rol Ventas sin % propio): cada parte de un cobro paga el % del tramo en el que cae según lo vendido en el mes. Vacío = % fijo"},"commission_product_rates":{"type":"array","items":{"$ref":"#/components/schemas/CommissionProductRate"},"maxItems":30,"description":"% por producto: el primero que coincide sustituye al del comercial y a la escala"}},"required":["avatar","stale_deal_days","lead_repeat_alert","sla_minutes","sla_channel_minutes","sla_escalate_minutes","sla_reassign","sla_notify_admins","score_hot","score_warm","commissions_enabled","commission_default_bp","commission_tiers","commission_product_rates"]},"WorkspaceAvatar":{"type":["string","null"],"enum":["agency","restaurant","cafe","clinic","dental","vet","beauty","realestate","shop","fitness","legal","education","travel","events","automotive","construction",null],"description":"Avatar del workspace en el menú (null = su inicial)"},"CommissionTier":{"type":"object","properties":{"from":{"type":"integer","minimum":0,"maximum":1000000000000,"description":"Ventas del mes del comercial (unidades mínimas de la moneda del espacio) a partir de las que se aplica este %"},"rate_bp":{"type":"integer","minimum":0,"maximum":10000}},"required":["from","rate_bp"]},"CommissionProductRate":{"type":"object","properties":{"match":{"type":"string","minLength":1,"maxLength":80,"description":"Producto: igual a `metadata.ordyum_product` del cobro o contenido en su descripción (sin distinguir mayúsculas)"},"rate_bp":{"type":"integer","minimum":0,"maximum":10000}},"required":["match","rate_bp"]},"Impersonation":{"type":["object","null"],"properties":{"admin":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["admin","expires_at"],"description":"Un admin de plataforma está viendo la cuenta como este usuario (solo lectura)"},"MeUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"timezone":{"type":"string","minLength":1,"maxLength":64,"example":"America/New_York"},"avatar_preset":{"type":["integer","null"],"minimum":1,"maximum":5,"description":"Elige uno de los avatares ilustrados (1–5); `null` quita la foto"},"guide_answer":{"allOf":[{"$ref":"#/components/schemas/GuideAnswer"},{"description":"`new`: abrió la guía de uso; `experienced`: fue a los primeros pasos; `skipped`: «Ahora no»"}]},"onboarding_emails":{"type":"boolean"}}},"AvatarUpload":{"type":"object","properties":{"data_url":{"type":"string","maxLength":300000,"pattern":"^data:image\\/(webp|jpeg|png);base64,[A-Za-z0-9+/=]+$","description":"Imagen cuadrada ya recortada (WebP, JPEG o PNG en base64, máx. 200 KB)"}},"required":["data_url"]},"MySession":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"ip":{"type":["string","null"]},"user_agent":{"type":["string","null"]},"location":{"$ref":"#/components/schemas/DeviceLocation"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_active_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"current":{"type":"boolean","description":"La sesión con la que se hizo esta petición"}},"required":["id","ip","user_agent","location","created_at","last_active_at","expires_at","current"]},"DeviceLocation":{"type":["object","null"],"properties":{"city":{"type":["string","null"]},"country":{"type":["string","null"],"minLength":2,"maxLength":2,"description":"ISO 3166-1 alfa-2"}},"required":["city","country"],"description":"Ubicación aproximada que envía el proxy/CDN de confianza"},"KnownDevice":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string","description":"Navegador · sistema (vacío si el user agent no se reconoce)"},"ip":{"type":["string","null"],"description":"Última IP desde la que entró"},"location":{"$ref":"#/components/schemas/DeviceLocation"},"first_seen_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_seen_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"current":{"type":"boolean","description":"Es el dispositivo de esta sesión"}},"required":["key","label","ip","location","first_seen_at","last_seen_at","current"],"description":"Dispositivo de confianza: entrar desde él no envía aviso por email"},"PushConfig":{"type":"object","properties":{"available":{"type":"boolean","description":"false si el servidor no tiene Firebase Cloud Messaging configurado"},"web":{"type":["object","null"],"properties":{"api_key":{"type":"string"},"project_id":{"type":"string"},"app_id":{"type":"string"},"messaging_sender_id":{"type":"string"},"vapid_key":{"type":"string"}},"required":["api_key","project_id","app_id","messaging_sender_id","vapid_key"],"description":"Configuración pública del SDK web de Firebase; null si falta alguna clave"}},"required":["available","web"]},"PushDevice":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"platform":{"type":"string","enum":["web","android","ios"]},"label":{"type":"string","description":"Navegador · sistema (vacío si el user agent no se reconoce)"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_seen_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"current":{"type":"boolean","description":"Registrado desde la sesión de esta petición"}},"required":["id","platform","label","created_at","last_seen_at","current"],"description":"Navegador o app que recibe notificaciones push (Firebase Cloud Messaging)"},"PushDeviceRegister":{"type":"object","properties":{"token":{"type":"string","minLength":20,"maxLength":4096,"pattern":"^[\\w:.-]+$","description":"Token de registro de Firebase Cloud Messaging"},"platform":{"type":"string","enum":["web","android","ios"],"default":"web"}},"required":["token"]},"NotMeResult":{"type":"object","properties":{"closed":{"type":"integer","description":"Sesiones cerradas (todas las de la cuenta)"},"password_reset":{"type":"boolean","description":"true si se bloqueó la contraseña y se envió el email para elegir otra"}},"required":["closed","password_reset"]},"NotMeRequest":{"type":"object","properties":{"token":{"type":"string","minLength":20,"maxLength":400}},"required":["token"]},"OrganizationCreated":{"type":"object","properties":{"organization":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"workspace":{"$ref":"#/components/schemas/WorkspaceSummary"},"api_key":{"$ref":"#/components/schemas/InitialApiKey"}},"required":["organization","workspace","api_key"]},"InitialApiKey":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"prefix":{"type":"string"},"secret":{"type":"string","description":"Solo se devuelve en el alta; después solo se ve el prefijo"}},"required":["id","name","prefix","secret"]},"OrganizationCreate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"workspace_name":{"type":"string","minLength":2,"maxLength":120},"currency":{"type":"string","pattern":"^[A-Z]{3}$","default":"USD","example":"USD"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"],"default":"en"},"timezone":{"type":"string","maxLength":64,"default":"UTC"},"country":{"type":"string","pattern":"^[A-Z]{2}$","example":"ES","description":"ISO 3166-1 alfa-2"}},"required":["name"]},"WorkspaceCreated":{"allOf":[{"$ref":"#/components/schemas/WorkspaceSummary"},{"type":"object","properties":{"api_key":{"$ref":"#/components/schemas/InitialApiKey"}},"required":["api_key"]}]},"WorkspaceCreate":{"type":"object","properties":{"org_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string","minLength":2,"maxLength":120},"currency":{"type":"string","pattern":"^[A-Z]{3}$","default":"USD","example":"USD"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"],"default":"en"},"timezone":{"type":"string","minLength":1,"maxLength":64,"default":"UTC","example":"America/New_York"},"country":{"type":"string","pattern":"^[A-Z]{2}$","example":"ES","description":"ISO 3166-1 alfa-2"},"template_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Plantilla de la agencia a aplicar (pipelines, campos, reglas, formularios…)"},"clone_workspace_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Copia la configuración de otro workspace de la agencia (nunca sus datos)"}},"required":["org_id","name"]},"DeleteConfirm":{"type":"object","properties":{"confirm":{"type":"string","minLength":1,"maxLength":120,"description":"Nombre exacto de lo que se borra (sin distinguir mayúsculas)"}},"required":["confirm"]},"InvitationPreview":{"type":"object","properties":{"status":{"type":"string","enum":["valid","expired","accepted","invalid"]},"organization":{"type":["string","null"]},"workspaces":{"type":"array","items":{"type":"string"},"description":"Espacios del lote aún pendientes (o el del enlace)"},"role":{"type":["string","null"],"enum":["admin","manager","sales","viewer",null]},"invited_by":{"type":["string","null"]},"email_hint":{"type":["string","null"],"description":"Correo invitado enmascarado (ma•••@dominio.com) para saber con qué cuenta entrar"},"expires_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["status","organization","workspaces","role","invited_by","email_hint","expires_at"]},"InvitationAccept":{"type":"object","properties":{"token":{"type":"string","minLength":20}},"required":["token"]},"WorkspaceUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"timezone":{"type":"string","minLength":1,"maxLength":64,"example":"America/New_York"},"country":{"type":["string","null"],"pattern":"^[A-Z]{2}$","example":"ES","description":"ISO 3166-1 alfa-2"},"settings":{"type":"object","properties":{"avatar":{"$ref":"#/components/schemas/WorkspaceAvatar"},"stale_deal_days":{"type":"integer","minimum":1,"maximum":365,"description":"Días sin actividad para marcar un deal como estancado"},"lead_repeat_alert":{"type":"integer","minimum":0,"maximum":1000,"description":"Leads reenviados de un mismo origen en 24 h que avisan a los admins (0 = sin aviso)"},"sla_minutes":{"type":"integer","minimum":1,"maximum":1440,"description":"Speed-to-lead: minutos para el primer contacto"},"sla_channel_minutes":{"type":"object","additionalProperties":{"type":"integer","minimum":1,"maximum":1440},"description":"SLA por canal (`google_ads`, `meta_ads`…); sustituye al general para ese canal"},"sla_escalate_minutes":{"type":"integer","minimum":0,"maximum":2880,"description":"Minutos sin respuesta tras los que se escala (0 = sin escalado)"},"sla_reassign":{"type":"boolean","description":"Al escalar, reasigna el lead al comercial con menos pendientes"},"sla_notify_admins":{"type":"boolean","description":"Al escalar, avisa a los admins"},"score_hot":{"type":"integer","minimum":1,"maximum":100,"description":"Score desde el que un lead es Hot"},"score_warm":{"type":"integer","minimum":0,"maximum":99,"description":"Score desde el que un lead es Warm"},"commissions_enabled":{"type":"boolean","description":"Cada cobro de Stripe genera la comisión del responsable del cliente"},"commission_default_bp":{"type":"integer","minimum":0,"maximum":10000,"description":"% por defecto en puntos básicos (1000 = 10 %) para el rol Ventas; cada miembro puede tener el suyo"},"commission_tiers":{"type":"array","items":{"$ref":"#/components/schemas/CommissionTier"},"maxItems":10,"description":"Escala por tramos para quien cobra el % por defecto (rol Ventas sin % propio): cada parte de un cobro paga el % del tramo en el que cae según lo vendido en el mes. Vacío = % fijo"},"commission_product_rates":{"type":"array","items":{"$ref":"#/components/schemas/CommissionProductRate"},"maxItems":30,"description":"% por producto: el primero que coincide sustituye al del comercial y a la escala"}}}}},"WorkspaceSetup":{"type":"object","properties":{"steps":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["country","lead_source","team","pipeline","ads"]},"done":{"type":"boolean"},"done_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Cuándo se cumplió (null si se dio por bueno a mano o aún no)"}},"required":["key","done","done_at"]}},"done":{"type":"integer"},"total":{"type":"integer"},"complete":{"type":"boolean"},"dismissed":{"type":"boolean","description":"Un admin ocultó la guía"}},"required":["steps","done","total","complete","dismissed"]},"WorkspaceSetupUpdate":{"type":"object","properties":{"pipeline_ok":{"type":"boolean","description":"Las etapas por defecto valen: el paso del pipeline queda hecho"},"dismissed":{"type":"boolean"}}},"OrgSecurity":{"type":"object","properties":{"require_admin_2fa":{"type":"boolean"},"can_manage":{"type":"boolean","description":"Propietario o admin de la agencia"},"admins_pending":{"type":"array","items":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"},"avatar_url":{"type":["string","null"],"description":"Foto de perfil lista para `<img>` (subida, ilustrada o del proveedor de acceso); null = iniciales"}},"required":["user_id","name","email","avatar_url"]},"description":"Administradores con contraseña y sin 2FA (solo para quien puede gestionarlo)"}},"required":["require_admin_2fa","can_manage","admins_pending"]},"OrgSecurityUpdate":{"type":"object","properties":{"require_admin_2fa":{"type":"boolean"}},"required":["require_admin_2fa"]},"Member":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"image":{"type":["string","null"]},"avatar_url":{"type":["string","null"],"description":"Foto de perfil lista para `<img>` (subida, ilustrada o del proveedor de acceso); null = iniciales"},"role":{"type":"string","enum":["admin","manager","sales","viewer"]},"visibility":{"type":"string","enum":["all","own"]},"joined_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"commission_rate_bp":{"type":["integer","null"],"description":"% propio en puntos básicos; null = el por defecto del espacio (solo Ventas)"},"commission_since":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Desde cuándo cobra comisión (null = desde que entró)"}},"required":["user_id","name","email","image","avatar_url","role","visibility","joined_at","commission_rate_bp","commission_since"]},"MemberAccountCreated":{"type":"object","properties":{"member":{"$ref":"#/components/schemas/Member"},"email_sent":{"type":"boolean","description":"Se envió el email para elegir contraseña"},"workspaces":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}}},"required":["member","email_sent","workspaces"]},"MemberAccountCreate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["admin","manager","sales","viewer"],"default":"sales"},"visibility":{"type":"string","enum":["all","own"],"default":"all"},"password":{"type":"string","minLength":10,"maxLength":128,"description":"Sin contraseña, le llega un email para elegirla"},"commission_rate_bp":{"type":["integer","null"],"minimum":0,"maximum":10000},"workspace_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":50,"description":"Otros espacios de la misma agencia con el mismo rol (hay que ser admin de cada uno)"}},"required":["name","email"]},"MemberUpdate":{"type":"object","properties":{"role":{"type":"string","enum":["admin","manager","sales","viewer"]},"visibility":{"type":"string","enum":["all","own"]},"commission_rate_bp":{"type":["integer","null"],"minimum":0,"maximum":10000,"description":"null = vuelve al % por defecto del espacio"},"commission_since":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}}},"Invitation":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["admin","manager","sales","viewer"]},"invited_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","email","role","invited_by","expires_at","created_at"]},"InvitationCreated":{"type":"object","properties":{"invitation":{"$ref":"#/components/schemas/Invitation"},"token":{"type":"string","description":"Solo se devuelve una vez; la web construye `/invite/{token}`"},"email_sent":{"type":"boolean","description":"true si se envió el email de invitación (SMTP configurado)"},"workspaces":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"description":"Workspaces a los que da acceso el enlace"},"skipped":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"description":"Workspaces pedidos donde la persona ya era miembro"}},"required":["invitation","token","email_sent","workspaces","skipped"]},"InvitationCreate":{"type":"object","properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["admin","manager","sales","viewer"],"default":"sales"},"workspace_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":50,"description":"Otros workspaces de la misma agencia a los que invitar a la vez con el mismo rol (hay que ser admin de cada uno). Un solo email y un solo enlace: aceptarlo da acceso a todos."}},"required":["email"]},"ApiKey":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"allowed_ips":{"type":"array","items":{"type":"string"},"description":"IPs o rangos CIDR desde los que se acepta; vacío = cualquiera"},"expires_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_used_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_used_ip":{"type":["string","null"]},"client_version":{"type":["string","null"],"description":"Versión del plugin de WordPress que usa la clave (si es el plugin)"},"client_site":{"type":["string","null"],"description":"Web de WordPress desde la que se usa"},"revoked_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","prefix","scopes","allowed_ips","expires_at","last_used_at","last_used_ip","client_version","client_site","revoked_at","created_at"]},"ApiKeyCreated":{"type":"object","properties":{"api_key":{"$ref":"#/components/schemas/ApiKey"},"secret":{"type":"string","description":"Solo se muestra una vez"}},"required":["api_key","secret"]},"ApiKeyCreate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":80},"scopes":{"type":"array","items":{"type":"string","enum":["read","write"]},"default":["read","write"]},"allowed_ips":{"type":"array","items":{"type":"string","minLength":2,"maxLength":49,"pattern":"^[0-9a-fA-F:.]+(\\/\\d{1,3})?$"},"maxItems":20,"default":[]},"expires_in_days":{"anyOf":[{"type":"number","enum":[30]},{"type":"number","enum":[90]},{"type":"number","enum":[180]},{"type":"number","enum":[365]},{"type":"null"}],"default":null,"description":"Caducidad; null = no caduca"}},"required":["name"]},"ApiKeyUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":80},"allowed_ips":{"type":"array","items":{"type":"string","minLength":2,"maxLength":49,"pattern":"^[0-9a-fA-F:.]+(\\/\\d{1,3})?$"},"maxItems":20}}},"CustomField":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"entity":{"type":"string","enum":["contact","company","deal"]},"key":{"type":"string"},"label":{"type":"string"},"type":{"type":"string","enum":["text","textarea","number","money","date","select","multiselect","checkbox","url","email","phone"]},"options":{"type":"array","items":{"type":"string"}},"required":{"type":"boolean"},"help":{"type":["string","null"]},"position":{"type":"integer"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","entity","key","label","type","options","required","help","position","created_at"]},"CustomFieldCreate":{"type":"object","properties":{"entity":{"type":"string","enum":["contact","company","deal"]},"label":{"type":"string","minLength":1,"maxLength":80},"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"type":{"type":"string","enum":["text","textarea","number","money","date","select","multiselect","checkbox","url","email","phone"]},"options":{"type":"array","items":{"type":"string","minLength":1,"maxLength":80},"maxItems":100,"default":[]},"required":{"type":"boolean","default":false},"help":{"type":["string","null"],"maxLength":200}},"required":["entity","label","type"]},"CustomFieldReorder":{"type":"object","properties":{"entity":{"type":"string","enum":["contact","company","deal"]},"ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"minItems":1,"maxItems":200}},"required":["entity","ids"]},"CustomFieldUpdate":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":80},"options":{"type":"array","items":{"type":"string","minLength":1,"maxLength":80},"maxItems":100},"required":{"type":"boolean"},"help":{"type":["string","null"],"maxLength":200}}},"SavedView":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"entity":{"type":"string","enum":["contact","company","deal"]},"name":{"type":"string"},"filters":{"type":"object","additionalProperties":{"type":"string"}},"shared":{"type":"boolean","description":"Visible para todo el espacio"},"mine":{"type":"boolean","description":"La creó el usuario actual (puede editarla)"},"owner":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"position":{"type":"integer"},"is_default":{"type":"boolean","description":"El usuario actual abre este listado con esta vista aplicada"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","entity","name","filters","shared","mine","owner","position","is_default","created_at","updated_at"]},"SavedViewCreate":{"type":"object","properties":{"entity":{"type":"string","enum":["contact","company","deal"]},"name":{"type":"string","minLength":1,"maxLength":60},"filters":{"type":"object","additionalProperties":{"type":"string","maxLength":200},"description":"Mismos parámetros que el listado (`q`, `owner_id` —`me` incluido—, `lifecycle_stage`, `tag_id`, `pipeline_id`, `status`)"},"shared":{"type":"boolean","default":false}},"required":["entity","name","filters"]},"SavedViewDefault":{"type":"object","properties":{"entity":{"type":"string","enum":["contact","company","deal"]},"view_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"`null` quita la vista predeterminada"}},"required":["entity","view_id"]},"SavedViewUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"filters":{"type":"object","additionalProperties":{"type":"string","maxLength":200},"description":"Mismos parámetros que el listado (`q`, `owner_id` —`me` incluido—, `lifecycle_stage`, `tag_id`, `pipeline_id`, `status`)"},"shared":{"type":"boolean"},"position":{"type":"integer","minimum":0,"maximum":1000}}},"Tag":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"color":{"type":"string","enum":["gray","red","orange","amber","green","teal","blue","indigo","purple","pink"]},"usage":{"type":"object","properties":{"contacts":{"type":"integer"},"companies":{"type":"integer"},"deals":{"type":"integer"}},"required":["contacts","companies","deals"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","color","usage","created_at"]},"TagCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":40},"color":{"type":"string","enum":["gray","red","orange","amber","green","teal","blue","indigo","purple","pink"],"default":"gray"}},"required":["name"]},"TagUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":40},"color":{"type":"string","enum":["gray","red","orange","amber","green","teal","blue","indigo","purple","pink"]}}},"Product":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"sku":{"type":["string","null"]},"description":{"type":["string","null"]},"unit_price":{"type":"integer","description":"Unidades menores (céntimos), en la moneda del workspace"},"billing":{"type":"string","enum":["one_time","monthly","yearly"]},"active":{"type":"boolean"},"deals":{"type":"integer","description":"Negocios con este producto en sus líneas"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","sku","description","unit_price","billing","active","deals","created_at"]},"ProductCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"sku":{"type":["string","null"],"maxLength":60},"description":{"type":["string","null"],"maxLength":2000},"unit_price":{"type":"integer","minimum":0},"billing":{"type":"string","enum":["one_time","monthly","yearly"],"default":"one_time"},"active":{"type":"boolean","default":true}},"required":["name","unit_price"]},"ProductUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"sku":{"type":["string","null"],"maxLength":60},"description":{"type":["string","null"],"maxLength":2000},"unit_price":{"type":"integer","minimum":0},"billing":{"type":"string","enum":["one_time","monthly","yearly"],"default":"one_time"},"active":{"type":"boolean","default":true}}},"BulkResult":{"type":"object","properties":{"updated":{"type":"integer"},"deleted":{"type":"integer"},"skipped":{"type":"integer","description":"Ids inexistentes o fuera de tu visibilidad"}},"required":["updated","deleted","skipped"]},"BulkAction":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"minItems":1,"maxItems":500},"action":{"type":"string","enum":["update","delete"]},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"`null` = sin responsable"},"lifecycle_stage":{"type":"string","enum":["lead","prospect","customer","churned","other"],"description":"Solo contactos"},"add_tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30},"remove_tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30}},"required":["ids","action"]},"Contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"first_name":{"type":"string"},"last_name":{"type":["string","null"]},"full_name":{"type":"string"},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"phone_status":{"$ref":"#/components/schemas/PhoneStatus"},"phone_suggestion":{"type":["string","null"],"description":"El teléfono sin prefijo completado con el país del espacio (`+34 699 88 87 77`); null si no aplica"},"job_title":{"type":["string","null"]},"company_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"company":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"owner_since":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Desde cuándo lo lleva su responsable actual"},"lifecycle_stage":{"type":"string","enum":["lead","prospect","customer","churned","other"]},"source":{"type":["string","null"]},"custom":{"type":"object","additionalProperties":{}},"tags":{"type":"array","items":{"$ref":"#/components/schemas/TagRef"}},"score":{"type":["integer","null"],"description":"Lead score 0–100 (null si el workspace no tiene reglas de puntuación)"},"score_tier":{"$ref":"#/components/schemas/ScoreTier"},"ads_consent":{"$ref":"#/components/schemas/AdsConsent"},"lead_received_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Último lead entrante (speed-to-lead)"},"origin":{"type":["object","null"],"properties":{"channel":{"$ref":"#/components/schemas/Channel"},"campaign":{"type":["string","null"]}},"required":["channel","campaign"],"description":"Canal y campaña del primer touch (o del `source` si no hay touches); null si no se sabe de dónde vino"},"first_response_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Primer contacto del equipo tras ese lead"},"last_activity_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","first_name","last_name","full_name","email","phone","phone_status","phone_suggestion","job_title","company_id","company","owner_id","owner_since","lifecycle_stage","source","custom","tags","score","score_tier","ads_consent","lead_received_at","origin","first_response_at","last_activity_at","created_at","updated_at"]},"PhoneStatus":{"type":["string","null"],"enum":["international","no_prefix","invalid",null],"description":"`international`: con prefijo y válido; `no_prefix`: sin prefijo (no se envía a Google, Meta ni WhatsApp); `invalid`: con prefijo pero no existe"},"TagRef":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"color":{"type":"string","enum":["gray","red","orange","amber","green","teal","blue","indigo","purple","pink"]}},"required":["id","name","color"]},"ScoreTier":{"type":["string","null"],"enum":["hot","warm","cold",null],"description":"Temperatura según los umbrales `score_hot` / `score_warm` del workspace"},"AdsConsent":{"type":["string","null"],"enum":["granted","denied",null],"description":"Consentimiento para usar sus datos en anuncios (conversiones y audiencias)"},"Channel":{"type":"string","enum":["google_ads","meta_ads","paid_other","organic_search","social","email","referral","direct","other","none"]},"ContactMerge":{"type":"object","properties":{"source_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Contacto duplicado que se fusiona en el de la URL y se elimina"}},"required":["source_id"]},"AutomationRuleList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AutomationRule"}}},"required":["data"]},"AutomationRule":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"enabled":{"type":"boolean"},"trigger":{"$ref":"#/components/schemas/AutomationTrigger"},"trigger_config":{"$ref":"#/components/schemas/TriggerConfig"},"conditions":{"type":"array","items":{"$ref":"#/components/schemas/RuleCondition"}},"actions":{"type":"array","items":{"$ref":"#/components/schemas/RuleAction"}},"run_count":{"type":"integer"},"last_run_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_error":{"type":["string","null"]},"last_error_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","enabled","trigger","trigger_config","conditions","actions","run_count","last_run_at","last_error","last_error_at","created_at","updated_at"]},"AutomationTrigger":{"type":"string","enum":["lead.received","contact.created","deal.created","deal.stage_changed","deal.won","deal.lost","deal.idle"]},"TriggerConfig":{"type":"object","properties":{"days":{"type":"integer","minimum":1,"maximum":365,"description":"Solo `deal.idle`: días sin actividad"}}},"RuleCondition":{"type":"object","properties":{"field":{"type":"string","maxLength":80,"pattern":"^(?:[a-z][a-z0-9_]*|custom\\.[a-z0-9_]{1,60})$"},"op":{"type":"string","enum":["eq","neq","gt","gte","lt","lte","contains","is_set","is_not_set"]},"value":{"anyOf":[{"type":"string","maxLength":300},{"type":"number"},{"type":"boolean"},{"type":"null"}]}},"required":["field","op"]},"RuleAction":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["create_task"]},"title":{"type":"string","minLength":1,"maxLength":200},"due_in_days":{"type":"integer","minimum":0,"maximum":365,"default":0},"priority":{"type":"string","enum":["low","normal","high"],"default":"normal"},"assignee":{"anyOf":[{"type":"string","enum":["owner"]},{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}],"default":"owner"}},"required":["type","title"]},{"type":"object","properties":{"type":{"type":"string","enum":["assign_owner"]},"user_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["type","user_id"]},{"type":"object","properties":{"type":{"type":"string","enum":["assign_round_robin"]},"user_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"minItems":2,"maxItems":20}},"required":["type","user_ids"],"description":"Reparte por turnos entre `user_ids` (en ese orden); se salta a quien ya no sea miembro"},{"type":"object","properties":{"type":{"type":"string","enum":["add_tag"]},"tag_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["type","tag_id"]},{"type":"object","properties":{"type":{"type":"string","enum":["set_priority"]},"priority":{"$ref":"#/components/schemas/DealPriority"}},"required":["type","priority"]},{"type":"object","properties":{"type":{"type":"string","enum":["set_lifecycle"]},"stage":{"type":"string","enum":["lead","prospect","customer","churned","other"]}},"required":["type","stage"]}]},"DealPriority":{"type":"string","enum":["normal","high"]},"AutomationRuleCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"enabled":{"type":"boolean","default":true},"trigger":{"$ref":"#/components/schemas/AutomationTrigger"},"trigger_config":{"$ref":"#/components/schemas/TriggerConfig"},"conditions":{"type":"array","items":{"$ref":"#/components/schemas/RuleCondition"},"maxItems":10,"default":[]},"actions":{"type":"array","items":{"$ref":"#/components/schemas/RuleAction"},"minItems":1,"maxItems":5}},"required":["name","trigger","actions"]},"AutomationRuleUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"enabled":{"type":"boolean"},"trigger_config":{"$ref":"#/components/schemas/TriggerConfig"},"conditions":{"type":"array","items":{"$ref":"#/components/schemas/RuleCondition"},"maxItems":10},"actions":{"type":"array","items":{"$ref":"#/components/schemas/RuleAction"},"minItems":1,"maxItems":5}}},"AutomationRunPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AutomationRun"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["data","next_cursor"]},"AutomationRun":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"rule_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"rule_name":{"type":"string"},"subject_type":{"type":"string","enum":["contact","deal"]},"subject_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"subject_label":{"type":["string","null"]},"status":{"type":"string","enum":["succeeded","failed"]},"effects":{"type":"array","items":{"type":"object","additionalProperties":{}}},"error":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","rule_id","rule_name","subject_type","subject_id","subject_label","status","effects","error","created_at"]},"ScoringRuleList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ScoringRule"}}},"required":["data"]},"ScoringRule":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"label":{"type":"string"},"condition":{"$ref":"#/components/schemas/RuleCondition"},"points":{"type":"integer"},"position":{"type":"integer"},"enabled":{"type":"boolean"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","label","condition","points","position","enabled","created_at","updated_at"]},"ScoringRuleCreate":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":120},"condition":{"$ref":"#/components/schemas/RuleCondition"},"points":{"type":"integer","minimum":-100,"maximum":100},"enabled":{"type":"boolean","default":true}},"required":["label","condition","points"]},"ScoringRuleUpdate":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":120},"condition":{"$ref":"#/components/schemas/RuleCondition"},"points":{"type":"integer","minimum":-100,"maximum":100},"enabled":{"type":"boolean"},"position":{"type":"integer","minimum":0,"maximum":1000}}},"ScoreBreakdown":{"type":"object","properties":{"score":{"type":["integer","null"],"description":"0–100; null si no hay reglas activas"},"raw":{"type":"integer","description":"Suma sin acotar de los puntos"},"items":{"type":"array","items":{"type":"object","properties":{"rule_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"label":{"type":"string"},"points":{"type":"integer"}},"required":["rule_id","label","points"]}},"tier":{"type":["string","null"],"enum":["hot","warm","cold",null]},"thresholds":{"type":"object","properties":{"hot":{"type":"integer"},"warm":{"type":"integer"}},"required":["hot","warm"]},"computed_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["score","raw","items","tier","thresholds","computed_at"]},"CompanyPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Company"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"Company":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"domain":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"]},"phone":{"type":["string","null"]},"address":{"type":["string","null"]},"description":{"type":["string","null"]},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"custom":{"type":"object","additionalProperties":{}},"tags":{"type":"array","items":{"$ref":"#/components/schemas/TagRef"}},"last_activity_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","domain","industry","size","phone","address","description","owner_id","custom","tags","last_activity_at","created_at","updated_at"]},"CompanyCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"domain":{"type":["string","null"],"maxLength":253},"industry":{"type":["string","null"],"maxLength":120},"size":{"type":["string","null"],"maxLength":40},"phone":{"type":["string","null"],"maxLength":40},"address":{"type":["string","null"],"maxLength":500},"description":{"type":["string","null"],"maxLength":5000},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"custom":{"type":"object","additionalProperties":{}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30,"description":"Sustituye todas las etiquetas del registro"}},"required":["name"]},"CompanyUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"domain":{"type":["string","null"],"maxLength":253},"industry":{"type":["string","null"],"maxLength":120},"size":{"type":["string","null"],"maxLength":40},"phone":{"type":["string","null"],"maxLength":40},"address":{"type":["string","null"],"maxLength":500},"description":{"type":["string","null"],"maxLength":5000},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"custom":{"type":"object","additionalProperties":{}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30,"description":"Sustituye todas las etiquetas del registro"}}},"ContactPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"PhoneFixPreview":{"type":"object","properties":{"country":{"type":["string","null"],"pattern":"^[A-Z]{2}$","example":"ES","description":"País del espacio; sin él no hay propuestas"},"fixable":{"type":"integer","description":"Teléfonos sin prefijo que se pueden completar"},"unfixable":{"type":"integer","description":"Sin prefijo y no válidos para el país: hay que corregirlos a mano"},"conflicts":{"type":"integer","description":"Se completarían, pero otro contacto ya tiene ese número"},"items":{"type":"array","items":{"$ref":"#/components/schemas/PhoneFixItem"},"description":"Muestra: primero los que se pueden completar (hasta `limit`)"}},"required":["country","fixable","unfixable","conflicts","items"]},"PhoneFixItem":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"full_name":{"type":"string"},"phone":{"type":"string","description":"Teléfono tal como está guardado"},"suggestion":{"type":["string","null"],"description":"Con el prefijo del país (`+34 699 88 87 77`); null si no es un número válido de ese país"},"conflict_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Otro contacto ya tiene ese número: no se cambia (fusiónalos desde la ficha)"}},"required":["contact_id","full_name","phone","suggestion","conflict_id"]},"PhoneFixResult":{"type":"object","properties":{"updated":{"type":"integer"},"skipped":{"type":"integer","description":"No válidos para el país o con conflicto"}},"required":["updated","skipped"]},"PhoneFixApply":{"type":"object","properties":{"country":{"type":"string","pattern":"^[A-Z]{2}$","example":"ES","description":"Por defecto, el del espacio"},"contact_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":5000,"description":"Solo estos contactos; sin la lista, todos los que se pueden completar"}}},"ContactCreate":{"type":"object","properties":{"first_name":{"type":"string","minLength":1,"maxLength":120},"last_name":{"type":["string","null"],"maxLength":120},"email":{"type":["string","null"],"maxLength":320,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"job_title":{"type":["string","null"],"maxLength":120},"company_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"lifecycle_stage":{"type":"string","enum":["lead","prospect","customer","churned","other"]},"source":{"type":["string","null"],"maxLength":120},"custom":{"type":"object","additionalProperties":{}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30,"description":"Sustituye todas las etiquetas del registro"},"ads_consent":{"$ref":"#/components/schemas/AdsConsent"},"attribution":{"$ref":"#/components/schemas/AttributionInput"}},"required":["first_name"]},"AttributionInput":{"type":"object","properties":{"utm_source":{"type":["string","null"],"maxLength":200,"description":"Alias de `source`"},"utm_medium":{"type":["string","null"],"maxLength":200,"description":"Alias de `medium`"},"utm_campaign":{"type":["string","null"],"maxLength":500,"description":"Alias de `campaign`"},"utm_id":{"type":["string","null"],"maxLength":100,"description":"Alias de `campaign_id`"},"utm_content":{"type":["string","null"],"maxLength":500,"description":"Alias de `content`"},"utm_term":{"type":["string","null"],"maxLength":500,"description":"Alias de `term`"},"source":{"type":["string","null"],"maxLength":200},"medium":{"type":["string","null"],"maxLength":200},"campaign":{"type":["string","null"],"maxLength":500},"campaign_id":{"type":["string","null"],"maxLength":100,"description":"Id de campaña de la plataforma (`utm_id`); casa el lead con el gasto de la campaña"},"adset_id":{"type":["string","null"],"maxLength":100,"description":"Id del conjunto (Meta) o grupo de anuncios (Google)"},"ad_id":{"type":["string","null"],"maxLength":100,"description":"Id del anuncio"},"content":{"type":["string","null"],"maxLength":500},"term":{"type":["string","null"],"maxLength":500},"lead_id":{"type":["string","null"],"maxLength":100,"description":"Id del lead en la plataforma (Meta Lead Ads / Google lead forms)"},"gclid":{"type":["string","null"],"maxLength":500},"gbraid":{"type":["string","null"],"maxLength":500},"wbraid":{"type":["string","null"],"maxLength":500},"fbclid":{"type":["string","null"],"maxLength":500},"fbc":{"type":["string","null"],"maxLength":500},"fbp":{"type":["string","null"],"maxLength":500},"landing_url":{"type":["string","null"],"maxLength":2000},"referrer":{"type":["string","null"],"maxLength":2000},"device":{"type":["string","null"],"enum":["mobile","tablet","desktop",null],"description":"Dispositivo del visitante (lo envía `ordyum.js`)"}}},"ContactAttribution":{"type":"object","properties":{"channel":{"allOf":[{"$ref":"#/components/schemas/Channel"},{"description":"Canal del primer contacto (o del campo `source` si no hay touches)"}]},"first":{"$ref":"#/components/schemas/AttributionTouch"},"last":{"allOf":[{"$ref":"#/components/schemas/AttributionTouch"},{"description":"Touch más reciente; null si coincide con `first`"}]},"converting":{"allOf":[{"$ref":"#/components/schemas/AttributionTouch"},{"description":"Touch que convirtió: el último antes del primer lead (null si coincide con `first`)"}]},"total":{"type":"integer"},"forms":{"type":"integer","description":"Formularios enviados (leads recibidos)"},"device":{"type":["string","null"],"enum":["mobile","tablet","desktop",null]},"match":{"type":"object","properties":{"consent":{"allOf":[{"$ref":"#/components/schemas/AdsConsent"},{"description":"Consentimiento del contacto; null = el general de cada conexión"}]},"google_ads":{"$ref":"#/components/schemas/MatchQuality"},"meta":{"$ref":"#/components/schemas/MatchQuality"}},"required":["consent","google_ads","meta"],"description":"Con qué señales se casarían sus conversiones en cada plataforma"}},"required":["channel","first","last","converting","total","forms","device","match"]},"AttributionTouch":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"touch_type":{"type":"string","enum":["first","last","other"]},"occurred_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"channel":{"$ref":"#/components/schemas/Channel"},"source":{"type":["string","null"]},"medium":{"type":["string","null"]},"campaign":{"type":["string","null"]},"campaign_id":{"type":["string","null"]},"adset_id":{"type":["string","null"]},"ad_id":{"type":["string","null"]},"content":{"type":["string","null"]},"term":{"type":["string","null"]},"lead_id":{"type":["string","null"]},"gclid":{"type":["string","null"]},"gbraid":{"type":["string","null"]},"wbraid":{"type":["string","null"]},"fbclid":{"type":["string","null"]},"fbc":{"type":["string","null"]},"fbp":{"type":["string","null"]},"landing_url":{"type":["string","null"]},"referrer":{"type":["string","null"]},"device":{"type":["string","null"],"enum":["mobile","tablet","desktop",null]}},"required":["id","touch_type","occurred_at","channel","source","medium","campaign","campaign_id","adset_id","ad_id","content","term","lead_id","gclid","gbraid","wbraid","fbclid","fbc","fbp","landing_url","referrer","device"]},"MatchQuality":{"type":"object","properties":{"level":{"type":"string","enum":["high","medium","low","none","blocked"],"description":"`high` = clic o lead de la plataforma; `medium` = varios datos personales; `low` = uno; `blocked` = consentimiento denegado"},"signals":{"type":"array","items":{"type":"string","enum":["click_id","lead_id","email","phone","name","browser_id"]}}},"required":["level","signals"]},"ContactUpdate":{"type":"object","properties":{"first_name":{"type":"string","minLength":1,"maxLength":120},"last_name":{"type":["string","null"],"maxLength":120},"email":{"type":["string","null"],"maxLength":320,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"job_title":{"type":["string","null"],"maxLength":120},"company_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"lifecycle_stage":{"type":"string","enum":["lead","prospect","customer","churned","other"]},"source":{"type":["string","null"],"maxLength":120},"custom":{"type":"object","additionalProperties":{}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30,"description":"Sustituye todas las etiquetas del registro"},"ads_consent":{"$ref":"#/components/schemas/AdsConsent"}}},"ContactImportResult":{"type":"object","properties":{"dry_run":{"type":"boolean"},"created":{"type":"integer"},"merged":{"type":"integer"},"skipped":{"type":"integer","description":"Duplicados de registros existentes con `duplicates=skip` (o sin nada que completar)"},"failed":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"row":{"type":"integer","description":"Índice 1-based dentro de `rows`"},"code":{"type":"string","enum":["missing_name","missing_title","invalid_email","invalid_stage","invalid_amount","invalid_date","invalid_currency","duplicate_in_file"]}},"required":["row","code"]}},"warnings":{"$ref":"#/components/schemas/ImportWarnings"},"companies_created":{"type":"integer"},"phone_issues":{"type":"object","properties":{"no_prefix":{"type":"integer"},"invalid":{"type":"integer"},"samples":{"type":"array","items":{"type":"object","properties":{"row":{"type":"integer"},"phone":{"type":"string"},"status":{"type":"string","enum":["no_prefix","invalid"]}},"required":["row","phone","status"]},"maxItems":8}},"required":["no_prefix","invalid","samples"],"description":"Filas importables cuyo teléfono no servirá para WhatsApp, Google ni Meta (se importan igualmente); hasta 8 ejemplos"}},"required":["dry_run","created","merged","skipped","failed","errors","warnings","companies_created","phone_issues"]},"ImportWarnings":{"type":"object","properties":{"unmatched_owners":{"type":"array","items":{"type":"string"},"description":"Responsables que no son miembros: se asigna `owner_id`"},"unmatched_pipelines":{"type":"array","items":{"type":"string"},"description":"Pipelines desconocidos: se usa el elegido o el principal"},"unmatched_stages":{"type":"array","items":{"type":"string"},"description":"Etapas desconocidas: se usa la primera etapa abierta"}},"required":["unmatched_owners","unmatched_pipelines","unmatched_stages"]},"ContactImport":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/ContactImportRow"},"minItems":1,"maxItems":2000},"duplicates":{"type":"string","enum":["skip","merge"],"default":"skip","description":"`merge` solo rellena campos vacíos del contacto existente"},"dry_run":{"type":"boolean","default":false},"source":{"type":"string","maxLength":120,"description":"Origen por defecto si la fila no trae uno (por defecto `import`)"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["rows"]},"ContactImportRow":{"type":"object","properties":{"name":{"type":["string","null"],"maxLength":240,"description":"Nombre completo; se usa si faltan first_name/last_name"},"first_name":{"type":["string","null"],"maxLength":120},"last_name":{"type":["string","null"],"maxLength":120},"email":{"type":["string","null"],"maxLength":320},"phone":{"type":["string","null"],"maxLength":40},"company":{"type":["string","null"],"maxLength":200},"lifecycle_stage":{"type":["string","null"],"maxLength":40,"description":"lead | prospect | customer | churned | other (o su traducción en/es/fr)"},"source":{"type":["string","null"],"maxLength":120},"owner":{"type":["string","null"],"maxLength":320,"description":"Email o nombre de un miembro del workspace; si no coincide, se usa `owner_id`"}}},"CompanyImportResult":{"type":"object","properties":{"dry_run":{"type":"boolean"},"created":{"type":"integer"},"merged":{"type":"integer"},"skipped":{"type":"integer","description":"Duplicados de registros existentes con `duplicates=skip` (o sin nada que completar)"},"failed":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"row":{"type":"integer","description":"Índice 1-based dentro de `rows`"},"code":{"type":"string","enum":["missing_name","missing_title","invalid_email","invalid_stage","invalid_amount","invalid_date","invalid_currency","duplicate_in_file"]}},"required":["row","code"]}},"warnings":{"$ref":"#/components/schemas/ImportWarnings"}},"required":["dry_run","created","merged","skipped","failed","errors","warnings"]},"CompanyImport":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/CompanyImportRow"},"minItems":1,"maxItems":2000},"duplicates":{"type":"string","enum":["skip","merge"],"default":"skip"},"dry_run":{"type":"boolean","default":false},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["rows"]},"CompanyImportRow":{"type":"object","properties":{"name":{"type":["string","null"],"maxLength":200},"domain":{"type":["string","null"],"maxLength":253},"industry":{"type":["string","null"],"maxLength":120},"size":{"type":["string","null"],"maxLength":40},"owner":{"type":["string","null"],"maxLength":320,"description":"Email o nombre de un miembro del workspace"},"external_id":{"type":["string","null"],"maxLength":120,"description":"ID en el CRM de origen (HubSpot Record ID, Pipedrive ID): deduplica reimportaciones"}}},"DealImportResult":{"type":"object","properties":{"dry_run":{"type":"boolean"},"created":{"type":"integer"},"merged":{"type":"integer"},"skipped":{"type":"integer","description":"Duplicados de registros existentes con `duplicates=skip` (o sin nada que completar)"},"failed":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"row":{"type":"integer","description":"Índice 1-based dentro de `rows`"},"code":{"type":"string","enum":["missing_name","missing_title","invalid_email","invalid_stage","invalid_amount","invalid_date","invalid_currency","duplicate_in_file"]}},"required":["row","code"]}},"warnings":{"$ref":"#/components/schemas/ImportWarnings"},"companies_created":{"type":"integer"},"contacts_created":{"type":"integer"}},"required":["dry_run","created","merged","skipped","failed","errors","warnings","companies_created","contacts_created"]},"DealImport":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/DealImportRow"},"minItems":1,"maxItems":2000},"duplicates":{"type":"string","enum":["skip","merge"],"default":"skip","description":"Solo con `external_id`; `merge` completa importe, fecha, contacto y empresa vacíos"},"dry_run":{"type":"boolean","default":false},"pipeline_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Pipeline por defecto (si no, el principal)"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["rows"]},"DealImportRow":{"type":"object","properties":{"title":{"type":["string","null"],"maxLength":200},"amount":{"type":["string","null"],"maxLength":40,"description":"Decimal en la moneda del negocio: `1234.5`, `1.234,50`, `€ 1,234`"},"currency":{"type":["string","null"],"maxLength":8},"pipeline":{"type":["string","null"],"maxLength":120,"description":"Nombre del pipeline (si no coincide, el elegido en la importación)"},"stage":{"type":["string","null"],"maxLength":120,"description":"Nombre de la etapa; también `won`/`lost` (Closed Won, Ganado, Gagné…)"},"status":{"type":["string","null"],"maxLength":40,"description":"open | won | lost (Pipedrive «Status»); manda sobre la etapa"},"expected_close_at":{"type":["string","null"],"maxLength":40},"closed_at":{"type":["string","null"],"maxLength":40,"description":"Fecha de ganado/perdido"},"created_at":{"type":["string","null"],"maxLength":40},"lost_reason":{"type":["string","null"],"maxLength":500},"company":{"type":["string","null"],"maxLength":200},"contact_email":{"type":["string","null"],"maxLength":320,"description":"Se enlaza al contacto con ese email (o se crea)"},"contact_name":{"type":["string","null"],"maxLength":240},"owner":{"type":["string","null"],"maxLength":320,"description":"Email o nombre de un miembro del workspace"},"external_id":{"type":["string","null"],"maxLength":120},"next_step":{"type":["string","null"],"maxLength":200,"description":"Siguiente paso de un negocio abierto (tarea)"},"next_step_date":{"type":["string","null"],"maxLength":40}}},"Pipeline":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"position":{"type":"integer"},"is_default":{"type":"boolean"},"stages":{"type":"array","items":{"$ref":"#/components/schemas/Stage"}},"rot":{"$ref":"#/components/schemas/RotThresholds"}},"required":["id","name","position","is_default","stages","rot"]},"Stage":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"position":{"type":"integer"},"probability":{"type":"integer"},"type":{"type":"string","enum":["open","won","lost"]},"deals":{"type":"integer","description":"Deals en la etapa"}},"required":["id","name","position","probability","type","deals"]},"RotThresholds":{"type":"object","properties":{"cooling":{"type":"integer","minimum":1,"maximum":365},"stale":{"type":"integer","minimum":1,"maximum":365},"at_risk":{"type":"integer","minimum":1,"maximum":365}},"required":["cooling","stale","at_risk"],"description":"Días sin actividad para Cooling / Stale / At risk (valores efectivos)"},"PipelineCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"copy_from":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Copia las etapas de otro pipeline; si no, etapas por defecto en el idioma del workspace"}},"required":["name"]},"IdsOrder":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"minItems":1,"maxItems":50}},"required":["ids"]},"PipelineUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"is_default":{"type":"boolean","enum":[true],"description":"Lo marca como principal (el anterior deja de serlo)"},"rot":{"type":["object","null"],"properties":{"cooling":{"type":"integer","minimum":1,"maximum":365},"stale":{"type":"integer","minimum":1,"maximum":365},"at_risk":{"type":"integer","minimum":1,"maximum":365}},"required":["cooling","stale","at_risk"],"description":"Umbrales de deal rot; null = valores por defecto"}}},"StageCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"type":{"type":"string","enum":["open","won","lost"],"default":"open"},"probability":{"type":"integer","minimum":0,"maximum":100,"description":"Ganada = 100 y perdida = 0 siempre"}},"required":["name"]},"StageUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"type":{"type":"string","enum":["open","won","lost"],"description":"Solo en etapas sin deals"},"probability":{"type":"integer","minimum":0,"maximum":100}}},"DealPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Deal"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"Deal":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"amount":{"type":"integer","description":"Unidades menores (céntimos)"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"pipeline_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"stage_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"status":{"type":"string","enum":["open","won","lost"]},"expected_close_at":{"type":["string","null"],"format":"date","example":"2026-11-30"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"contact_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"company_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"company":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"contact_score":{"type":["integer","null"],"description":"Lead score 0–100 del contacto vinculado (null sin contacto o sin reglas)"},"next_step":{"type":["object","null"],"properties":{"task_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"due_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["task_id","title","due_at"]},"is_stale":{"type":"boolean"},"rot":{"type":["object","null"],"properties":{"status":{"$ref":"#/components/schemas/RotStatus"},"days":{"type":"integer"}},"required":["status","days"],"description":"Frescura del deal abierto según los umbrales de su pipeline (null si está cerrado)"},"stage_changed_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"won_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"lost_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"lost_reason":{"type":["string","null"]},"lost_reason_code":{"$ref":"#/components/schemas/LostReasonCode"},"priority":{"$ref":"#/components/schemas/DealPriority"},"tags":{"type":"array","items":{"$ref":"#/components/schemas/TagRef"}},"custom":{"type":"object","additionalProperties":{}},"line_items":{"type":"array","items":{"$ref":"#/components/schemas/LineItem"},"description":"Solo en el detalle (`GET /deals/{id}`)"},"last_activity_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","title","amount","currency","pipeline_id","stage_id","status","expected_close_at","owner_id","contact_id","company_id","contact","company","contact_score","next_step","is_stale","rot","stage_changed_at","won_at","lost_at","lost_reason","lost_reason_code","priority","tags","custom","last_activity_at","created_at","updated_at"]},"RotStatus":{"type":"string","enum":["fresh","healthy","cooling","stale","at_risk"]},"LostReasonCode":{"type":["string","null"],"enum":["price","competitor","no_response","timing","no_budget","not_qualified","other",null]},"LineItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"product_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"quantity":{"type":"number"},"unit_price":{"type":"integer"},"discount":{"type":"number","description":"Porcentaje 0–100"},"total":{"type":"integer","description":"quantity × unit_price × (1 − discount/100), redondeado"}},"required":["id","product_id","name","quantity","unit_price","discount","total"]},"DealCreate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"amount":{"type":"integer","minimum":0,"default":0},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"pipeline_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"stage_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"expected_close_at":{"type":["string","null"],"format":"date","example":"2026-11-30"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"contact_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"company_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"priority":{"$ref":"#/components/schemas/DealPriority"},"custom":{"type":"object","additionalProperties":{}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30,"description":"Sustituye todas las etiquetas del registro"},"line_items":{"type":"array","items":{"$ref":"#/components/schemas/LineItemInput"},"maxItems":100,"description":"Sustituye todas las líneas; con líneas, `amount` se calcula como su suma"},"next_step":{"$ref":"#/components/schemas/NextStepInput"}},"required":["title"]},"LineItemInput":{"type":"object","properties":{"product_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string","minLength":1,"maxLength":200},"quantity":{"type":"number","exclusiveMinimum":0,"maximum":1000000,"default":1},"unit_price":{"type":"integer","minimum":0},"discount":{"type":"number","minimum":0,"maximum":100,"default":0}},"required":["name","unit_price"]},"NextStepInput":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"due_at":{"type":"string","format":"date-time"}},"required":["title","due_at"],"description":"Obligatorio si la etapa es abierta"},"DealUpdate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"amount":{"type":"integer","minimum":0,"default":0},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"expected_close_at":{"type":["string","null"],"format":"date","example":"2026-11-30"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"contact_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"company_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"priority":{"$ref":"#/components/schemas/DealPriority"},"custom":{"type":"object","additionalProperties":{}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":30,"description":"Sustituye todas las etiquetas del registro"},"line_items":{"type":"array","items":{"$ref":"#/components/schemas/LineItemInput"},"maxItems":100,"description":"Sustituye todas las líneas; con líneas, `amount` se calcula como su suma"}}},"DealMove":{"type":"object","properties":{"stage_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"next_step":{"$ref":"#/components/schemas/NextStepInput"},"lost_reason_code":{"allOf":[{"$ref":"#/components/schemas/LostReasonCode"},{"description":"Motivo estructurado; obligatorio (o `lost_reason`) al perder"}]},"lost_reason":{"type":"string","maxLength":500,"description":"Detalle libre; sin código se guarda como `other`"}},"required":["stage_id"]},"TaskPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Task"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"Task":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"due_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"assignee_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"subject_type":{"type":["string","null"],"enum":["contact","company","deal",null]},"subject_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"subject":{"type":["object","null"],"properties":{"type":{"type":"string","enum":["contact","company","deal"]},"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"label":{"type":"string"}},"required":["type","id","label"]},"priority":{"type":"string","enum":["low","normal","high"]},"done_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","title","due_at","assignee_id","subject_type","subject_id","subject","priority","done_at","created_at","updated_at"]},"TaskCreate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"due_at":{"type":["string","null"],"format":"date-time"},"assignee_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"subject_type":{"type":["string","null"],"enum":["contact","company","deal",null]},"subject_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"priority":{"type":"string","enum":["low","normal","high"]}},"required":["title"]},"TaskUpdate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"due_at":{"type":["string","null"],"format":"date-time"},"assignee_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"priority":{"type":"string","enum":["low","normal","high"]}}},"TaskCompleted":{"type":"object","properties":{"task":{"$ref":"#/components/schemas/Task"},"deal_needs_next_step":{"type":"boolean"}},"required":["task","deal_needs_next_step"]},"TaskComplete":{"type":"object","properties":{"next_step":{"$ref":"#/components/schemas/NextStepInput"}}},"ActivityPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Activity"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"Activity":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"type":{"type":"string","enum":["note","email","call","meeting","system"]},"subject_type":{"type":"string","enum":["contact","company","deal"]},"subject_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"actor_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"actor_name":{"type":["string","null"]},"occurred_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"body":{"type":["string","null"]},"payload":{"type":"object","additionalProperties":{}},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","type","subject_type","subject_id","actor_id","actor_name","occurred_at","body","payload","created_at"]},"ActivityCreate":{"type":"object","properties":{"type":{"type":"string","enum":["note","email","call","meeting"]},"subject_type":{"type":"string","enum":["contact","company","deal"]},"subject_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"body":{"type":["string","null"],"maxLength":20000},"occurred_at":{"type":"string","format":"date-time"},"payload":{"type":"object","additionalProperties":{}}},"required":["type","subject_type","subject_id"]},"Today":{"type":"object","properties":{"overdue":{"type":"array","items":{"$ref":"#/components/schemas/Task"}},"due_today":{"type":"array","items":{"$ref":"#/components/schemas/Task"}},"upcoming":{"type":"array","items":{"$ref":"#/components/schemas/Task"}},"deals_without_next_step":{"type":"array","items":{"$ref":"#/components/schemas/Deal"}},"stale_deals":{"type":"array","items":{"$ref":"#/components/schemas/Deal"}},"new_leads":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"full_name":{"type":"string"},"source":{"type":["string","null"]},"lead_received_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"sla_minutes":{"type":"integer"},"overdue":{"type":"boolean","description":"Ya superó el SLA de primer contacto"}},"required":["id","full_name","source","lead_received_at","sla_minutes","overdue"]},"description":"Leads del usuario aún sin primer contacto (últimos 7 días)"}},"required":["overdue","due_today","upcoming","deals_without_next_step","stale_deals","new_leads"]},"Summary":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"from":{"type":"string","format":"date","example":"2026-11-30"},"to":{"type":"string","format":"date","example":"2026-11-30"},"pipeline_value":{"type":"integer"},"weighted_value":{"type":"integer"},"open_deals":{"type":"integer"},"other_currency_deals":{"type":"integer","description":"Negocios abiertos o ganados en el periodo en una moneda sin tipo de cambio: cuentan en las unidades, no en los importes"},"converted_deals":{"type":"integer","description":"Negocios abiertos o ganados en el periodo en otra moneda, sumados al tipo de referencia del BCE de `fx_date`"},"fx_date":{"type":["string","null"],"format":"date","example":"2026-11-30","description":"Fecha del tipo de cambio usado; null si no hay tipos guardados"},"current":{"type":"object","properties":{"new_contacts":{"type":"integer"},"new_deals":{"type":"integer"},"won_count":{"type":"integer"},"won_amount":{"type":"integer"}},"required":["new_contacts","new_deals","won_count","won_amount"]},"previous":{"type":"object","properties":{"new_contacts":{"type":"integer"},"new_deals":{"type":"integer"},"won_count":{"type":"integer"},"won_amount":{"type":"integer"}},"required":["new_contacts","new_deals","won_count","won_amount"]},"lead_sources":{"type":"array","items":{"type":"object","properties":{"channel":{"$ref":"#/components/schemas/Channel"},"count":{"type":"integer"}},"required":["channel","count"]},"description":"Contactos nuevos del periodo por canal de adquisición, de mayor a menor"}},"required":["currency","from","to","pipeline_value","weighted_value","open_deals","other_currency_deals","converted_deals","fx_date","current","previous","lead_sources"]},"SearchResult":{"type":"object","properties":{"contacts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"label":{"type":"string"},"sublabel":{"type":["string","null"]}},"required":["id","label","sublabel"]}},"companies":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"label":{"type":"string"},"sublabel":{"type":["string","null"]}},"required":["id","label","sublabel"]}},"deals":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"label":{"type":"string"},"sublabel":{"type":["string","null"]},"amount":{"type":"integer"},"currency":{"type":"string"}},"required":["id","label","sublabel","amount","currency"]}}},"required":["contacts","companies","deals"]},"FxRates":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"date":{"type":["string","null"],"format":"date","example":"2026-11-30"},"factors":{"type":"object","additionalProperties":{"type":"number"},"description":"Importe en esa moneda × factor = importe en la moneda del espacio. Sin clave = sin tipo de cambio"}},"required":["currency","date","factors"]},"LeadResult":{"type":"object","properties":{"contact":{"$ref":"#/components/schemas/Contact"},"created":{"type":"boolean","description":"`false` si el lead coincidió con un contacto existente (email/teléfono)"},"task":{"allOf":[{"$ref":"#/components/schemas/Task"},{"type":["object","null"]}]},"repeat":{"type":"boolean","description":"`true` si era un reenvío idéntico (mismo contacto, origen y mensaje en los últimos 10 min): no se registró de nuevo"}},"required":["contact","created","task","repeat"]},"LeadCreate":{"type":"object","properties":{"name":{"type":["string","null"],"maxLength":240,"description":"Nombre completo; alternativa a first_name/last_name"},"first_name":{"type":["string","null"],"maxLength":120},"last_name":{"type":["string","null"],"maxLength":120},"email":{"type":["string","null"],"maxLength":320,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"company":{"type":["string","null"],"maxLength":200,"description":"Nombre de empresa; se reutiliza si ya existe"},"job_title":{"type":["string","null"],"maxLength":120},"message":{"type":["string","null"],"maxLength":5000},"source":{"type":["string","null"],"maxLength":120,"example":"wordpress"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"custom":{"type":"object","additionalProperties":{}},"attribution":{"$ref":"#/components/schemas/AttributionInput"},"utm_source":{"type":["string","null"],"maxLength":200,"description":"Alias de `source`"},"utm_medium":{"type":["string","null"],"maxLength":200,"description":"Alias de `medium`"},"utm_campaign":{"type":["string","null"],"maxLength":500,"description":"Alias de `campaign`"},"utm_id":{"type":["string","null"],"maxLength":100,"description":"Alias de `campaign_id`"},"utm_content":{"type":["string","null"],"maxLength":500,"description":"Alias de `content`"},"utm_term":{"type":["string","null"],"maxLength":500,"description":"Alias de `term`"},"gclid":{"type":["string","null"],"maxLength":500,"description":"Alias de `attribution.gclid`"},"fbclid":{"type":["string","null"],"maxLength":500,"description":"Alias de `attribution.fbclid`"},"ads_consent":{"type":["string","null"],"enum":["granted","denied",null],"description":"Casilla de consentimiento de anuncios del formulario; solo se guarda si viene"}}},"OrderResult":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"contact_created":{"type":"boolean"},"duplicate":{"type":"boolean"},"deal_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["contact_id","contact_created","duplicate","deal_id"]},"OrderCreate":{"type":"object","properties":{"external_id":{"type":"string","minLength":1,"maxLength":100,"description":"Id del pedido en la tienda; con `source` deduplica reenvíos","example":"4521"},"source":{"type":"string","pattern":"^[a-z0-9][a-z0-9_.-]{0,39}$","default":"api","description":"Plataforma en minúsculas","example":"woocommerce"},"number":{"type":["string","null"],"maxLength":60,"description":"Número visible del pedido","example":"#4521"},"status":{"type":"string","enum":["pending","paid"],"default":"paid","description":"`paid` marca al contacto como cliente y, con `create_deal`, crea el negocio ganado"},"amount":{"type":"integer","minimum":0,"maximum":10000000000000,"description":"Total en unidades menores (céntimos)"},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"ISO 4217; por defecto la del workspace"},"customer":{"type":"object","properties":{"email":{"type":["string","null"],"maxLength":320,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"first_name":{"type":["string","null"],"maxLength":120},"last_name":{"type":["string","null"],"maxLength":120},"company":{"type":["string","null"],"maxLength":200}}},"items":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"quantity":{"type":"integer","minimum":1,"maximum":100000,"default":1},"price":{"type":["integer","null"],"minimum":0}},"required":["title"]},"maxItems":50},"attribution":{"$ref":"#/components/schemas/AttributionInput"},"create_deal":{"type":"boolean","default":false,"description":"Pedido pagado → negocio ganado (y conversión offline a Google Ads / Meta si están conectados)"}},"required":["external_id","amount","customer"]},"LeadRepeatStats":{"type":"object","properties":{"days":{"type":"integer"},"total":{"type":"integer"},"by_source":{"type":"array","items":{"type":"object","properties":{"source":{"type":"string"},"count":{"type":"integer"},"last_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["source","count","last_at"]}},"recent":{"type":"array","items":{"type":"object","properties":{"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"source":{"type":"string"},"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["contact","source","at"]}}},"required":["days","total","by_source","recent"]},"WebhookEndpoint":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"url":{"type":"string"},"description":{"type":["string","null"]},"events":{"type":"array","items":{"type":"string","enum":["contact.created","contact.updated","contact.deleted","company.created","company.updated","company.deleted","deal.created","deal.updated","deal.stage_changed","deal.won","deal.lost","deal.deleted","task.created","task.updated","task.completed","activity.created","lead.received","form.submitted","message.received","message.sent"]},"description":"Vacío = todos los eventos"},"enabled":{"type":"boolean"},"disabled_reason":{"type":["string","null"],"enum":["manual","too_many_failures",null]},"secret_hint":{"type":"string","example":"whsec_…f3a9"},"consecutive_failures":{"type":"integer"},"last_delivery":{"type":["object","null"],"properties":{"status":{"type":"string","enum":["pending","succeeded","failed"]},"status_code":{"type":["integer","null"]},"error":{"type":["string","null"],"description":"Último error si el intento falló (se reintentará si `status` es `pending`)"},"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["status","status_code","error","at"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","url","description","events","enabled","disabled_reason","secret_hint","consecutive_failures","last_delivery","created_at","updated_at"]},"WebhookEndpointCreated":{"type":"object","properties":{"endpoint":{"$ref":"#/components/schemas/WebhookEndpoint"},"secret":{"type":"string","description":"Clave de firma HMAC. Solo se muestra una vez."}},"required":["endpoint","secret"]},"WebhookEndpointCreate":{"type":"object","properties":{"url":{"type":"string","maxLength":2000,"format":"uri","example":"https://hooks.example.com/ordyum","description":"HTTPS en producción"},"description":{"type":["string","null"],"maxLength":200},"events":{"type":"array","items":{"type":"string","enum":["contact.created","contact.updated","contact.deleted","company.created","company.updated","company.deleted","deal.created","deal.updated","deal.stage_changed","deal.won","deal.lost","deal.deleted","task.created","task.updated","task.completed","activity.created","lead.received","form.submitted","message.received","message.sent"]},"maxItems":20,"default":[]}},"required":["url"]},"WebhookEndpointUpdate":{"type":"object","properties":{"url":{"type":"string","maxLength":2000,"format":"uri","example":"https://hooks.example.com/ordyum","description":"HTTPS en producción"},"description":{"type":["string","null"],"maxLength":200},"events":{"type":"array","items":{"type":"string","enum":["contact.created","contact.updated","contact.deleted","company.created","company.updated","company.deleted","deal.created","deal.updated","deal.stage_changed","deal.won","deal.lost","deal.deleted","task.created","task.updated","task.completed","activity.created","lead.received","form.submitted","message.received","message.sent"]},"maxItems":20},"enabled":{"type":"boolean"}}},"WebhookDelivery":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"endpoint_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"event_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"event_type":{"type":"string"},"status":{"type":"string","enum":["pending","succeeded","failed"]},"attempts":{"type":"integer"},"last_status_code":{"type":["integer","null"]},"last_error":{"type":["string","null"]},"last_duration_ms":{"type":["integer","null"]},"next_attempt_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"delivered_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"payload":{"type":"object","additionalProperties":{}}},"required":["id","endpoint_id","event_id","event_type","status","attempts","last_status_code","last_error","last_duration_ms","next_attempt_at","delivered_at","created_at","payload"]},"WebhookDeliveryPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookDelivery"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AdConnectionList":{"type":"object","properties":{"connections":{"type":"array","items":{"$ref":"#/components/schemas/AdConnection"}},"google_ads_available":{"type":"boolean"}},"required":["connections","google_ads_available"]},"AdConnection":{"type":"object","properties":{"platform":{"type":"string","enum":["google_ads","meta"]},"connected":{"type":"boolean"},"enabled":{"type":"boolean"},"ready":{"type":"boolean"},"config":{"type":"object","additionalProperties":{"type":["string","null"]},"description":"Google Ads: `customer_id`, `conversion_action_id`, `login_customer_id`, `enhanced_conversions` (`on`/`off`), `ad_user_data_consent` (`granted`/`denied`), `stage_conversion_action_id`, `stage_ids`. Meta: `pixel_id`, `test_event_code`, `ad_account_id`, `stage_ids`. `stage_ids` = ids de etapas abiertas separados por comas que también se envían como conversión."},"credentials_hint":{"type":["string","null"],"description":"Últimos caracteres del token guardado; el token nunca sale de la API."},"uses_platform_credentials":{"type":"boolean"},"last_success_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_error":{"type":["string","null"]},"last_error_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"stats":{"type":"object","properties":{"sent":{"type":"integer"},"pending":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}},"required":["sent","pending","failed","skipped"],"description":"Últimos 30 días"},"spend_available":{"type":"boolean"},"spend_synced_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"spend_error":{"type":["string","null"]},"updated_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["platform","connected","enabled","ready","config","credentials_hint","uses_platform_credentials","last_success_at","last_error","last_error_at","stats","spend_available","spend_synced_at","spend_error","updated_at"]},"AdConnectionUpdate":{"type":"object","properties":{"enabled":{"type":"boolean"},"config":{"type":"object","additionalProperties":{"type":["string","null"],"maxLength":1000}},"secret":{"type":["string","null"],"minLength":10,"maxLength":4000}}},"AdConnectionTest":{"type":"object","properties":{"ok":{"type":"boolean"},"detail":{"type":["string","null"]},"error":{"type":["string","null"]}},"required":["ok","detail","error"]},"AdConnectionBackfillResult":{"type":"object","properties":{"queued":{"type":"integer"},"skipped":{"type":"integer"}},"required":["queued","skipped"]},"AdConnectionBackfill":{"type":"object","properties":{"days":{"type":"integer","minimum":1,"maximum":90,"default":30,"description":"Meta solo acepta eventos de los últimos 7 días."}}},"ConversionUploadPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ConversionUpload"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"ConversionUpload":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"platform":{"type":"string","enum":["google_ads","meta"]},"deal":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"}},"required":["id","title"]},"event":{"type":"string","description":"`won` (venta) o `stage:<id>` (llegada a una etapa configurada)"},"event_name":{"type":["string","null"],"description":"Nombre de la etapa en eventos por etapa"},"status":{"type":"string","enum":["pending","sent","failed","skipped"]},"match_key":{"type":["string","null"],"description":"`gclid`, `gbraid`, `wbraid`, `fbc`, `lead_id` o `user_data`"},"value":{"type":"integer","description":"Unidades menores"},"currency":{"type":"string"},"conversion_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"attempts":{"type":"integer"},"last_error":{"type":["string","null"],"description":"Error de la plataforma o motivo de omisión (`no_click_id`…)"},"sent_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","platform","deal","event","event_name","status","match_key","value","currency","conversion_at","attempts","last_error","sent_at","created_at"]},"AdSpendSyncResult":{"type":"object","properties":{"ok":{"type":"boolean"},"rows":{"type":"integer"},"error":{"type":["string","null"]},"synced_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["ok","rows","error","synced_at"]},"AdsReport":{"type":"object","properties":{"from":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"to":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"currency":{"type":"string"},"mixed_currency":{"type":"boolean"},"audience":{"type":"string","enum":["team","client"]},"platforms":{"type":"array","items":{"$ref":"#/components/schemas/AdPlatformPerformance"}},"campaigns":{"type":"array","items":{"$ref":"#/components/schemas/AdCampaignPerformance"}},"units":{"type":"array","items":{"$ref":"#/components/schemas/AdUnitPerformance"}}},"required":["from","to","currency","mixed_currency","audience","platforms","campaigns","units"]},"AdPlatformPerformance":{"type":"object","properties":{"platform":{"type":"string","enum":["google_ads","meta"]},"spend":{"type":"integer","description":"Unidades menores en la moneda de la cuenta publicitaria"},"clicks":{"type":"integer"},"impressions":{"type":"integer"},"leads":{"type":"integer","description":"Contactos creados en el periodo cuyo primer touch es esta campaña"},"won_count":{"type":"integer"},"won_amount":{"type":"integer","description":"Ingresos ganados en el periodo, moneda del workspace"},"cpl":{"type":["integer","null"],"description":"Coste por lead; `null` sin leads o con otra moneda"},"roas":{"type":["number","null"],"description":"Ingresos / gasto; `null` sin gasto o con otra moneda"},"qualified":{"type":"integer","description":"Leads del periodo que ya tienen un negocio o son prospecto/cliente"},"customers":{"type":"integer","description":"Contactos distintos con una venta ganada en el periodo"},"cost_per_qualified":{"type":["integer","null"],"description":"Gasto / cualificados; `null` sin cualificados o con otra moneda"},"cac":{"type":["integer","null"],"description":"Coste de adquisición de cliente: gasto / clientes; `null` sin clientes o con otra moneda"},"available":{"type":"boolean"},"synced_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"spend_error":{"type":["string","null"]}},"required":["platform","spend","clicks","impressions","leads","won_count","won_amount","cpl","roas","qualified","customers","cost_per_qualified","cac","available","synced_at","spend_error"]},"AdCampaignPerformance":{"type":"object","properties":{"platform":{"type":"string","enum":["google_ads","meta"]},"campaign_id":{"type":["string","null"]},"campaign_name":{"type":["string","null"]},"spend":{"type":"integer","description":"Unidades menores en la moneda de la cuenta publicitaria"},"currency":{"type":["string","null"]},"clicks":{"type":"integer"},"impressions":{"type":"integer"},"leads":{"type":"integer","description":"Contactos creados en el periodo cuyo primer touch es esta campaña"},"won_count":{"type":"integer"},"won_amount":{"type":"integer","description":"Ingresos ganados en el periodo, moneda del workspace"},"cpl":{"type":["integer","null"],"description":"Coste por lead; `null` sin leads o con otra moneda"},"roas":{"type":["number","null"],"description":"Ingresos / gasto; `null` sin gasto o con otra moneda"},"qualified":{"type":"integer","description":"Leads del periodo que ya tienen un negocio o son prospecto/cliente"},"customers":{"type":"integer","description":"Contactos distintos con una venta ganada en el periodo"},"cost_per_qualified":{"type":["integer","null"],"description":"Gasto / cualificados; `null` sin cualificados o con otra moneda"},"cac":{"type":["integer","null"],"description":"Coste de adquisición de cliente: gasto / clientes; `null` sin clientes o con otra moneda"}},"required":["platform","campaign_id","campaign_name","spend","currency","clicks","impressions","leads","won_count","won_amount","cpl","roas","qualified","customers","cost_per_qualified","cac"]},"AdUnitPerformance":{"allOf":[{"$ref":"#/components/schemas/AdCampaignPerformance"},{"type":"object","properties":{"level":{"type":"string","enum":["adset","ad"]},"adset_id":{"type":["string","null"]},"adset_name":{"type":["string","null"]},"ad_id":{"type":["string","null"]},"ad_name":{"type":["string","null"]}},"required":["level","adset_id","adset_name","ad_id","ad_name"]}]},"AdAudienceList":{"type":"object","properties":{"audiences":{"type":"array","items":{"$ref":"#/components/schemas/AdAudience"}},"limit":{"type":"integer"},"platforms":{"type":"array","items":{"type":"string","enum":["google_ads","meta"]}}},"required":["audiences","limit","platforms"]},"AdAudience":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"platform":{"type":"string","enum":["google_ads","meta"]},"name":{"type":"string"},"segment":{"$ref":"#/components/schemas/AudienceSegment"},"enabled":{"type":"boolean"},"external_id":{"type":["string","null"]},"status":{"type":"string","enum":["pending","syncing","synced","error"]},"member_count":{"type":"integer"},"eligible_count":{"type":"integer"},"last_synced_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_error":{"type":["string","null"]},"next_sync_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","platform","name","segment","enabled","external_id","status","member_count","eligible_count","last_synced_at","last_error","next_sync_at","created_at","updated_at"]},"AudienceSegment":{"type":"object","properties":{"lifecycle_stage":{"type":"string","enum":["lead","prospect","customer","churned","other"]},"tag_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"min_score":{"type":"integer","minimum":0,"maximum":1000},"owner_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"description":"Filtros combinados con AND. Vacío = todos los contactos con email o teléfono."},"AdAudienceCreate":{"type":"object","properties":{"platform":{"type":"string","enum":["google_ads","meta"]},"name":{"type":"string","minLength":1,"maxLength":120},"segment":{"$ref":"#/components/schemas/AudienceSegment"},"enabled":{"type":"boolean","default":true}},"required":["platform","name"]},"AdAudienceUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"segment":{"$ref":"#/components/schemas/AudienceSegment"},"enabled":{"type":"boolean"}}},"AdAudienceSyncResult":{"type":"object","properties":{"ok":{"type":"boolean"},"member_count":{"type":"integer"},"error":{"type":["string","null"]},"synced_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["ok","member_count","error","synced_at"]},"Report":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"from":{"type":"string","format":"date","example":"2026-11-30"},"to":{"type":"string","format":"date","example":"2026-11-30"},"pipeline":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"other_currency_deals":{"type":"integer","description":"Negocios del pipeline abiertos o ganados en el periodo en una moneda sin tipo de cambio: no suman en los importes"},"converted_deals":{"type":"integer","description":"Negocios del pipeline abiertos o ganados en el periodo en otra moneda, convertidos al tipo del BCE de `fx_date`"},"fx_date":{"type":["string","null"],"format":"date","example":"2026-11-30"},"totals":{"type":"object","properties":{"new_contacts":{"type":"integer"},"new_deals":{"type":"integer"},"won_count":{"type":"integer"},"won_amount":{"type":"integer","description":"Unidades menores en la moneda del workspace"},"lost_count":{"type":"integer"},"win_rate":{"type":["number","null"],"minimum":0,"maximum":1,"description":"Ganados / (ganados + perdidos) cerrados en el periodo"},"avg_won_amount":{"type":["integer","null"],"description":"Unidades menores en la moneda del workspace"},"avg_cycle_days":{"type":["number","null"],"description":"Días medios desde la creación hasta ganado"}},"required":["new_contacts","new_deals","won_count","won_amount","lost_count","win_rate","avg_won_amount","avg_cycle_days"]},"funnel":{"type":"array","items":{"type":"object","properties":{"stage_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"type":{"type":"string","enum":["open","won"]},"reached":{"type":"integer","description":"Negocios creados en el periodo que llegaron a esta etapa"}},"required":["stage_id","name","type","reached"]},"description":"Embudo de conversión por etapas (historial de cambios de etapa)"},"open_by_stage":{"type":"array","items":{"type":"object","properties":{"stage_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"probability":{"type":"integer"},"count":{"type":"integer"},"amount":{"type":"integer","description":"Unidades menores en la moneda del workspace"},"weighted":{"type":"integer","description":"Unidades menores en la moneda del workspace"}},"required":["stage_id","name","probability","count","amount","weighted"]}},"monthly":{"type":"array","items":{"type":"object","properties":{"month":{"type":"string","example":"2026-09"},"new_deals":{"type":"integer"},"won_count":{"type":"integer"},"won_amount":{"type":"integer","description":"Unidades menores en la moneda del workspace"},"lost_count":{"type":"integer"}},"required":["month","new_deals","won_count","won_amount","lost_count"]}},"forecast":{"type":"array","items":{"type":"object","properties":{"bucket":{"type":"string","description":"`YYYY-MM`, `overdue` (fecha pasada) o `none` (sin fecha)"},"count":{"type":"integer"},"amount":{"type":"integer","description":"Unidades menores en la moneda del workspace"},"weighted":{"type":"integer","description":"Unidades menores en la moneda del workspace"}},"required":["bucket","count","amount","weighted"]},"description":"Pipeline abierto por mes de cierre previsto"},"by_owner":{"type":"array","items":{"type":"object","properties":{"user":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"open_count":{"type":"integer"},"open_amount":{"type":"integer","description":"Unidades menores en la moneda del workspace"},"won_count":{"type":"integer"},"won_amount":{"type":"integer","description":"Unidades menores en la moneda del workspace"},"lost_count":{"type":"integer"},"activities":{"type":"integer"},"tasks_done":{"type":"integer"}},"required":["user","open_count","open_amount","won_count","won_amount","lost_count","activities","tasks_done"]}},"lost_reasons":{"type":"array","items":{"type":"object","properties":{"reason":{"type":"string"},"count":{"type":"integer"}},"required":["reason","count"]}},"lead_sources":{"type":"array","items":{"type":"object","properties":{"channel":{"$ref":"#/components/schemas/Channel"},"count":{"type":"integer"}},"required":["channel","count"]}},"by_channel":{"type":"array","items":{"type":"object","properties":{"channel":{"$ref":"#/components/schemas/Channel"},"leads":{"type":"integer","description":"Contactos creados en el periodo con este canal de origen"},"new_deals":{"type":"integer","description":"Negocios del pipeline creados en el periodo"},"won_count":{"type":"integer"},"won_amount":{"type":"integer","description":"Unidades menores en la moneda del workspace"}},"required":["channel","leads","new_deals","won_count","won_amount"]},"description":"Rendimiento por canal de adquisición (primer contacto); ordenado por ingresos"},"activity_mix":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["note","email","call","meeting"]},"count":{"type":"integer"}},"required":["type","count"]}}},"required":["currency","from","to","pipeline","other_currency_deals","converted_deals","fx_date","totals","funnel","open_by_stage","monthly","forecast","by_owner","lost_reasons","lead_sources","by_channel","activity_mix"]},"NotificationList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Notification"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"},"unread":{"type":"integer","description":"No leídas en este workspace"}},"required":["data","next_cursor","unread"]},"Notification":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"type":{"type":"string","enum":["lead.received","task.assigned","deal.assigned","record.assigned","deal.won","webhook.disabled","leads.repeated","lead.sla_missed","lead.sla_escalated","deal.at_risk","invitation.accepted","invitation.expired","commission.earned","visitor.arrived"]},"payload":{"$ref":"#/components/schemas/NotificationPayload"},"read_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","type","payload","read_at","created_at"]},"NotificationPayload":{"type":"object","properties":{"actor":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"deal":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"amount":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"}},"required":["id","title","amount","currency"]},"task":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"due_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","title","due_at"]},"webhook":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"url":{"type":"string"}},"required":["id","url"]},"channel":{"$ref":"#/components/schemas/Channel"},"repeats":{"type":"object","properties":{"source":{"type":"string"},"count":{"type":"integer"},"hours":{"type":"integer"}},"required":["source","count","hours"],"description":"`leads.repeated`: reenvíos ignorados de un origen en las últimas `hours` horas"},"sla":{"type":"object","properties":{"minutes":{"type":"integer"},"waited":{"type":"integer"},"reassigned_to":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}},"required":["minutes","waited","reassigned_to"],"description":"`lead.sla_*`: SLA en minutos, minutos esperando y a quién se reasignó"},"rot":{"type":"object","properties":{"idle_days":{"type":"integer"},"at_risk_days":{"type":"integer"},"stage":{"type":"string"}},"required":["idle_days","at_risk_days","stage"],"description":"`deal.at_risk`: días sin actividad, umbral «En riesgo» del pipeline y etapa actual"},"invitation":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"email":{"type":"string"},"role":{"type":"string"}},"required":["id","email","role"],"description":"`invitation.*`: a quién se invitó y con qué rol (en `accepted`, `actor` es quien se unió)"},"commission":{"type":"object","properties":{"amount":{"type":"integer"},"base_amount":{"type":"integer"},"rate_bp":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"}},"required":["amount","base_amount","rate_bp","currency"],"description":"`commission.earned`: comisión, cobro sobre el que se calcula y % aplicado"},"record":{"type":"object","properties":{"type":{"type":"string","enum":["contact","company","deal"]},"id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":["string","null"]},"count":{"type":"integer"}},"required":["type","id","name","count"],"description":"`record.assigned`: qué se asignó; con `count` > 1 (acción masiva) `id` y `name` son null"},"visitor":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"page":{"type":["string","null"]},"title":{"type":["string","null"]},"referrer":{"type":["string","null"]},"returning":{"type":"boolean"}},"required":["id","name","page","title","referrer","returning"],"description":"`visitor.arrived`: quién llegó a la web (con `contact` si es un contacto conocido), en qué página y si ya había venido"}}},"NotificationsUnread":{"type":"object","properties":{"unread":{"type":"integer"}},"required":["unread"]},"NotificationsRead":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"maxItems":100},"all":{"type":"boolean","description":"Marca todas como leídas"}}},"NotificationSettings":{"type":"object","properties":{"channels":{"type":"object","properties":{"lead.received":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"task.assigned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"deal.assigned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"record.assigned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"deal.won":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"webhook.disabled":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"leads.repeated":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"lead.sla_missed":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"lead.sla_escalated":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"deal.at_risk":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"invitation.accepted":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"invitation.expired":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"commission.earned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]},"visitor.arrived":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}},"required":["in_app","email","push"]}},"description":"Por tipo: aviso in-app, email y/o push"},"weekly_report":{"type":"boolean","description":"Informe semanal por email (lunes por la mañana, zona del workspace)"},"email_available":{"type":"boolean","description":"false si el servidor no tiene SMTP configurado"},"push_available":{"type":"boolean","description":"false si el servidor no tiene Firebase Cloud Messaging configurado"}},"required":["channels","weekly_report","email_available","push_available"]},"NotificationSettingsUpdate":{"type":"object","properties":{"channels":{"type":"object","properties":{"lead.received":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"task.assigned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"deal.assigned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"record.assigned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"deal.won":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"webhook.disabled":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"leads.repeated":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"lead.sla_missed":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"lead.sla_escalated":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"deal.at_risk":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"invitation.accepted":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"invitation.expired":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"commission.earned":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}},"visitor.arrived":{"type":"object","properties":{"in_app":{"type":"boolean"},"email":{"type":"boolean"},"push":{"type":"boolean"}}}}},"weekly_report":{"type":"boolean"}}},"AuditPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AuditEntry"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AuditEntry":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"action":{"type":"string","enum":["workspace.created","workspace.updated","workspace.exported","member.joined","member.updated","member.removed","invitation.created","invitation.resent","invitation.revoked","api_key.created","api_key.updated","api_key.rotated","api_key.revoked","webhook.created","webhook.updated","webhook.deleted","webhook.secret_rotated","contact.deleted","company.deleted","deal.deleted","contacts.imported","companies.imported","deals.imported","contacts.phones_completed","ad_connection.updated","ad_connection.deleted","organization.updated","organization.suspended","organization.reactivated","organization.deleted","org_member.added","org_member.updated","org_member.removed","workspace.deleted","user.created","user.updated","user.deleted","user.password_set","user.password_reset_sent","user.sessions_revoked","user.suspended","user.reactivated","user.two_factor_reset","user.platform_role_changed","user.impersonation_started","user.impersonation_ended","billing.subscription_updated","billing.payment_failed","billing.payment_succeeded","billing.payment_action_required","billing.dispute_opened","billing.plan_changed","billing.subscription_resumed","billing.details_updated","billing.duplicate_canceled","billing.extras_changed","plan.created","plan.updated","plan.renamed","plan.stripe_synced","plan.deleted","pipeline.created","pipeline.updated","pipeline.deleted","stage.created","stage.updated","stage.deleted","stages.reordered","custom_field.created","custom_field.updated","custom_field.deleted","tag.created","tag.updated","tag.deleted","product.created","product.updated","product.deleted","contacts.merged","records.bulk_updated","records.bulk_deleted","inbound.created","inbound.updated","inbound.deleted","contact_request.updated","platform.maintenance_on","platform.maintenance_off","platform.testimonial_created","platform.testimonial_updated","platform.testimonial_deleted","platform.config_updated","platform.config_reset","platform.cdn_purged","platform.branding_updated","platform.data_reset","platform.mail_template_updated","platform.mail_template_reset","platform.mail_template_fallback","automation_rule.created","automation_rule.updated","automation_rule.deleted","scoring_rule.created","scoring_rule.updated","scoring_rule.deleted","template.created","template.updated","template.deleted","form.created","form.updated","form.deleted","landing.created","landing.updated","landing.deleted","platform.landing_saved","platform.landing_deleted","platform.landing_blocked","platform.landing_unblocked","inbox_channel.created","inbox_channel.updated","inbox_channel.deleted","calendar_feed.rotated","workspace_template.created","workspace_template.deleted","portal_share.created","portal_share.revoked","member.account_created","commissions.paid","commissions.exported","commission.voided","commission.restored","customer_payment.updated","assistant.updated","assistant.key_set","assistant.key_removed","assistant.document_added","assistant.document_deleted"]},"actor":{"type":"object","properties":{"type":{"type":"string","enum":["user","api_key","platform","system"]},"id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"label":{"type":["string","null"]}},"required":["type","id","label"]},"target":{"type":"object","properties":{"type":{"type":["string","null"]},"id":{"type":["string","null"]},"label":{"type":["string","null"]}},"required":["type","id","label"]},"changes":{"type":["object","null"],"additionalProperties":{}},"ip":{"type":["string","null"]},"workspace":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"organization":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","action","actor","target","changes","ip","workspace","organization","created_at"]},"PlatformOverview":{"type":"object","properties":{"business":{"type":"object","properties":{"mrr":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]},"description":"Ingreso mensual recurrente estimado (suscripciones activas o en impago × precio del plan; anual / 12)"},"paying":{"type":"integer"},"trialing":{"type":"integer"},"trials_ending_7d":{"type":"integer"},"past_due":{"type":"integer"},"canceled_30d":{"type":"integer"},"trial_conversion_90d":{"type":["number","null"],"description":"Agencias creadas hace 30–120 días que hoy pagan (0–1); null sin base"}},"required":["mrr","paying","trialing","trials_ending_7d","past_due","canceled_30d","trial_conversion_90d"]},"usage":{"type":"object","properties":{"dau":{"type":"integer"},"wau":{"type":"integer"},"mau":{"type":"integer"},"active_orgs_7d":{"type":"integer","description":"Agencias con algún miembro que entró en 7 días"},"leads_prev_30d":{"type":"integer"},"signups_orgs_30d":{"type":"integer"},"signups_orgs_prev_30d":{"type":"integer"},"deals_won_30d":{"type":"integer"},"won_value_30d":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}},"messages_30d":{"type":"integer"}},"required":["dau","wau","mau","active_orgs_7d","leads_prev_30d","signups_orgs_30d","signups_orgs_prev_30d","deals_won_30d","won_value_30d","messages_30d"]},"lead_channels":{"type":"array","items":{"type":"object","properties":{"channel":{"type":"string"},"count":{"type":"integer"}},"required":["channel","count"]},"description":"Leads de los últimos 30 días por canal, en todas las agencias"},"adoption":{"type":"object","properties":{"base":{"type":"integer","description":"Agencias no suspendidas"},"features":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["lead_source","team","ads","inbox","automations","webhooks"]},"orgs":{"type":"integer"}},"required":["key","orgs"]}}},"required":["base","features"]},"attention":{"type":"array","items":{"type":"object","properties":{"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"plan":{"type":"string"}},"required":["id","name","slug","plan"]},"reasons":{"type":"array","items":{"type":"string","enum":["past_due","trial_ending","trial_expired","inactive","no_leads","webhooks_failing"]}},"trial_ends_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_active_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["org","reasons","trial_ends_at","last_active_at"]}},"totals":{"type":"object","properties":{"organizations":{"type":"integer"},"suspended_organizations":{"type":"integer"},"workspaces":{"type":"integer"},"users":{"type":"integer"},"active_users_7d":{"type":"integer","description":"Usuarios con sesión renovada en los últimos 7 días"},"contacts":{"type":"integer"},"deals":{"type":"integer"},"leads_30d":{"type":"integer"}},"required":["organizations","suspended_organizations","workspaces","users","active_users_7d","contacts","deals","leads_30d"]},"signups":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string","format":"date","example":"2026-11-30"},"organizations":{"type":"integer"},"users":{"type":"integer"},"leads":{"type":"integer"}},"required":["date","organizations","users","leads"]},"description":"Altas y leads diarios de los últimos 30 días (UTC)"},"plans":{"type":"array","items":{"type":"object","properties":{"plan":{"type":"string"},"count":{"type":"integer"}},"required":["plan","count"]}},"top_organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"plan":{"type":"string"},"contacts":{"type":"integer"},"deals":{"type":"integer"},"members":{"type":"integer"}},"required":["id","name","slug","plan","contacts","deals","members"]}},"recent_audit":{"type":"array","items":{"$ref":"#/components/schemas/AuditEntry"}},"demos":{"type":"object","properties":{"active":{"type":"integer"},"created_7d":{"type":"integer","description":"Demos abiertas en los últimos 7 días (del historial, que sobrevive al borrado)"},"converted_7d":{"type":"integer","description":"De esas, cuántas acabaron en una cuenta real creada desde el mismo navegador"}},"required":["active","created_7d","converted_7d"],"description":"Demos públicas. Viven aparte: no cuentan en ninguna otra cifra de la consola y se borran solas al caducar."}},"required":["business","usage","lead_channels","adoption","attention","totals","signups","plans","top_organizations","recent_audit","demos"]},"AdminWorkspacePage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AdminWorkspace"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AdminWorkspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"avatar":{"$ref":"#/components/schemas/WorkspaceAvatar"},"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"plan":{"type":"string"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"members":{"type":"integer"},"contacts":{"type":"integer"},"open_deals":{"type":"integer"},"leads_30d":{"type":"integer"},"last_activity_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","slug","avatar","org","plan","currency","members","contacts","open_deals","leads_30d","last_activity_at","created_at"]},"AdminContactPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AdminContact"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AdminContact":{"type":"object","properties":{"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"source":{"type":["string","null"]},"channel":{"type":["string","null"]},"lifecycle_stage":{"type":"string"},"score":{"type":["integer","null"]},"owner":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_activity_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["workspace","org","id","name","email","phone","source","channel","lifecycle_stage","score","owner","created_at","last_activity_at"]},"AdminDealPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AdminDeal"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AdminDeal":{"type":"object","properties":{"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"amount":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"status":{"type":"string","enum":["open","won","lost"]},"stage":{"type":"string"},"owner":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"closed_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["workspace","org","id","title","amount","currency","status","stage","owner","contact","created_at","closed_at"]},"AdminOrgPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AdminOrg"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AdminOrg":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"plan":{"type":"string"},"trial_ends_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"suspended_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"suspended_reason":{"type":["string","null"]},"suspension_source":{"type":["string","null"],"enum":["platform","billing",null]},"billing_status":{"type":"string","enum":["none","trialing","active","past_due","unpaid","canceled"]},"owner":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"}},"required":["id","name","email"]},"members":{"type":"integer"},"workspaces":{"type":"integer"},"contacts":{"type":"integer"},"deals":{"type":"integer"},"leads_30d":{"type":"integer"},"last_active_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Última vez que entró algún miembro"},"mrr":{"type":["object","null"],"properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"],"description":"Cuota mensual estimada si paga"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","slug","plan","trial_ends_at","suspended_at","suspended_reason","suspension_source","billing_status","owner","members","workspaces","contacts","deals","leads_30d","last_active_at","mrr","created_at"]},"AdminOrgDetail":{"allOf":[{"$ref":"#/components/schemas/AdminOrg"},{"type":"object","properties":{"workspaces_list":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"avatar":{"$ref":"#/components/schemas/WorkspaceAvatar"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"locale":{"type":"string"},"timezone":{"type":"string"},"stale_deal_days":{"type":["integer","null"]},"members":{"type":"integer"},"contacts":{"type":"integer"},"open_deals":{"type":"integer"},"won_deals":{"type":"integer"},"last_activity_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","slug","avatar","currency","locale","timezone","stale_deal_days","members","contacts","open_deals","won_deals","last_activity_at","created_at"]}},"members_list":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"},"avatar_url":{"type":["string","null"]},"role":{"type":"string","enum":["owner","admin","member"]},"last_seen_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"suspended":{"type":"boolean"}},"required":["id","name","email","avatar_url","role","last_seen_at","suspended"]}},"webhooks":{"type":"object","properties":{"endpoints":{"type":"integer"},"paused":{"type":"integer"},"failed_24h":{"type":"integer"}},"required":["endpoints","paused","failed_24h"]},"billing":{"type":"object","properties":{"customer_id":{"type":["string","null"]},"subscription_id":{"type":["string","null"]},"period_end":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"past_due_since":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"grace_ends_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["customer_id","subscription_id","period_end","past_due_since","grace_ends_at"]},"usage":{"$ref":"#/components/schemas/PlanUsage"},"extras":{"type":"object","properties":{"users":{"type":"integer"},"workspaces":{"type":"integer"},"contact_packs":{"type":"integer"}},"required":["users","workspaces","contact_packs"],"description":"Extras que paga en su suscripción"},"bonus":{"type":"object","properties":{"users":{"type":"integer"},"workspaces":{"type":"integer"},"contacts":{"type":"integer"}},"required":["users","workspaces","contacts"],"description":"Capacidad regalada por la plataforma"},"activation":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["first_contact","lead_source","ads_connected","inbox_connected","deal_moved","deal_won","teammate"]},"at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["key","at"]}},"leads_daily":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string","format":"date","example":"2026-11-30"},"count":{"type":"integer"}},"required":["date","count"]},"description":"Leads diarios de los últimos 30 días (UTC)"},"lead_channels":{"type":"array","items":{"type":"object","properties":{"channel":{"type":"string"},"count":{"type":"integer"}},"required":["channel","count"]}},"activity_30d":{"type":"object","properties":{"messages":{"type":"integer"},"deals_won":{"type":"integer"},"tasks_done":{"type":"integer"},"automation_runs":{"type":"integer"}},"required":["messages","deals_won","tasks_done","automation_runs"]},"audit":{"type":"array","items":{"$ref":"#/components/schemas/AuditEntry"}}},"required":["workspaces_list","members_list","webhooks","billing","usage","extras","bonus","activation","leads_daily","lead_channels","activity_30d","audit"]}]},"PlanUsage":{"type":"object","properties":{"workspaces":{"type":"object","properties":{"used":{"type":"integer"},"max":{"type":["integer","null"]}},"required":["used","max"]},"users":{"type":"object","properties":{"used":{"type":"integer"},"max":{"type":["integer","null"]}},"required":["used","max"]},"contacts":{"type":"object","properties":{"used":{"type":"integer"},"max":{"type":["integer","null"]}},"required":["used","max"]}},"required":["workspaces","users","contacts"],"description":"Consumo de la agencia frente a los límites de su plan"},"AdminOrgUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"slug":{"type":"string","minLength":2,"maxLength":60,"pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$"},"plan":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"trial_ends_at":{"type":["string","null"],"format":"date","example":"2026-11-30"},"suspended":{"type":"boolean"},"suspended_reason":{"type":["string","null"],"maxLength":300},"bonus_users":{"type":"integer","minimum":0,"maximum":10000,"description":"Usuarios regalados sobre el plan (sin cobro)"},"bonus_workspaces":{"type":"integer","minimum":0,"maximum":10000},"bonus_contacts":{"type":"integer","minimum":0,"maximum":10000000}}},"AdminUserPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AdminUser"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AdminUser":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"},"avatar_url":{"type":["string","null"]},"platform_admin":{"type":"boolean"},"bootstrap_admin":{"type":"boolean"},"two_factor_enabled":{"type":"boolean"},"suspended_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_seen_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"active_sessions":{"type":"integer"},"organizations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"role":{"type":"string","enum":["owner","admin","member"]}},"required":["id","name","role"]}},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","email","avatar_url","platform_admin","bootstrap_admin","two_factor_enabled","suspended_at","last_seen_at","active_sessions","organizations","created_at"]},"AdminUserDetail":{"allOf":[{"$ref":"#/components/schemas/AdminUser"},{"type":"object","properties":{"email_verified":{"type":"boolean"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"timezone":{"type":"string"},"has_password":{"type":"boolean"},"login_methods":{"type":"array","items":{"type":"string"}},"memberships":{"type":"array","items":{"type":"object","properties":{"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"role":{"type":"string","enum":["owner","admin","member"]},"workspaces":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"role":{"type":["string","null"],"enum":["admin","manager","sales","viewer",null]},"visibility":{"type":["string","null"],"enum":["all","own",null]}},"required":["id","name","slug","role","visibility"]}}},"required":["org","role","workspaces"]}},"sessions_list":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"ip":{"type":["string","null"]},"user_agent":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_active_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","ip","user_agent","created_at","last_active_at","expires_at"]}},"audit":{"type":"array","items":{"$ref":"#/components/schemas/AuditEntry"}}},"required":["email_verified","locale","timezone","has_password","login_methods","memberships","sessions_list","audit"]}]},"AdminUserCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"email":{"type":"string","maxLength":320,"format":"email"},"password":{"type":"string","minLength":10,"maxLength":128},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"],"default":"es"},"timezone":{"type":"string","minLength":1,"maxLength":64,"default":"UTC"},"platform_admin":{"type":"boolean","default":false},"workspace_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"workspace_role":{"type":"string","enum":["admin","manager","sales","viewer"],"default":"sales"}},"required":["name","email"]},"AdminUserUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"email":{"type":"string","maxLength":320,"format":"email"},"email_verified":{"type":"boolean"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"timezone":{"type":"string","minLength":1,"maxLength":64},"platform_admin":{"type":"boolean"},"suspended":{"type":"boolean"},"two_factor_enabled":{"type":"boolean","enum":[false]}}},"AdminUserPassword":{"type":"object","properties":{"password":{"type":"string","minLength":10,"maxLength":128}},"required":["password"]},"PasswordResetSent":{"type":"object","properties":{"email":{"type":"string"}},"required":["email"]},"AdminOrgMembershipInput":{"type":"object","properties":{"role":{"type":"string","enum":["owner","admin","member"]}},"required":["role"]},"AdminWorkspaceMembershipInput":{"type":"object","properties":{"role":{"type":"string","enum":["admin","manager","sales","viewer"]},"visibility":{"type":"string","enum":["all","own"]}},"required":["role"]},"AdminWorkspaceUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"slug":{"type":"string","minLength":2,"maxLength":60,"pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"timezone":{"type":"string","minLength":1,"maxLength":64},"stale_deal_days":{"type":"integer","minimum":1,"maximum":365}}},"ImpersonationStarted":{"type":"object","properties":{"expires_at":{"type":"string"}},"required":["expires_at"]},"SystemHealth":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded"]},"version":{"type":"string"},"uptime_s":{"type":"integer"},"runtime":{"type":"object","properties":{"node":{"type":"string"},"memory_mb":{"type":"integer"},"platform":{"type":"string"}},"required":["node","memory_mb","platform"]},"database":{"type":"object","properties":{"kind":{"type":"string"},"latency_ms":{"type":"number"},"version":{"type":["string","null"]},"size_mb":{"type":["number","null"]}},"required":["kind","latency_ms","version","size_mb"]},"outbox":{"type":"object","properties":{"pending":{"type":"integer"},"oldest_pending_s":{"type":["integer","null"]}},"required":["pending","oldest_pending_s"]},"webhooks":{"type":"object","properties":{"endpoints":{"type":"integer"},"paused":{"type":"integer"},"succeeded_24h":{"type":"integer"},"failed_24h":{"type":"integer"},"pending":{"type":"integer"},"failing":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"url":{"type":"string"},"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"consecutive_failures":{"type":"integer"},"disabled_reason":{"type":["string","null"]},"last_error":{"type":["string","null"]}},"required":["id","url","workspace","consecutive_failures","disabled_reason","last_error"]}}},"required":["endpoints","paused","succeeded_24h","failed_24h","pending","failing"]},"services":{"type":"object","properties":{"worker":{"type":"boolean"},"rate_limit":{"type":"boolean"},"rate_limit_store":{"type":"string","enum":["memory","redis"]},"smtp":{"type":"boolean"}},"required":["worker","rate_limit","rate_limit_store","smtp"]},"workers":{"type":"array","items":{"type":"object","properties":{"mode":{"type":"string","enum":["api","standalone"]},"host":{"type":"string"},"version":{"type":"string"},"started_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"beat_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"alive":{"type":"boolean"}},"required":["mode","host","version","started_at","beat_at","alive"]}},"checks":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"ok":{"type":"boolean"}},"required":["key","ok"]}}},"required":["status","version","uptime_s","runtime","database","outbox","webhooks","services","workers","checks"]},"BackupStatus":{"type":"object","properties":{"configured":{"type":"boolean"},"checked_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"stale":{"type":"boolean"},"stale_after_hours":{"type":"integer"},"schedule":{"type":"object","properties":{"hour_utc":{"type":["integer","null"]},"verify_weekday":{"type":["integer","null"]},"retention_days":{"type":["integer","null"]}},"required":["hour_utc","verify_weekday","retention_days"]},"offsite":{"type":"object","properties":{"enabled":{"type":"boolean"},"bucket":{"type":["string","null"]},"prefix":{"type":["string","null"]},"retention_days":{"type":["integer","null"]},"reachable":{"type":["boolean","null"]}},"required":["enabled","bucket","prefix","retention_days","reachable"]},"last_backup":{"type":["object","null"],"properties":{"name":{"type":"string"},"size_bytes":{"type":"integer"},"modified_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"offsite":{"type":"string","enum":["ok","missing","unknown","disabled"]}},"required":["name","size_bytes","modified_at","offsite"]},"last_attempt":{"type":["object","null"],"properties":{"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"ok":{"type":"boolean"},"stage":{"type":["string","null"]}},"required":["at","ok","stage"]},"restore_check":{"type":["object","null"],"properties":{"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"ok":{"type":"boolean"},"file":{"type":["string","null"]},"source":{"type":["string","null"],"enum":["local","offsite",null]},"organizations":{"type":["integer","null"]},"users":{"type":["integer","null"]}},"required":["at","ok","file","source","organizations","users"]},"local":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"size_bytes":{"type":"integer"},"modified_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["name","size_bytes","modified_at"]}},"remote":{"type":["array","null"],"items":{"type":"object","properties":{"name":{"type":"string"},"size_bytes":{"type":"integer"},"modified_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["name","size_bytes","modified_at"]}}},"required":["configured","checked_at","stale","stale_after_hours","schedule","offsite","last_backup","last_attempt","restore_check","local","remote"]},"WebVitalsSummary":{"type":"object","properties":{"days":{"type":"integer"},"metrics":{"type":"object","properties":{"LCP":{"type":"object","properties":{"p75":{"type":["number","null"]},"samples":{"type":"integer"},"good":{"type":["number","null"]}},"required":["p75","samples","good"]},"INP":{"type":"object","properties":{"p75":{"type":["number","null"]},"samples":{"type":"integer"},"good":{"type":["number","null"]}},"required":["p75","samples","good"]},"CLS":{"type":"object","properties":{"p75":{"type":["number","null"]},"samples":{"type":"integer"},"good":{"type":["number","null"]}},"required":["p75","samples","good"]},"FCP":{"type":"object","properties":{"p75":{"type":["number","null"]},"samples":{"type":"integer"},"good":{"type":["number","null"]}},"required":["p75","samples","good"]},"TTFB":{"type":"object","properties":{"p75":{"type":["number","null"]},"samples":{"type":"integer"},"good":{"type":["number","null"]}},"required":["p75","samples","good"]}}},"pages":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"samples":{"type":"integer"},"lcp_p75":{"type":["number","null"]},"inp_p75":{"type":["number","null"]},"cls_p75":{"type":["number","null"]}},"required":["path","samples","lcp_p75","inp_p75","cls_p75"]}},"devices":{"type":"object","properties":{"mobile":{"type":"integer"},"desktop":{"type":"integer"}},"required":["mobile","desktop"]}},"required":["days","metrics","pages","devices"]},"WebVitalsReport":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"name":{"$ref":"#/components/schemas/WebVitalName"},"value":{"type":"number","minimum":0,"maximum":600000},"rating":{"type":"string","enum":["good","needs-improvement","poor"]},"path":{"type":"string","minLength":1,"maxLength":160,"pattern":"^\\/[^?#\\s]*$"}},"required":["name","value","rating","path"]},"minItems":1,"maxItems":10},"device":{"type":"string","enum":["mobile","desktop"]},"version":{"type":"string","maxLength":32}},"required":["items","device"]},"WebVitalName":{"type":"string","enum":["LCP","INP","CLS","FCP","TTFB"]},"PlatformResetPreview":{"type":"object","properties":{"phrase":{"type":"string","description":"Texto que hay que escribir para confirmar"},"counts":{"type":"object","properties":{"organizations":{"type":"integer"},"workspaces":{"type":"integer"},"contacts":{"type":"integer"},"deals":{"type":"integer"},"conversations":{"type":"integer"},"payments":{"type":"integer"},"contact_requests":{"type":"integer"},"audit_logs":{"type":"integer"},"users":{"type":"integer","description":"Cuentas de usuario totales"},"removable_users":{"type":"integer","description":"Cuentas que se borrarían con include_users (no admins de plataforma ni el operador)"}},"required":["organizations","workspaces","contacts","deals","conversations","payments","contact_requests","audit_logs","users","removable_users"]},"live_subscriptions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"description":"Agencias con suscripción viva en Stripe o PayPal: seguirán cobrando hasta cancelarlas allí"}},"required":["phrase","counts","live_subscriptions"]},"PlatformResetResult":{"type":"object","properties":{"deleted":{"type":"object","properties":{"organizations":{"type":"integer"},"workspaces":{"type":"integer"},"contacts":{"type":"integer"},"deals":{"type":"integer"},"contact_requests":{"type":"integer"},"audit_logs":{"type":"integer"},"users":{"type":"integer"}},"required":["organizations","workspaces","contacts","deals","contact_requests","audit_logs","users"]},"kept_users":{"type":"integer"}},"required":["deleted","kept_users"]},"PlatformResetInput":{"type":"object","properties":{"confirm":{"type":"string","maxLength":40},"password":{"type":"string","minLength":1,"maxLength":200,"description":"Contraseña actual del operador"},"include_contact_requests":{"type":"boolean","default":true},"include_audit":{"type":"boolean","default":true},"include_users":{"type":"boolean","default":false,"description":"Borrar también las cuentas que no son admin de plataforma"},"acknowledge_subscriptions":{"type":"boolean","default":false,"description":"Obligatorio si hay suscripciones vivas"}},"required":["confirm","password"]},"Maintenance":{"type":"object","properties":{"enabled":{"type":"boolean"},"message":{"type":["string","null"]},"until":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}},"required":["enabled","message","until","updated_at","updated_by"]},"MaintenanceUpdate":{"type":"object","properties":{"enabled":{"type":"boolean"},"message":{"type":["string","null"],"maxLength":500},"until":{"type":["string","null"],"format":"date-time"}},"required":["enabled"]},"Testimonial":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"quote":{"type":"string"},"author_name":{"type":"string"},"author_role":{"type":["string","null"]},"company":{"type":"string"},"company_url":{"type":["string","null"]},"org":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"locale":{"type":["string","null"],"enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa",null]},"logo_url":{"type":["string","null"]},"consent_note":{"type":"string"},"published":{"type":"boolean"},"sort":{"type":"integer"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","quote","author_name","author_role","company","company_url","org","locale","logo_url","consent_note","published","sort","created_at","updated_at"]},"TestimonialInput":{"type":"object","properties":{"quote":{"type":"string","minLength":10,"maxLength":400},"author_name":{"type":"string","minLength":2,"maxLength":80},"author_role":{"type":["string","null"],"maxLength":80},"company":{"type":"string","minLength":2,"maxLength":80},"company_url":{"type":["string","null"],"maxLength":300},"org_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"locale":{"type":["string","null"],"enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa",null]},"consent_note":{"type":"string","minLength":5,"maxLength":300},"published":{"type":"boolean","default":false},"sort":{"type":"integer","minimum":0,"maximum":999,"default":0},"logo":{"type":["string","null"],"maxLength":300000}},"required":["quote","author_name","company","consent_note"]},"PublicTestimonial":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"quote":{"type":"string"},"author_name":{"type":"string"},"author_role":{"type":["string","null"]},"company":{"type":"string"},"company_url":{"type":["string","null"]},"locale":{"type":["string","null"],"enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa",null]},"logo_url":{"type":["string","null"]}},"required":["id","quote","author_name","author_role","company","company_url","locale","logo_url"]},"PlatformConfig":{"type":"object","properties":{"sections":{"type":"array","items":{"$ref":"#/components/schemas/PlatformConfigSection"}},"urls":{"type":"object","properties":{"stripe_webhook":{"type":"string"},"paypal_webhook":{"type":"string"},"inbox_google_redirect":{"type":"string"},"inbox_microsoft_redirect":{"type":"string"},"meta_oauth_redirect":{"type":"string"},"meta_webhook":{"type":"string"},"meta_verify_token":{"type":"string"},"social_google_redirect":{"type":"string"},"social_microsoft_redirect":{"type":"string"},"social_facebook_redirect":{"type":"string"},"cdn_origin":{"type":"string"},"captcha_hostname":{"type":"string"}},"required":["stripe_webhook","paypal_webhook","inbox_google_redirect","inbox_microsoft_redirect","meta_oauth_redirect","meta_webhook","meta_verify_token","social_google_redirect","social_microsoft_redirect","social_facebook_redirect","cdn_origin","captcha_hostname"]}},"required":["sections","urls"]},"PlatformConfigSection":{"type":"object","properties":{"id":{"type":"string","enum":["email","push","stripe","paypal","google_ads","inbox_oauth","meta_messaging","social_login","cdn","captcha"]},"source":{"type":"string","enum":["console","env","none"]},"configured":{"type":"boolean"},"values":{"type":"object","additionalProperties":{"type":["string","null"]}},"secrets":{"type":"object","additionalProperties":{"type":"object","properties":{"set":{"type":"boolean"},"hint":{"type":["string","null"]}},"required":["set","hint"]}},"env_available":{"type":"boolean"},"updated_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}},"required":["id","source","configured","values","secrets","env_available","updated_at","updated_by"]},"PlatformConfigUpdate":{"type":"object","properties":{"values":{"type":"object","additionalProperties":{"type":["string","null"],"maxLength":2000},"default":{}},"secrets":{"type":"object","additionalProperties":{"type":["string","null"],"maxLength":20000},"default":{}}}},"PlatformConfigTestResult":{"type":"object","properties":{"ok":{"type":"boolean"},"code":{"type":"string","enum":["sent","valid","not_configured","auth_failed","connection_failed","invalid_config","no_refresh_token","not_cloudflare","purged","no_purge_keys"]},"detail":{"type":["string","null"]}},"required":["ok","code","detail"]},"PlatformConfigTest":{"type":"object","properties":{"to":{"type":"string","maxLength":320,"format":"email"}}},"MailTemplateList":{"type":"object","properties":{"templates":{"type":"array","items":{"$ref":"#/components/schemas/MailTemplateSummary"}},"senders":{"type":"object","properties":{"account":{"type":["string","null"]},"notifications":{"type":["string","null"]},"support":{"type":["string","null"]},"billing":{"type":["string","null"]},"updates":{"type":["string","null"]}}}},"required":["templates","senders"]},"MailTemplateSummary":{"type":"object","properties":{"key":{"type":"string"},"category":{"type":"string","enum":["account","notifications","support","billing","updates"]},"edited":{"type":"array","items":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]}},"fallbacks":{"type":"array","items":{"$ref":"#/components/schemas/MailTemplateFallback"}}},"required":["key","category","edited","fallbacks"]},"MailTemplateFallback":{"type":"object","properties":{"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"at":{"type":"string"},"missing":{"type":"array","items":{"type":"string"}},"count":{"type":"integer"}},"required":["locale","at","missing","count"]},"MailTemplateDetail":{"type":"object","properties":{"key":{"type":"string"},"category":{"type":"string","enum":["account","notifications","support","billing","updates"]},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"fields":{"type":"array","items":{"type":"string","enum":["subject","preheader","heading","paragraphs","cta","secondary_text","secondary_label","footnote"]}},"vars":{"type":"array","items":{"type":"string"}},"optional":{"type":"array","items":{"type":"string"}},"defaults":{"$ref":"#/components/schemas/MailTemplateTexts"},"saved":{"allOf":[{"$ref":"#/components/schemas/MailTemplateTexts"},{"type":["object","null"]}]},"preview":{"$ref":"#/components/schemas/MailTemplatePreview"},"history":{"type":"array","items":{"$ref":"#/components/schemas/MailTemplateVersion"}},"fallback":{"allOf":[{"$ref":"#/components/schemas/MailTemplateFallback"},{"type":["object","null"]}]}},"required":["key","category","locale","fields","vars","optional","defaults","saved","preview","history","fallback"]},"MailTemplateTexts":{"type":"object","properties":{"subject":{"type":"string","maxLength":2000},"preheader":{"type":"string","maxLength":2000},"heading":{"type":"string","maxLength":2000},"paragraphs":{"type":"array","items":{"type":"string","maxLength":4000},"maxItems":20},"cta":{"type":"string","maxLength":2000},"secondary_text":{"type":"string","maxLength":2000},"secondary_label":{"type":"string","maxLength":2000},"footnote":{"type":"string","maxLength":2000}}},"MailTemplatePreview":{"type":"object","properties":{"subject":{"type":"string"},"html":{"type":"string"},"from":{"type":["string","null"]}},"required":["subject","html","from"]},"MailTemplateVersion":{"type":"object","properties":{"texts":{"$ref":"#/components/schemas/MailTemplateTexts"},"saved_at":{"type":["string","null"]},"saved_by":{"type":["object","null"],"properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"]}},"required":["texts","saved_at","saved_by"]},"MailTemplatePreviewInput":{"type":"object","properties":{"texts":{"$ref":"#/components/schemas/MailTemplateTexts"}},"required":["texts"]},"MailTemplateTestResult":{"type":"object","properties":{"sent":{"type":"boolean"},"to":{"type":"string"}},"required":["sent","to"]},"MailTemplateTestInput":{"type":"object","properties":{"texts":{"$ref":"#/components/schemas/MailTemplateTexts"},"to":{"type":"string","maxLength":320,"format":"email"}}},"PublicStatus":{"type":"object","properties":{"version":{"type":"string"},"maintenance":{"type":"object","properties":{"enabled":{"type":"boolean"},"message":{"type":["string","null"]},"until":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["enabled","message","until"]}},"required":["version","maintenance"]},"PublicGeo":{"type":"object","properties":{"country":{"type":["string","null"],"minLength":2,"maxLength":2,"description":"País ISO 3166-1 alfa-2 de la IP según el CDN/proxy de confianza; null si no se sabe."}},"required":["country"]},"AuthProviders":{"type":"object","properties":{"providers":{"type":"array","items":{"type":"string","enum":["google","microsoft","facebook"]},"description":"Proveedores activos para entrar o registrarse; vacío = solo correo y contraseña"}},"required":["providers"]},"PublicUptime":{"type":"object","properties":{"generated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"components":{"type":"array","items":{"$ref":"#/components/schemas/UptimeComponent"}},"days":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"uptime":{"type":["number","null"],"minimum":0,"maximum":1},"down_minutes":{"type":"integer"}},"required":["date","uptime","down_minutes"]}},"uptime_90d":{"type":["number","null"],"minimum":0,"maximum":1},"since":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["generated_at","components","days","uptime_90d","since"]},"UptimeComponent":{"type":"object","properties":{"key":{"type":"string","enum":["api","database","worker","backups"]},"status":{"type":"string","enum":["operational","degraded","down","unknown"]},"last_success_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["key","status","last_success_at"]},"PublicSubprocessors":{"type":"object","properties":{"stripe":{"type":"boolean"},"paypal":{"type":"boolean"},"push":{"type":"boolean"},"cdn":{"type":"boolean"},"offsite_backups":{"type":"boolean"},"email_domain":{"type":["string","null"]},"social_login":{"type":"array","items":{"type":"string"}},"inbox_oauth":{"type":"boolean"},"google_ads":{"type":"boolean"}},"required":["stripe","paypal","push","cdn","offsite_backups","email_domain","social_login","inbox_oauth","google_ads"]},"Branding":{"type":"object","properties":{"name":{"type":"string"},"tagline":{"type":["string","null"]},"signup_enabled":{"type":"boolean"},"default_locale":{"type":["string","null"],"enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa",null]},"default_theme":{"type":"string","enum":["system","light","dark"]},"logo_light_url":{"type":["string","null"]},"logo_dark_url":{"type":["string","null"]},"favicon_url":{"type":["string","null"]},"company":{"$ref":"#/components/schemas/ServiceOwner"},"currency":{"type":"string","minLength":3,"maxLength":3},"site_chat_token":{"type":["string","null"]}},"required":["name","tagline","signup_enabled","default_locale","default_theme","logo_light_url","logo_dark_url","favicon_url","company","currency","site_chat_token"]},"ServiceOwner":{"type":"object","properties":{"legal_name":{"type":["string","null"]},"tax_id":{"type":["string","null"]},"address":{"type":["string","null"]},"contact_email":{"type":["string","null"]},"privacy_email":{"type":["string","null"]},"province":{"type":["string","null"],"enum":["AB","BC","MB","NB","NL","NS","NT","NU","ON","PE","QC","SK","YT",null]}},"required":["legal_name","tax_id","address","contact_email","privacy_email","province"]},"AdminBranding":{"allOf":[{"$ref":"#/components/schemas/Branding"},{"type":"object","properties":{"site_chat":{"type":["object","null"],"properties":{"workspace":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"widget_enabled":{"type":"boolean"}},"required":["workspace","widget_enabled"]},"updated_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}},"required":["site_chat","updated_at","updated_by"]}]},"BrandingUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":40},"tagline":{"type":["string","null"],"maxLength":160},"signup_enabled":{"type":"boolean"},"default_locale":{"type":["string","null"],"enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa",null]},"default_theme":{"type":"string","enum":["system","light","dark"]},"company":{"$ref":"#/components/schemas/ServiceOwnerUpdate"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"site_chat_workspace":{"type":["string","null"],"maxLength":64}}},"ServiceOwnerUpdate":{"type":"object","properties":{"legal_name":{"type":["string","null"],"maxLength":120},"tax_id":{"type":["string","null"],"maxLength":40},"address":{"type":["string","null"],"maxLength":240},"contact_email":{"anyOf":[{"type":"string","maxLength":254,"format":"email"},{"type":"string","enum":[""]},{"type":"null"}]},"privacy_email":{"anyOf":[{"type":"string","maxLength":254,"format":"email"},{"type":"string","enum":[""]},{"type":"null"}]},"province":{"anyOf":[{"type":"string","enum":["AB","BC","MB","NB","NL","NS","NT","NU","ON","PE","QC","SK","YT"]},{"type":"string","enum":[""]},{"type":"null"}]}}},"BrandAssetUpload":{"type":"object","properties":{"data_url":{"type":"string","maxLength":300000}},"required":["data_url"]},"AdminPaymentSummary":{"type":"object","properties":{"collected":{"type":"object","properties":{"all_time":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}},"last_30d":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}},"prev_30d":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}},"this_month":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}}},"required":["all_time","last_30d","prev_30d","this_month"]},"refunded":{"type":"object","properties":{"all_time":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}},"last_30d":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}}},"required":["all_time","last_30d"]},"net_all_time":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]},"description":"Cobrado − reembolsado"},"counts":{"type":"object","properties":{"succeeded":{"type":"integer"},"failed":{"type":"integer"},"refunds":{"type":"integer"},"succeeded_30d":{"type":"integer"},"failed_30d":{"type":"integer"},"paying_orgs_ever":{"type":"integer","description":"Agencias con al menos un cobro"}},"required":["succeeded","failed","refunds","succeeded_30d","failed_30d","paying_orgs_ever"]},"avg_payment":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]},"description":"Importe medio por cobro, por moneda"},"failure_rate_30d":{"type":["number","null"],"description":"Fallidos / (cobrados + fallidos) en 30 días"},"by_provider":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string","enum":["stripe","paypal"]},"succeeded":{"type":"integer"},"failed":{"type":"integer"},"refunds":{"type":"integer"},"collected":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}}},"required":["provider","succeeded","failed","refunds","collected"]}},"by_plan":{"type":"array","items":{"type":"object","properties":{"plan":{"type":"string"},"payments":{"type":"integer"},"collected":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}}},"required":["plan","payments","collected"]}},"monthly":{"type":"array","items":{"type":"object","properties":{"month":{"type":"string","example":"2026-10"},"succeeded":{"type":"integer"},"failed":{"type":"integer"},"collected":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}},"refunded":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}}},"required":["month","succeeded","failed","collected","refunded"]},"description":"Últimos 12 meses (UTC), del más antiguo al actual"},"subscriptions":{"type":"array","items":{"type":"object","properties":{"plan":{"type":"string"},"total":{"type":"integer"},"trialing":{"type":"integer"},"active":{"type":"integer"},"past_due":{"type":"integer"},"canceled":{"type":"integer"},"none":{"type":"integer"},"stripe":{"type":"integer"},"paypal":{"type":"integer"}},"required":["plan","total","trialing","active","past_due","canceled","none","stripe","paypal"]},"description":"Agencias por plan y estado de suscripción, con la pasarela"},"providers":{"type":"object","properties":{"stripe":{"type":"boolean"},"paypal":{"type":"boolean"}},"required":["stripe","paypal"]}},"required":["collected","refunded","net_all_time","counts","avg_payment","failure_rate_30d","by_provider","by_plan","monthly","subscriptions","providers"]},"AdminPaymentPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AdminPayment"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"AdminPayment":{"allOf":[{"$ref":"#/components/schemas/Payment"},{"type":"object","properties":{"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]}},"required":["org"]}]},"Payment":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"provider":{"type":"string","enum":["stripe","paypal"]},"provider_ref":{"type":"string","description":"Id del cobro en la pasarela (factura de Stripe, venta de PayPal, reembolso)"},"kind":{"type":"string","enum":["charge","refund"]},"status":{"type":"string","enum":["succeeded","failed","refunded","pending"]},"amount":{"type":"integer","description":"Unidades menores; los reembolsos van en positivo con `kind = refund`"},"currency":{"type":"string"},"plan":{"type":["string","null"]},"interval":{"type":["string","null"],"enum":["month","year",null]},"period_start":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"period_end":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"invoice_number":{"type":["string","null"]},"receipt_url":{"type":["string","null"],"description":"Recibo o factura en la pasarela"},"failure_reason":{"type":["string","null"]},"occurred_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","provider","provider_ref","kind","status","amount","currency","plan","interval","period_start","period_end","invoice_number","receipt_url","failure_reason","occurred_at"]},"AdminPlan":{"allOf":[{"$ref":"#/components/schemas/PublicPlan"},{"type":"object","properties":{"stripe_price_id":{"type":["string","null"]},"stripe":{"$ref":"#/components/schemas/StripePriceState"},"price_amount_yearly":{"type":["integer","null"]},"stripe_price_id_yearly":{"type":["string","null"]},"stripe_yearly":{"$ref":"#/components/schemas/StripePriceState"},"paypal_plan_id":{"type":["string","null"]},"paypal_plan_id_yearly":{"type":["string","null"]},"is_trial":{"type":"boolean"},"trial_days":{"type":["integer","null"]},"is_public":{"type":"boolean"},"is_active":{"type":"boolean"},"position":{"type":"integer"},"organizations":{"type":"integer","description":"Agencias con este plan"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["stripe_price_id","stripe","price_amount_yearly","stripe_price_id_yearly","stripe_yearly","paypal_plan_id","paypal_plan_id_yearly","is_trial","trial_days","is_public","is_active","position","organizations","created_at","updated_at"]}]},"LocalizedText":{"type":"object","properties":{"en":{"type":"string","maxLength":400},"es":{"type":"string","maxLength":400},"fr":{"type":"string","maxLength":400},"de":{"type":"string","maxLength":400},"it":{"type":"string","maxLength":400},"pt":{"type":"string","maxLength":400},"nl":{"type":"string","maxLength":400},"pl":{"type":"string","maxLength":400},"tr":{"type":"string","maxLength":400},"ar":{"type":"string","maxLength":400},"fa":{"type":"string","maxLength":400}}},"LocalizedList":{"type":"object","properties":{"en":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"es":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"fr":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"de":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"it":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"pt":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"nl":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"pl":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"tr":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"ar":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8},"fa":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":8}}},"YearlyPrice":{"type":["object","null"],"properties":{"amount":{"type":"integer","description":"Unidades menores por año"},"monthly_equivalent":{"type":"integer","description":"amount / 12, redondeado"},"savings_pct":{"type":"integer","description":"Ahorro frente a pagar 12 meses del precio mensual"}},"required":["amount","monthly_equivalent","savings_pct"]},"PlanLimits":{"type":"object","properties":{"workspaces":{"type":["integer","null"]},"users":{"type":["integer","null"]},"contacts":{"type":["integer","null"]}},"required":["workspaces","users","contacts"],"description":"`null` = ilimitado"},"PlanAddons":{"type":"object","properties":{"user":{"type":["object","null"],"properties":{"amount":{"type":"integer","description":"Unidades menores por unidad y periodo base del plan"},"amount_yearly":{"type":["integer","null"],"description":"Por unidad y año (mismo descuento que el plan anual); `null` si el plan no se vende por año"}},"required":["amount","amount_yearly"],"description":"Cada usuario por encima de los incluidos"},"workspace":{"type":["object","null"],"properties":{"amount":{"type":"integer","description":"Unidades menores por unidad y periodo base del plan"},"amount_yearly":{"type":["integer","null"],"description":"Por unidad y año (mismo descuento que el plan anual); `null` si el plan no se vende por año"}},"required":["amount","amount_yearly"],"description":"Cada espacio adicional"},"contacts_pack":{"type":["object","null"],"properties":{"amount":{"type":"integer","description":"Unidades menores por unidad y periodo base del plan"},"amount_yearly":{"type":["integer","null"],"description":"Por unidad y año (mismo descuento que el plan anual); `null` si el plan no se vende por año"},"size":{"type":"integer","description":"Contactos por paquete"}},"required":["amount","amount_yearly","size"],"description":"Paquetes de contactos adicionales"}},"required":["user","workspace","contacts_pack"],"description":"Extras contratables sobre lo incluido; `null` = no se venden en este plan"},"StripePriceState":{"type":["object","null"],"properties":{"status":{"type":"string","enum":["ok","mismatch","not_found","unchecked"],"description":"`mismatch` = el importe, la moneda o el periodo en Stripe no coinciden con el plan; `unchecked` = Stripe no configurado"},"amount":{"type":["integer","null"]},"currency":{"type":["string","null"]},"interval":{"type":["string","null"]}},"required":["status","amount","currency","interval"]},"PublicPlan":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"name":{"type":"string"},"description":{"$ref":"#/components/schemas/LocalizedText"},"highlights":{"$ref":"#/components/schemas/LocalizedList"},"price":{"type":"object","properties":{"amount":{"type":["integer","null"],"description":"Unidades menores por periodo; `null` = a medida"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"interval":{"type":"string","enum":["month","year"]}},"required":["amount","currency","interval"]},"yearly":{"$ref":"#/components/schemas/YearlyPrice"},"limits":{"$ref":"#/components/schemas/PlanLimits"},"addons":{"$ref":"#/components/schemas/PlanAddons"},"features":{"type":"array","items":{"type":"string","enum":["inbox","automations","scoring","ads_leads","ads_conversions","ads_spend","ads_audiences","client_reports","webhooks","report_exports"]},"description":"Funciones incluidas (además del núcleo CRM)"},"featured":{"type":"boolean"}},"required":["id","name","description","highlights","price","yearly","limits","addons","features","featured"]},"AdminPlanCreate":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"name":{"type":"string","minLength":1,"maxLength":60},"description":{"$ref":"#/components/schemas/LocalizedText"},"highlights":{"$ref":"#/components/schemas/LocalizedList"},"price_amount":{"type":["integer","null"],"minimum":0,"maximum":100000000},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"interval":{"type":"string","enum":["month","year"]},"stripe_price_id":{"type":["string","null"],"pattern":"^price_[A-Za-z0-9]+$"},"price_amount_yearly":{"type":["integer","null"],"minimum":0,"maximum":1000000000},"stripe_price_id_yearly":{"type":["string","null"],"pattern":"^price_[A-Za-z0-9]+$"},"paypal_plan_id":{"type":["string","null"],"pattern":"^P-[A-Z0-9]{10,40}$"},"paypal_plan_id_yearly":{"type":["string","null"],"pattern":"^P-[A-Z0-9]{10,40}$"},"max_workspaces":{"type":["integer","null"],"minimum":1,"maximum":10000000},"max_users":{"type":["integer","null"],"minimum":1,"maximum":10000000},"max_contacts":{"type":["integer","null"],"minimum":1,"maximum":10000000},"price_per_user":{"type":["integer","null"],"minimum":1,"maximum":10000000,"description":"Céntimos por usuario extra y periodo base; `null` = no se venden"},"price_per_workspace":{"type":["integer","null"],"minimum":1,"maximum":10000000},"contacts_pack_size":{"type":["integer","null"],"minimum":100,"maximum":10000000,"description":"Contactos por paquete extra (junto con `price_per_contacts_pack`)"},"price_per_contacts_pack":{"type":["integer","null"],"minimum":1,"maximum":10000000},"features":{"type":["array","null"],"items":{"type":"string","enum":["inbox","automations","scoring","ads_leads","ads_conversions","ads_spend","ads_audiences","client_reports","webhooks","report_exports"]},"maxItems":10,"description":"`null` = todas las funciones"},"trial_days":{"type":["integer","null"],"minimum":1,"maximum":90},"is_public":{"type":"boolean"},"is_featured":{"type":"boolean"},"is_active":{"type":"boolean"},"position":{"type":"integer","minimum":0,"maximum":1000}},"required":["id","name","price_amount","currency","interval","max_workspaces","max_users","max_contacts"]},"PlanStripeSync":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/PlanStripeSyncItem"}}},"required":["items"]},"PlanStripeSyncItem":{"type":"object","properties":{"plan":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"name":{"type":"string"},"status":{"type":"string","enum":["ok","created","skipped","error"],"description":"`created` = se crearon o sustituyeron prices; `skipped` = sin precio fijo (prueba o a medida); `error` = Stripe lo rechazó"},"created":{"type":"integer","description":"Prices nuevos (mensual/base y anual)"},"error":{"type":["string","null"]}},"required":["plan","name","status","created","error"]},"AdminPlanRename":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"}},"required":["id"]},"AdminPlanUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"description":{"$ref":"#/components/schemas/LocalizedText"},"highlights":{"$ref":"#/components/schemas/LocalizedList"},"price_amount":{"type":["integer","null"],"minimum":0,"maximum":100000000},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"interval":{"type":"string","enum":["month","year"]},"stripe_price_id":{"type":["string","null"],"pattern":"^price_[A-Za-z0-9]+$"},"price_amount_yearly":{"type":["integer","null"],"minimum":0,"maximum":1000000000},"stripe_price_id_yearly":{"type":["string","null"],"pattern":"^price_[A-Za-z0-9]+$"},"paypal_plan_id":{"type":["string","null"],"pattern":"^P-[A-Z0-9]{10,40}$"},"paypal_plan_id_yearly":{"type":["string","null"],"pattern":"^P-[A-Z0-9]{10,40}$"},"max_workspaces":{"type":["integer","null"],"minimum":1,"maximum":10000000},"max_users":{"type":["integer","null"],"minimum":1,"maximum":10000000},"max_contacts":{"type":["integer","null"],"minimum":1,"maximum":10000000},"price_per_user":{"type":["integer","null"],"minimum":1,"maximum":10000000,"description":"Céntimos por usuario extra y periodo base; `null` = no se venden"},"price_per_workspace":{"type":["integer","null"],"minimum":1,"maximum":10000000},"contacts_pack_size":{"type":["integer","null"],"minimum":100,"maximum":10000000,"description":"Contactos por paquete extra (junto con `price_per_contacts_pack`)"},"price_per_contacts_pack":{"type":["integer","null"],"minimum":1,"maximum":10000000},"features":{"type":["array","null"],"items":{"type":"string","enum":["inbox","automations","scoring","ads_leads","ads_conversions","ads_spend","ads_audiences","client_reports","webhooks","report_exports"]},"maxItems":10,"description":"`null` = todas las funciones"},"trial_days":{"type":["integer","null"],"minimum":1,"maximum":90},"is_public":{"type":"boolean"},"is_featured":{"type":"boolean"},"is_active":{"type":"boolean"},"position":{"type":"integer","minimum":0,"maximum":1000}}},"BillingInfo":{"type":"object","properties":{"enabled":{"type":"boolean","description":"false si el servidor no tiene ninguna pasarela configurada"},"providers":{"type":"object","properties":{"stripe":{"type":"boolean"},"paypal":{"type":"boolean"}},"required":["stripe","paypal"],"description":"Pasarelas activas en este servidor"},"provider":{"type":["string","null"],"enum":["stripe","paypal",null],"description":"Pasarela de la suscripción actual"},"next_charge":{"type":["object","null"],"properties":{"amount":{"type":"integer"},"currency":{"type":"string"},"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"interval":{"type":"string","enum":["month","year"]}},"required":["amount","currency","at","interval"],"description":"Próximo cobro previsto: precio del plan y fin del periodo actual (solo con suscripción activa)"},"manage_url":{"type":["string","null"],"description":"Dónde gestionar la suscripción fuera de Ordyum (PayPal → pagos automáticos)"},"payments_summary":{"type":["object","null"],"properties":{"count":{"type":"integer"},"paid":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}},"refunded":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string"},"amount":{"type":"integer"}},"required":["currency","amount"]}}},"required":["count","paid","refunded"],"description":"Totales del historial de cobros (solo owner/admin)"},"can_manage":{"type":"boolean","description":"Owner o admin de la agencia"},"plan":{"type":"string"},"plan_name":{"type":"string"},"limits":{"allOf":[{"$ref":"#/components/schemas/PlanLimits"},{"description":"Límites efectivos: lo incluido en el plan + extras contratados + cortesía"}]},"included":{"allOf":[{"$ref":"#/components/schemas/PlanLimits"},{"description":"Lo que incluye el plan por sí solo"}]},"extras":{"type":"object","properties":{"users":{"type":"integer"},"workspaces":{"type":"integer"},"contact_packs":{"type":"integer"}},"required":["users","workspaces","contact_packs"],"description":"Extras que paga la agencia"},"bonus":{"type":"object","properties":{"users":{"type":"integer"},"workspaces":{"type":"integer"},"contacts":{"type":"integer"}},"required":["users","workspaces","contacts"],"description":"Capacidad regalada por la plataforma"},"addons":{"allOf":[{"$ref":"#/components/schemas/PlanAddons"},{"description":"Extras que vende el plan actual"}]},"can_change_extras":{"type":"boolean","description":"Se pueden añadir o quitar extras desde Ordyum (suscripción de Stripe al día)"},"usage":{"$ref":"#/components/schemas/PlanUsage"},"features":{"type":"array","items":{"type":"string","enum":["inbox","automations","scoring","ads_leads","ads_conversions","ads_spend","ads_audiences","client_reports","webhooks","report_exports"]},"description":"Funciones del plan actual"},"feature_usage":{"type":"object","properties":{"automations":{"type":"integer","description":"Smart Rules activas en todos los espacios de la agencia"},"ads_audiences":{"type":"integer","description":"Audiencias activas (se sincronizan con Google/Meta)"},"webhooks":{"type":"integer","description":"Webhooks salientes activos"}},"required":["automations","ads_audiences","webhooks"],"description":"Lo que dejaría de funcionar al pasar a un plan sin esa función (los datos se conservan)"},"status":{"type":"string","enum":["none","trialing","active","past_due","unpaid","canceled"]},"interval":{"type":["string","null"],"enum":["month","year",null],"description":"Periodo de la suscripción actual (según el último cobro o el plan)"},"cancel_at_period_end":{"type":"boolean","description":"Stripe: cancelada al final del periodo; se puede reanudar hasta entonces"},"can_change_plan":{"type":"boolean","description":"Cambio de plan dentro de Ordyum con prorrateo (suscripción de Stripe al día)"},"automatic_tax":{"type":"boolean","description":"Stripe calcula el IVA/impuesto según el país y el NIF de facturación"},"trial_ends_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"period_end":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"past_due_since":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"grace_ends_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"has_customer":{"type":"boolean"},"payment_method":{"$ref":"#/components/schemas/PaymentMethodSummary"},"suspended":{"type":"boolean"},"suspension_source":{"type":["string","null"],"enum":["platform","billing",null]},"suspended_reason":{"type":["string","null"],"description":"`trial_expired`, `payment_failed`, `subscription_canceled` o texto de la plataforma"},"plans":{"type":"array","items":{"type":"object","properties":{"plan":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"name":{"type":"string"},"description":{"$ref":"#/components/schemas/LocalizedText"},"highlights":{"$ref":"#/components/schemas/LocalizedList"},"limits":{"$ref":"#/components/schemas/PlanLimits"},"addons":{"$ref":"#/components/schemas/PlanAddons"},"features":{"type":"array","items":{"type":"string","enum":["inbox","automations","scoring","ads_leads","ads_conversions","ads_spend","ads_audiences","client_reports","webhooks","report_exports"]}},"featured":{"type":"boolean"},"available":{"type":"boolean","description":"Contratable online (Stripe configurado y plan con price)"},"amount":{"type":["integer","null"],"description":"Unidades menores"},"currency":{"type":["string","null"]},"interval":{"type":["string","null"]},"amount_yearly":{"type":["integer","null"],"description":"Precio anual (unidades menores) si el plan se vende también por año"},"available_yearly":{"type":"boolean"},"paypal":{"type":"boolean","description":"Contratable con PayPal (periodo base)"},"paypal_yearly":{"type":"boolean"}},"required":["plan","name","description","highlights","limits","addons","features","featured","available","amount","currency","interval","amount_yearly","available_yearly","paypal","paypal_yearly"]}}},"required":["enabled","providers","provider","next_charge","manage_url","payments_summary","can_manage","plan","plan_name","limits","included","extras","bonus","addons","can_change_extras","usage","features","feature_usage","status","interval","cancel_at_period_end","can_change_plan","automatic_tax","trial_ends_at","period_end","past_due_since","grace_ends_at","has_customer","payment_method","suspended","suspension_source","suspended_reason","plans"]},"PaymentMethodSummary":{"type":["object","null"],"properties":{"type":{"type":"string","description":"`card`, `sepa_debit`, `paypal`, `link`, `us_bank_account`…"},"brand":{"type":["string","null"],"description":"Marca de la tarjeta (`visa`, `mastercard`…) o del wallet (`apple_pay`, `google_pay`)"},"last4":{"type":["string","null"]},"exp_month":{"type":["integer","null"]},"exp_year":{"type":["integer","null"]}},"required":["type","brand","last4","exp_month","exp_year"],"description":"Método de pago guardado en Stripe (solo para owner/admin); se cambia desde el portal"},"BillingRedirect":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]},"BillingCheckout":{"type":"object","properties":{"plan":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"interval":{"type":"string","enum":["month","year"],"default":"month"},"provider":{"type":"string","enum":["stripe","paypal"],"default":"stripe"},"extras":{"$ref":"#/components/schemas/BillingExtras"}},"required":["plan"]},"BillingExtras":{"type":"object","properties":{"users":{"type":"integer","minimum":0,"maximum":1000,"default":0,"description":"Usuarios por encima de los incluidos en el plan"},"workspaces":{"type":"integer","minimum":0,"maximum":500,"default":0},"contact_packs":{"type":"integer","minimum":0,"maximum":1000,"default":0,"description":"Paquetes de contactos (tamaño según el plan)"}},"description":"Usuarios, espacios y contactos extra desde el primer cobro (solo con tarjeta)"},"PaymentPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Payment"}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"]},"BillingStatusResult":{"type":"object","properties":{"status":{"type":"string","enum":["none","trialing","active","past_due","unpaid","canceled"]},"access_until":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Tras cancelar: el acceso sigue hasta esta fecha"}},"required":["status"]},"PaypalConfirm":{"type":"object","properties":{"subscription_id":{"type":"string","pattern":"^I-[A-Z0-9]{6,40}$"}},"required":["subscription_id"]},"PlanChangePreview":{"type":"object","properties":{"plan":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"plan_name":{"type":"string"},"interval":{"type":"string","enum":["month","year"]},"currency":{"type":"string"},"amount_due":{"type":"integer","description":"Se cobra hoy (prorrateo del periodo restante, impuestos incluidos)"},"credit":{"type":"integer","description":"Saldo a favor que se descuenta de las próximas facturas (bajada de plan)"},"tax":{"type":"integer","description":"Parte de impuestos de `amount_due`"},"next_amount":{"type":["integer","null"],"description":"Precio del nuevo plan en cada renovación (sin impuestos)"},"next_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"proration_date":{"type":"integer","description":"Marca de tiempo del cálculo: se envía al confirmar para cobrar exactamente lo mostrado"}},"required":["plan","plan_name","interval","currency","amount_due","credit","tax","next_amount","next_at","proration_date"]},"PlanChangeInput":{"type":"object","properties":{"plan":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"interval":{"type":"string","enum":["month","year"],"default":"month"},"extras":{"allOf":[{"$ref":"#/components/schemas/BillingExtras"},{"description":"Extras con el nuevo plan; sin él se conservan los actuales que el plan venda"}]}},"required":["plan"]},"PlanChangeResult":{"type":"object","properties":{"status":{"type":"string","enum":["applied","payment_required"],"description":"`payment_required`: el banco pide confirmar el cobro; el plan cambia al pagar `invoice_url`"},"plan":{"type":"string"},"invoice_url":{"type":["string","null"]}},"required":["status","plan","invoice_url"]},"PlanChangeApply":{"allOf":[{"$ref":"#/components/schemas/PlanChangeInput"},{"type":"object","properties":{"proration_date":{"type":"integer","exclusiveMinimum":0}},"required":["proration_date"]}]},"ExtrasPreview":{"type":"object","properties":{"extras":{"allOf":[{"$ref":"#/components/schemas/BillingExtras"},{"description":"Extras contratados; se cobran en la suscripción de Stripe junto con el plan"}]},"limits":{"allOf":[{"$ref":"#/components/schemas/PlanLimits"},{"description":"Límites efectivos que tendría la agencia"}]},"currency":{"type":"string"},"amount_due":{"type":"integer","description":"Se cobra hoy por lo que queda del periodo (impuestos incluidos)"},"credit":{"type":"integer","description":"Saldo a favor al quitar extras"},"tax":{"type":"integer"},"next_amount":{"type":["integer","null"],"description":"Cuota de cada renovación con los extras (sin impuestos)"},"next_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"interval":{"type":"string","enum":["month","year"]},"proration_date":{"type":"integer"}},"required":["extras","limits","currency","amount_due","credit","tax","next_amount","next_at","interval","proration_date"]},"ExtrasResult":{"type":"object","properties":{"status":{"type":"string","enum":["applied","payment_required"]},"extras":{"allOf":[{"$ref":"#/components/schemas/BillingExtras"},{"description":"Extras contratados; se cobran en la suscripción de Stripe junto con el plan"}]},"invoice_url":{"type":["string","null"]}},"required":["status","extras","invoice_url"]},"ExtrasApply":{"allOf":[{"$ref":"#/components/schemas/BillingExtras"},{"type":"object","properties":{"proration_date":{"type":"integer","exclusiveMinimum":0}},"required":["proration_date"]}],"description":"Extras contratados; se cobran en la suscripción de Stripe junto con el plan"},"BillingDetails":{"type":"object","properties":{"name":{"type":["string","null"]},"email":{"type":["string","null"]},"country":{"type":["string","null"]},"line1":{"type":["string","null"]},"city":{"type":["string","null"]},"postal_code":{"type":["string","null"]},"tax_id":{"type":["object","null"],"properties":{"type":{"type":"string"},"value":{"type":"string"},"status":{"type":"string","enum":["pending","verified","unverified","unavailable"],"description":"Verificación de Stripe (VIES en la UE)"}},"required":["type","value","status"]}},"required":["name","email","country","line1","city","postal_code","tax_id"]},"BillingDetailsUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"email":{"type":"string","maxLength":320,"format":"email"},"country":{"type":"string","pattern":"^[A-Za-z]{2}$"},"line1":{"type":["string","null"],"maxLength":200},"city":{"type":["string","null"],"maxLength":120},"postal_code":{"type":["string","null"],"maxLength":20},"tax_id":{"type":["string","null"],"maxLength":40,"description":"CIF/NIF/VAT; vacío lo quita"}},"required":["name","email","country"]},"PublicPlans":{"type":"object","properties":{"plans":{"type":"array","items":{"$ref":"#/components/schemas/PublicPlan"}},"trial":{"type":["object","null"],"properties":{"days":{"type":"integer"},"limits":{"$ref":"#/components/schemas/PlanLimits"},"features":{"type":"array","items":{"type":"string","enum":["inbox","automations","scoring","ads_leads","ads_conversions","ads_spend","ads_audiences","client_reports","webhooks","report_exports"]}}},"required":["days","limits","features"],"description":"Prueba gratuita de las agencias nuevas"}},"required":["plans","trial"]},"InboundSource":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"kind":{"type":"string","enum":["google_ads_leads","meta_leads","shopify","stripe"]},"name":{"type":"string"},"url":{"type":"string","description":"URL pública a la que la plataforma envía los eventos"},"secret_hint":{"type":"string","description":"Últimos 4 caracteres de la clave"},"awaiting_secret":{"type":"boolean","description":"Stripe: creada sin el secreto de firma (`whsec_…`); no acepta eventos hasta pegarlo"},"settings":{"$ref":"#/components/schemas/InboundSettings"},"verify_token":{"type":["string","null"]},"credentials_hint":{"type":["string","null"]},"received_count":{"type":"integer"},"last_received_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_error":{"type":["string","null"]},"last_error_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","kind","name","url","secret_hint","awaiting_secret","settings","verify_token","credentials_hint","received_count","last_received_at","last_error","last_error_at","created_at"]},"InboundSettings":{"type":"object","properties":{"create_deals":{"type":"boolean"},"page_id":{"type":"string","pattern":"^\\d{5,25}$"}}},"InboundSourceCreated":{"type":"object","properties":{"source":{"$ref":"#/components/schemas/InboundSource"},"secret":{"type":"string","description":"Clave completa; solo se devuelve al crear"}},"required":["source","secret"]},"InboundSourceCreate":{"type":"object","properties":{"kind":{"type":"string","enum":["google_ads_leads","meta_leads","shopify","stripe"]},"name":{"type":"string","minLength":2,"maxLength":80},"secret":{"type":"string","minLength":8,"maxLength":200},"access_token":{"type":"string","minLength":20,"maxLength":1000},"settings":{"$ref":"#/components/schemas/InboundSettings"}},"required":["kind","name"]},"InboundSourceUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":80},"secret":{"type":"string","minLength":8,"maxLength":200},"access_token":{"type":"string","minLength":20,"maxLength":1000},"settings":{"$ref":"#/components/schemas/InboundSettings"}}},"InboundSourceTest":{"type":"object","properties":{"ok":{"type":"boolean"},"detail":{"type":["string","null"]},"error":{"type":["string","null"]}},"required":["ok","detail","error"]},"InboundImportResult":{"type":"object","properties":{"forms":{"type":"integer"},"found":{"type":"integer"},"imported":{"type":"integer","description":"Leads nuevos en Ordyum (los ya recibidos por webhook no cuentan)"},"truncated":{"type":"boolean","description":"Se alcanzó el tope de 2000 leads por importación"}},"required":["forms","found","imported","truncated"]},"InboundImport":{"type":"object","properties":{"days":{"type":"integer","minimum":1,"maximum":90,"default":30,"description":"Meta guarda los leads 90 días"}}},"ContactRequestCreate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"email":{"type":"string","maxLength":320,"format":"email"},"company":{"type":["string","null"],"maxLength":200},"website":{"type":["string","null"],"maxLength":300},"team_size":{"type":["string","null"],"enum":["1","2-5","6-15","16-50","50+",null]},"clients":{"type":["string","null"],"enum":["1-5","6-20","21-50","50+",null]},"plan":{"type":["string","null"],"maxLength":40},"topic":{"type":"string","enum":["sales","demo","partnership","support","privacy"],"default":"sales"},"message":{"type":"string","minLength":10,"maxLength":4000},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"],"default":"en"},"company_url":{"type":"string","maxLength":300}},"required":["name","email","message"]},"ContactRequest":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"},"company":{"type":["string","null"]},"website":{"type":["string","null"]},"team_size":{"type":["string","null"]},"clients":{"type":["string","null"]},"plan":{"type":["string","null"]},"topic":{"type":"string","enum":["sales","demo","partnership","support","privacy","feedback"]},"message":{"type":"string"},"locale":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"status":{"type":"string","enum":["new","contacted","closed"]},"notes":{"type":["string","null"]},"handled_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"organization":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"workspace":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"page":{"type":["string","null"]},"category":{"type":["string","null"],"enum":["confusing","slow","missing","unnecessary","bug","other","account","billing","integrations","data",null]},"subject":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","email","company","website","team_size","clients","plan","topic","message","locale","status","notes","handled_by","organization","workspace","page","category","subject","created_at","updated_at"]},"FeedbackCreate":{"type":"object","properties":{"category":{"type":"string","enum":["confusing","slow","missing","unnecessary","bug","other"]},"message":{"type":"string","minLength":3,"maxLength":4000},"page":{"type":["string","null"],"maxLength":300}},"required":["category","message"]},"SupportRequest":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"category":{"type":"string","enum":["account","billing","integrations","data","bug","other"]},"subject":{"type":"string"},"message":{"type":"string"},"status":{"type":"string","enum":["new","contacted","closed"]},"workspace":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","category","subject","message","status","workspace","created_at","updated_at"]},"SupportRequestCreate":{"type":"object","properties":{"category":{"type":"string","enum":["account","billing","integrations","data","bug","other"]},"subject":{"type":"string","minLength":3,"maxLength":160},"message":{"type":"string","minLength":10,"maxLength":4000},"workspace":{"type":["string","null"],"maxLength":120},"page":{"type":["string","null"],"maxLength":300}},"required":["category","subject","message"]},"ContactRequestPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ContactRequest"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"ContactRequestCounts":{"type":"object","properties":{"new":{"type":"integer"},"contacted":{"type":"integer"},"closed":{"type":"integer"}},"required":["new","contacted","closed"]},"ContactRequestUpdate":{"type":"object","properties":{"status":{"type":"string","enum":["new","contacted","closed"]},"notes":{"type":["string","null"],"maxLength":4000}}},"MessageTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"channel":{"$ref":"#/components/schemas/MessageChannel"},"subject":{"type":["string","null"],"description":"Solo email"},"body":{"type":"string"},"variables":{"type":"array","items":{"type":"string"},"description":"Variables usadas en asunto y cuerpo"},"use_count":{"type":"integer"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","channel","subject","body","variables","use_count","created_at","updated_at"]},"MessageChannel":{"type":"string","enum":["email","whatsapp"]},"MessageTemplateCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"channel":{"$ref":"#/components/schemas/MessageChannel"},"subject":{"type":["string","null"],"maxLength":300},"body":{"type":"string","minLength":1,"maxLength":10000}},"required":["name","channel","body"]},"MessageTemplateUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"channel":{"$ref":"#/components/schemas/MessageChannel"},"subject":{"type":["string","null"],"maxLength":300},"body":{"type":"string","minLength":1,"maxLength":10000}}},"TemplateRendered":{"type":"object","properties":{"subject":{"type":["string","null"]},"body":{"type":"string"},"missing":{"type":"array","items":{"type":"string"},"description":"Variables sin valor para este destinatario (quedan vacías)"}},"required":["subject","body","missing"]},"TemplateRenderInput":{"type":"object","properties":{"contact_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"deal_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"subject":{"type":["string","null"],"maxLength":300},"body":{"type":["string","null"],"maxLength":10000}}},"HostedForm":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"enabled":{"type":"boolean"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/FormField"}},"settings":{"$ref":"#/components/schemas/FormSettings"},"public_url":{"type":"string"},"embed_code":{"type":"string","description":"Fragmento HTML para incrustar en una web (iframe autoajustable)"},"submission_count":{"type":"integer"},"last_submission_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","enabled","fields","settings","public_url","embed_code","submission_count","last_submission_at","created_at","updated_at"]},"FormField":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$","description":"Estándar (`email`, `phone`, `name`…) o clave de un campo personalizado del contacto"},"label":{"type":"string","minLength":1,"maxLength":120},"type":{"type":"string","enum":["text","email","phone","textarea","select","checkbox"]},"required":{"type":"boolean","default":false},"placeholder":{"type":["string","null"],"maxLength":200},"options":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":30}},"required":["key","label","type"]},"FormSettings":{"type":"object","properties":{"title":{"type":["string","null"],"maxLength":160},"intro":{"type":["string","null"],"maxLength":1000},"submit_label":{"type":["string","null"],"maxLength":60},"success_message":{"type":["string","null"],"maxLength":500},"redirect_url":{"type":["string","null"],"maxLength":2000,"format":"uri"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"consent_text":{"type":["string","null"],"maxLength":500}}},"HostedFormCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"enabled":{"type":"boolean","default":true},"fields":{"type":"array","items":{"$ref":"#/components/schemas/FormField"},"minItems":1,"maxItems":25},"settings":{"$ref":"#/components/schemas/FormSettings"}},"required":["name","fields"]},"HostedFormUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"enabled":{"type":"boolean"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/FormField"},"minItems":1,"maxItems":25},"settings":{"$ref":"#/components/schemas/FormSettings"}}},"PublicForm":{"type":"object","properties":{"name":{"type":"string"},"workspace":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/FormField"}},"settings":{"type":"object","properties":{"title":{"type":["string","null"],"maxLength":160},"intro":{"type":["string","null"],"maxLength":1000},"submit_label":{"type":["string","null"],"maxLength":60},"success_message":{"type":["string","null"],"maxLength":500},"redirect_url":{"type":["string","null"],"maxLength":2000,"format":"uri"},"consent_text":{"type":["string","null"],"maxLength":500}}}},"required":["name","workspace","fields","settings"]},"PublicFormResult":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"message":{"type":["string","null"]},"redirect_url":{"type":["string","null"]}},"required":["ok","message","redirect_url"]},"PublicFormSubmit":{"type":"object","properties":{"values":{"type":"object","additionalProperties":{"anyOf":[{"type":"string","maxLength":5000},{"type":"boolean"}]}},"attribution":{"$ref":"#/components/schemas/AttributionInput"},"website":{"type":"string","maxLength":200},"elapsed_ms":{"type":"integer","minimum":0}},"required":["values"]},"CalendarResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CalendarEvent"}}},"required":["data"]},"CalendarEvent":{"type":"object","properties":{"id":{"type":"string","description":"`{kind}:{id}`"},"kind":{"type":"string","enum":["task","meeting","deal_close"]},"source_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"start":{"type":"string","description":"ISO date-time; en `all_day` solo la fecha (YYYY-MM-DD)"},"all_day":{"type":"boolean"},"done":{"type":"boolean"},"overdue":{"type":"boolean"},"priority":{"type":["string","null"],"enum":["low","normal","high",null]},"amount":{"type":["integer","null"]},"currency":{"type":["string","null"]},"subject":{"type":["object","null"],"properties":{"type":{"type":"string","enum":["contact","company","deal"]},"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["type","id","name"]},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["id","kind","source_id","title","start","all_day","done","overdue","priority","amount","currency","subject","owner_id"]},"CalendarFeed":{"type":"object","properties":{"url":{"type":"string"}},"required":["url"]},"DashboardLayout":{"type":"object","properties":{"widgets":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","enum":["kpis","today","new_leads","pipeline","activity","hot_leads","score","leaks","speed","channels"]},"visible":{"type":"boolean"}},"required":["id","visible"]},"maxItems":10}},"required":["widgets"]},"RecentActivity":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"type":{"type":"string","enum":["note","email","call","meeting","system"]},"body":{"type":["string","null"]},"payload":{"type":"object","additionalProperties":{}},"occurred_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"actor":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"subject":{"type":"object","properties":{"type":{"type":"string","enum":["contact","company","deal"]},"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["type","id","name"]}},"required":["id","type","body","payload","occurred_at","actor","subject"]},"InboxChannel":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"kind":{"$ref":"#/components/schemas/InboxChannelKind"},"name":{"type":"string"},"address":{"type":"string","description":"Email del buzón, número de WhatsApp, nombre de la página de Facebook o @usuario de Instagram"},"owner_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Buzones de email: solo su dueño los lee"},"status":{"type":"string","enum":["active","error","paused"]},"imap":{"type":["object","null"],"properties":{"host":{"type":"string"},"port":{"type":"integer"},"secure":{"type":"boolean"},"user":{"type":"string"}},"required":["host","port","secure","user"]},"smtp":{"type":["object","null"],"properties":{"host":{"type":"string"},"port":{"type":"integer"},"secure":{"type":"boolean"},"user":{"type":"string"}},"required":["host","port","secure","user"]},"webhook_url":{"type":["string","null"],"description":"WhatsApp: URL de devolución de llamada para Meta"},"verify_token":{"type":["string","null"],"description":"WhatsApp: token de verificación para Meta"},"auth":{"type":["string","null"],"enum":["password","oauth",null]},"provider":{"type":["string","null"],"enum":["google","microsoft",null]},"waba_id":{"type":["string","null"]},"last_sync_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_error":{"type":["string","null"]},"last_error_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"unread":{"type":"integer","description":"Conversaciones con mensajes sin leer"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","kind","name","address","owner_id","status","imap","smtp","webhook_url","verify_token","auth","provider","waba_id","last_sync_at","last_error","last_error_at","unread","created_at"]},"InboxChannelKind":{"type":"string","enum":["email","whatsapp","webchat","messenger","instagram"]},"InboxChannelCreate":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["email"]},"name":{"type":"string","minLength":1,"maxLength":120},"address":{"type":"string","maxLength":320,"format":"email"},"imap":{"type":"object","properties":{"host":{"type":"string","minLength":1,"maxLength":253,"pattern":"^[A-Za-z0-9.-]+$"},"port":{"type":"integer","minimum":1,"maximum":65535},"secure":{"type":"boolean"},"user":{"type":"string","minLength":1,"maxLength":320},"password":{"type":"string","minLength":1,"maxLength":500}},"required":["host","port","secure","user","password"]},"smtp":{"type":"object","properties":{"host":{"type":"string","minLength":1,"maxLength":253,"pattern":"^[A-Za-z0-9.-]+$"},"port":{"type":"integer","minimum":1,"maximum":65535},"secure":{"type":"boolean"},"user":{"type":"string","minLength":1,"maxLength":320},"password":{"type":"string","minLength":1,"maxLength":500}},"required":["host","port","secure","user","password"]}},"required":["kind","name","address","imap","smtp"]},{"type":"object","properties":{"kind":{"type":"string","enum":["whatsapp"]},"name":{"type":"string","minLength":1,"maxLength":120},"phone_number_id":{"type":"string","pattern":"^\\d{5,30}$"},"access_token":{"type":"string","minLength":20,"maxLength":1000},"app_secret":{"type":"string","minLength":8,"maxLength":200},"waba_id":{"type":["string","null"],"pattern":"^\\d{5,30}$"}},"required":["kind","name","phone_number_id","access_token","app_secret"]},{"type":"object","properties":{"kind":{"type":"string","enum":["messenger"]},"name":{"type":"string","minLength":1,"maxLength":120},"page_id":{"type":"string","pattern":"^\\d{5,30}$"},"page_token":{"type":"string","minLength":20,"maxLength":1000},"app_id":{"type":"string","pattern":"^\\d{5,30}$"},"app_secret":{"type":"string","minLength":8,"maxLength":200}},"required":["kind","name","page_id","page_token","app_id","app_secret"]},{"type":"object","properties":{"kind":{"type":"string","enum":["instagram"]},"name":{"type":"string","minLength":1,"maxLength":120},"page_id":{"type":"string","pattern":"^\\d{5,30}$"},"page_token":{"type":"string","minLength":20,"maxLength":1000},"app_id":{"type":"string","pattern":"^\\d{5,30}$"},"app_secret":{"type":"string","minLength":8,"maxLength":200},"ig_id":{"type":"string","pattern":"^\\d{5,30}$"}},"required":["kind","name","page_id","page_token","app_id","app_secret","ig_id"]}]},"InboxChannelUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"paused":{"type":"boolean"},"imap":{"type":"object","properties":{"host":{"type":"string","minLength":1,"maxLength":253,"pattern":"^[A-Za-z0-9.-]+$"},"port":{"type":"integer","minimum":1,"maximum":65535},"secure":{"type":"boolean"},"user":{"type":"string","minLength":1,"maxLength":320},"password":{"type":"string","minLength":1,"maxLength":500}},"required":["host","port","secure","user"]},"smtp":{"type":"object","properties":{"host":{"type":"string","minLength":1,"maxLength":253,"pattern":"^[A-Za-z0-9.-]+$"},"port":{"type":"integer","minimum":1,"maximum":65535},"secure":{"type":"boolean"},"user":{"type":"string","minLength":1,"maxLength":320},"password":{"type":"string","minLength":1,"maxLength":500}},"required":["host","port","secure","user"]},"access_token":{"type":"string","minLength":20,"maxLength":1000},"app_secret":{"type":"string","minLength":8,"maxLength":200},"waba_id":{"type":["string","null"],"pattern":"^\\d{5,30}$"},"page_token":{"type":"string","minLength":20,"maxLength":1000}}},"InboxSyncResult":{"type":"object","properties":{"imported":{"type":"integer"},"error":{"type":["string","null"]}},"required":["imported","error"]},"InboxOAuthProviders":{"type":"object","properties":{"google":{"type":"boolean"},"microsoft":{"type":"boolean"},"meta":{"type":"boolean","description":"App de Meta configurada en la consola: se pueden conectar páginas de Facebook e Instagram"}},"required":["google","microsoft","meta"],"description":"Proveedores con cliente OAuth configurado en la plataforma"},"InboxOAuthRedirect":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]},"InboxOAuthStart":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"channel_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}}},"MetaConnectRequest":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"pages":{"type":"array","items":{"$ref":"#/components/schemas/MetaPageOption"}},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","pages","expires_at"]},"MetaPageOption":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"picture":{"type":["string","null"]},"instagram":{"type":["object","null"],"properties":{"id":{"type":"string"},"username":{"type":["string","null"]}},"required":["id","username"]},"messenger_here":{"type":"boolean"},"instagram_here":{"type":"boolean"},"messenger_elsewhere":{"type":"boolean"},"instagram_elsewhere":{"type":"boolean"}},"required":["id","name","picture","instagram","messenger_here","instagram_here","messenger_elsewhere","instagram_elsewhere"]},"MetaConnectResult":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/InboxChannel"}}},"required":["data"]},"MetaConnectInput":{"type":"object","properties":{"pages":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^\\d{3,30}$"},"messenger":{"type":"boolean"},"instagram":{"type":"boolean"}},"required":["id","messenger","instagram"]},"minItems":1,"maxItems":50}},"required":["pages"]},"WhatsAppTemplateList":{"type":"object","properties":{"templates":{"type":"array","items":{"$ref":"#/components/schemas/WhatsAppTemplate"}}},"required":["templates"]},"WhatsAppTemplate":{"type":"object","properties":{"name":{"type":"string"},"language":{"type":"string"},"category":{"type":"string"},"body":{"type":"string"},"params":{"type":"integer"}},"required":["name","language","category","body","params"]},"ConversationPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Conversation"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"Conversation":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"channel_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"kind":{"$ref":"#/components/schemas/InboxChannelKind"},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"score":{"type":["integer","null"]}},"required":["id","name","score"]},"counterpart":{"type":"string"},"counterpart_name":{"type":["string","null"]},"subject":{"type":["string","null"]},"snippet":{"type":["string","null"]},"last_attachment":{"$ref":"#/components/schemas/MessageAttachment"},"last_message_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_direction":{"type":"string","enum":["in","out"]},"unread_count":{"type":"integer"},"reply_window_open":{"type":"boolean"},"reply_window_closes_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Cuándo deja de admitirse responder: WhatsApp 24 h tras el último mensaje del cliente; Messenger e Instagram 7 días (pasadas 24 h sale con la etiqueta «agente humano» de Meta). Null en correo"},"assignee":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"status":{"type":"string","enum":["open","closed"]},"snoozed_until":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Pospuesta hasta esa fecha (null = no pospuesta o ya vencida)"},"bot_active":{"type":"boolean","description":"Chat web: el asistente responde al visitante (false = lo atiende el equipo)"},"visitor":{"type":["object","null"],"properties":{"page":{"type":["string","null"]},"referrer":{"type":["string","null"]},"locale":{"type":["string","null"]},"device":{"type":["string","null"]}},"required":["page","referrer","locale","device"],"description":"Chat web: página e idioma del visitante"}},"required":["id","channel_id","kind","contact","counterpart","counterpart_name","subject","snippet","last_attachment","last_message_at","last_direction","unread_count","reply_window_open","reply_window_closes_at","assignee","status","snoozed_until","bot_active","visitor"]},"MessageAttachment":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"kind":{"$ref":"#/components/schemas/AttachmentKind"},"mime":{"type":"string"},"filename":{"type":["string","null"]},"size":{"type":["integer","null"]},"status":{"type":"string","enum":["pending","stored","failed","too_large"],"description":"`pending`: descargándose de WhatsApp; `stored`: disponible en `url`"},"url":{"type":["string","null"],"description":"Ruta de descarga (misma sesión; añade `?download=1` para forzar la descarga)"}},"required":["id","kind","mime","filename","size","status","url"],"description":"Primer adjunto del último mensaje (miniatura en la lista); null si el último mensaje es solo texto"},"AttachmentKind":{"type":"string","enum":["image","audio","video","document","sticker"]},"Message":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"conversation_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"direction":{"type":"string","enum":["in","out"]},"from":{"type":"string"},"to":{"type":"string"},"subject":{"type":["string","null"]},"body":{"type":"string"},"status":{"type":"string","enum":["received","sent","delivered","read","failed"]},"error":{"type":["string","null"]},"author":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"bot":{"type":"boolean","description":"Respuesta del asistente en el chat web"},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/MessageAttachment"}},"sent_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","conversation_id","direction","from","to","subject","body","status","error","author","bot","attachments","sent_at"]},"NewConversation":{"allOf":[{"$ref":"#/components/schemas/MessageSend"},{"type":"object","properties":{"channel_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"contact_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["channel_id","contact_id"]}]},"MessageSend":{"type":"object","properties":{"body":{"type":"string","maxLength":20000,"default":""},"attachment_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Archivo subido antes con `POST /v1/inbox/uploads` (imagen JPG/PNG o PDF)"},"subject":{"type":["string","null"],"maxLength":300},"template_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"whatsapp_template":{"type":["object","null"],"properties":{"name":{"type":"string","minLength":1,"maxLength":512},"language":{"type":"string","minLength":2,"maxLength":15},"params":{"type":"array","items":{"type":"string","minLength":1,"maxLength":1000},"maxItems":20,"default":[]}},"required":["name","language"]}}},"ConversationDetail":{"type":"object","properties":{"conversation":{"$ref":"#/components/schemas/Conversation"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/Message"}},"notes":{"type":"array","items":{"$ref":"#/components/schemas/ConversationNote"},"description":"Notas internas del equipo"}},"required":["conversation","messages","notes"]},"ConversationNote":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"body":{"type":"string"},"author":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","body","author","created_at"]},"CampaignJourney":{"type":"object","properties":{"campaign":{"$ref":"#/components/schemas/AdCampaignPerformance"},"days":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"funnel":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string","enum":["clicks","leads","contacted","qualified","opportunities","proposals","customers"]},"count":{"type":"integer"}},"required":["step","count"]}},"revenue":{"type":"integer"},"metrics":{"type":"object","properties":{"cpl":{"type":["integer","null"]},"cac":{"type":["integer","null"]},"roas":{"type":["number","null"]},"close_rate":{"type":["number","null"],"description":"Clientes / leads (0–1)"},"cost_per_qualified":{"type":["integer","null"]},"median_response_seconds":{"type":["integer","null"]}},"required":["cpl","cac","roas","close_rate","cost_per_qualified","median_response_seconds"]},"leads":{"type":"array","items":{"type":"object","properties":{"contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"response_seconds":{"type":["integer","null"]},"lifecycle_stage":{"type":"string","enum":["lead","prospect","customer","churned","other"]},"deal":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"amount":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"status":{"type":"string","enum":["open","won","lost"]},"stage":{"type":"string"}},"required":["id","title","amount","currency","status","stage"]}},"required":["contact","created_at","response_seconds","lifecycle_stage","deal"]}}},"required":["campaign","days","currency","funnel","revenue","metrics","leads"]},"ContactJourney":{"type":"object","properties":{"summary":{"type":"object","properties":{"channel":{"$ref":"#/components/schemas/Channel"},"campaign":{"type":["string","null"]},"first_touch_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"lead_received_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"response_seconds":{"type":["integer","null"]},"won_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"days_to_won":{"type":["integer","null"]},"revenue":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"touches":{"type":"integer"}},"required":["channel","campaign","first_touch_at","lead_received_at","response_seconds","won_at","days_to_won","revenue","currency","touches"]},"steps":{"type":"array","items":{"$ref":"#/components/schemas/JourneyStep"}}},"required":["summary","steps"]},"JourneyStep":{"type":"object","properties":{"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"kind":{"type":"string","enum":["ad_click","visit","form","created","assigned","first_response","message_in","message_out","call","email","meeting","note","task_done","deal_created","stage","won","lost","sla_missed","reassigned"]},"title":{"type":["string","null"],"description":"Dato principal (campaña, página, etapa, negocio…); el cliente compone el texto"},"detail":{"type":["string","null"]},"actor":{"type":["string","null"]},"amount":{"type":["integer","null"]},"currency":{"type":["string","null"],"pattern":"^[A-Z]{3}$","example":"USD"},"seconds":{"type":["integer","null"],"description":"first_response: segundos desde el lead"},"ref":{"type":["object","null"],"properties":{"type":{"type":"string","enum":["deal","conversation"]},"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["type","id"]}},"required":["at","kind","title","detail","actor","amount","currency","seconds","ref"]},"DealReplay":{"type":"object","properties":{"summary":{"type":"object","properties":{"age_days":{"type":"integer"},"touches":{"type":"integer","description":"Llamadas, emails, reuniones y notas registradas"},"amount_initial":{"type":"integer"},"amount_now":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"status":{"type":"string","enum":["open","won","lost"]}},"required":["age_days","touches","amount_initial","amount_now","currency","status"]},"events":{"type":"array","items":{"type":"object","properties":{"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"kind":{"type":"string","enum":["created","stage","amount","owner","close_date","title","contacted","task_done","automation","won","lost"]},"actor":{"type":["string","null"]},"from":{"type":["string","null"]},"to":{"type":["string","null"]},"detail":{"type":["string","null"]}},"required":["at","kind","actor","from","to","detail"]}},"stages":{"type":"array","items":{"type":"object","properties":{"stage_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"entered_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"left_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"days":{"type":"number"}},"required":["stage_id","name","entered_at","left_at","days"]}}},"required":["summary","events","stages"]},"AttributionCompare":{"type":"object","properties":{"days":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"total_leads":{"type":"integer"},"rows":{"type":"array","items":{"type":"object","properties":{"channel":{"$ref":"#/components/schemas/Channel"},"first":{"type":"object","properties":{"leads":{"type":"integer"},"won":{"type":"integer"},"revenue":{"type":"integer"}},"required":["leads","won","revenue"]},"last":{"type":"object","properties":{"leads":{"type":"integer"},"won":{"type":"integer"},"revenue":{"type":"integer"}},"required":["leads","won","revenue"]}},"required":["channel","first","last"]}}},"required":["days","currency","total_leads","rows"]},"LeakReport":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"total_amount":{"type":"integer","description":"Suma de importes en riesgo (sin duplicar un mismo negocio)"},"leaks":{"type":"array","items":{"$ref":"#/components/schemas/Leak"},"description":"Solo las reglas con algún caso, de más grave a menos"}},"required":["currency","total_amount","leaks"]},"Leak":{"type":"object","properties":{"kind":{"type":"string","enum":["unfollowed_deals","uncontacted_leads","stale_proposals","wasted_spend","deals_without_task","unanswered_conversations"]},"severity":{"type":"string","enum":["high","medium","low"]},"count":{"type":"integer"},"amount":{"type":["integer","null"],"description":"Dinero en juego (moneda del workspace); null si no aplica"},"threshold":{"type":"integer","description":"Umbral de la regla (días, horas o minutos según el tipo)"},"items":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["contact","deal","campaign","conversation"]},"id":{"type":"string"},"label":{"type":"string"},"sublabel":{"type":["string","null"]},"amount":{"type":["integer","null"]},"at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["type","id","label","sublabel","amount","at"]},"description":"Hasta 10 ejemplos, los de más valor primero"}},"required":["kind","severity","count","amount","threshold","items"]},"SpeedReport":{"type":"object","properties":{"days":{"type":"integer"},"sla_minutes":{"type":"integer"},"channel_minutes":{"type":"object","additionalProperties":{"type":"integer"}},"totals":{"type":"object","properties":{"leads":{"type":"integer"},"responded":{"type":"integer"},"within_sla":{"type":"integer"},"pct_within":{"type":["number","null"],"description":"0–1 sobre los leads con SLA vencido o atendidos"},"median_seconds":{"type":["integer","null"]},"missed":{"type":"integer","description":"Atendidos tarde o sin atender pasado el SLA"},"waiting":{"type":"integer","description":"Sin atender y aún dentro del SLA"}},"required":["leads","responded","within_sla","pct_within","median_seconds","missed","waiting"]},"this_week":{"type":"object","properties":{"leads":{"type":"integer"},"responded":{"type":"integer"},"within_sla":{"type":"integer"},"pct_within":{"type":["number","null"],"description":"0–1 sobre los leads con SLA vencido o atendidos"},"median_seconds":{"type":["integer","null"]},"missed":{"type":"integer","description":"Atendidos tarde o sin atender pasado el SLA"},"waiting":{"type":"integer","description":"Sin atender y aún dentro del SLA"}},"required":["leads","responded","within_sla","pct_within","median_seconds","missed","waiting"]},"by_owner":{"type":"array","items":{"type":"object","properties":{"leads":{"type":"integer"},"responded":{"type":"integer"},"within_sla":{"type":"integer"},"pct_within":{"type":["number","null"],"description":"0–1 sobre los leads con SLA vencido o atendidos"},"median_seconds":{"type":["integer","null"]},"missed":{"type":"integer","description":"Atendidos tarde o sin atender pasado el SLA"},"waiting":{"type":"integer","description":"Sin atender y aún dentro del SLA"},"user":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}},"required":["leads","responded","within_sla","pct_within","median_seconds","missed","waiting","user"]}},"by_channel":{"type":"array","items":{"type":"object","properties":{"leads":{"type":"integer"},"responded":{"type":"integer"},"within_sla":{"type":"integer"},"pct_within":{"type":["number","null"],"description":"0–1 sobre los leads con SLA vencido o atendidos"},"median_seconds":{"type":["integer","null"]},"missed":{"type":"integer","description":"Atendidos tarde o sin atender pasado el SLA"},"waiting":{"type":"integer","description":"Sin atender y aún dentro del SLA"},"channel":{"$ref":"#/components/schemas/Channel"},"sla_minutes":{"type":"integer"}},"required":["leads","responded","within_sla","pct_within","median_seconds","missed","waiting","channel","sla_minutes"]}},"buckets":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["5m","15m","1h","4h","24h","more","none"]},"count":{"type":"integer"}},"required":["key","count"]}},"recent":{"type":"array","items":{"type":"object","properties":{"contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"channel":{"$ref":"#/components/schemas/Channel"},"owner":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"received_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"first_response_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"seconds":{"type":["integer","null"]},"sla_minutes":{"type":"integer"},"status":{"type":"string","enum":["within","late","waiting","missed"]}},"required":["contact","channel","owner","received_at","first_response_at","seconds","sla_minutes","status"]}}},"required":["days","sla_minutes","channel_minutes","totals","this_week","by_owner","by_channel","buckets","recent"]},"PipelineHealth":{"type":"object","properties":{"pipeline_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"score":{"type":"integer"},"components":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["coverage","stale","no_task","win_rate","cycle"]},"score":{"type":"integer"},"weight":{"type":"integer"},"value":{"type":["number","null"],"description":"coverage: veces; stale/no_task/win_rate: 0–1; cycle: días"},"status":{"type":"string","enum":["good","warn","bad"]}},"required":["key","score","weight","value","status"]}},"open_deals":{"type":"integer"},"open_amount":{"type":"integer"},"rot":{"type":"array","items":{"type":"object","properties":{"status":{"type":"string","enum":["fresh","healthy","cooling","stale","at_risk"]},"count":{"type":"integer"},"amount":{"type":"integer"}},"required":["status","count","amount"]}},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"}},"required":["pipeline_id","score","components","open_deals","open_amount","rot","currency"]},"LostAnalysis":{"type":"object","properties":{"days":{"type":"integer"},"by":{"type":"string","enum":["owner","channel","campaign","product"]},"total":{"type":"integer"},"amount":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"reasons":{"type":"array","items":{"type":"object","properties":{"code":{"$ref":"#/components/schemas/LostReasonCode"},"count":{"type":"integer"},"amount":{"type":"integer"},"pct":{"type":"number"}},"required":["code","count","amount","pct"]}},"breakdown":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"total":{"type":"integer"},"reasons":{"type":"object","additionalProperties":{"type":"integer"}}},"required":["key","label","total","reasons"]}},"insights":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["top_reason","segment_skew"]},"reason":{"$ref":"#/components/schemas/LostReasonCode"},"pct":{"type":"number"},"segment":{"type":["string","null"]},"baseline_pct":{"type":["number","null"]}},"required":["kind","reason","pct","segment","baseline_pct"]}}},"required":["days","by","total","amount","currency","reasons","breakdown","insights"]},"OrdyumScore":{"type":"object","properties":{"score":{"type":"integer"},"previous":{"type":["integer","null"]},"delta":{"type":["integer","null"]},"week":{"type":"string"},"components":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["response_speed","follow_up","hygiene","conversion","velocity"]},"score":{"type":"integer"},"weight":{"type":"integer"},"value":{"type":["number","null"]}},"required":["key","score","weight","value"]}},"history":{"type":"array","items":{"type":"object","properties":{"week":{"type":"string"},"score":{"type":"integer"}},"required":["week","score"]}}},"required":["score","previous","delta","week","components","history"]},"PortalSummary":{"type":"object","properties":{"month":{"type":"string"},"from":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"to":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"mixed_currency":{"type":"boolean"},"workspace_name":{"type":"string"},"agency_name":{"type":"string"},"totals":{"type":"object","properties":{"spend":{"type":"integer"},"leads":{"type":"integer"},"contacted":{"type":"integer"},"unanswered":{"type":"integer"},"qualified":{"type":"integer"},"customers":{"type":"integer"},"revenue":{"type":"integer"},"roas":{"type":["number","null"]},"cpl":{"type":["integer","null"]},"cac":{"type":["integer","null"]}},"required":["spend","leads","contacted","unanswered","qualified","customers","revenue","roas","cpl","cac"]},"previous":{"type":"object","properties":{"spend":{"type":"integer"},"leads":{"type":"integer"},"contacted":{"type":"integer"},"unanswered":{"type":"integer"},"qualified":{"type":"integer"},"customers":{"type":"integer"},"revenue":{"type":"integer"},"roas":{"type":["number","null"]},"cpl":{"type":["integer","null"]},"cac":{"type":["integer","null"]}},"required":["spend","leads","contacted","unanswered","qualified","customers","revenue","roas","cpl","cac"]},"by_week":{"type":"array","items":{"type":"object","properties":{"week_start":{"type":"string"},"leads":{"type":"integer"},"customers":{"type":"integer"}},"required":["week_start","leads","customers"]}},"platforms":{"type":"array","items":{"type":"object","properties":{"platform":{"type":"string","enum":["google_ads","meta"]},"spend":{"type":"integer"},"leads":{"type":"integer"},"revenue":{"type":"integer"}},"required":["platform","spend","leads","revenue"]}},"campaigns":{"type":"array","items":{"$ref":"#/components/schemas/AdCampaignPerformance"}},"recent_leads":{"type":"array","items":{"type":"object","properties":{"contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"channel":{"$ref":"#/components/schemas/Channel"},"status":{"type":"string","enum":["new","contacted","qualified","customer","lost"]}},"required":["contact","created_at","channel","status"]}}},"required":["month","from","to","currency","mixed_currency","workspace_name","agency_name","totals","previous","by_week","platforms","campaigns","recent_leads"]},"PortalShareList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PortalShareLink"}}},"required":["data"]},"PortalShareLink":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"url":{"type":"string"},"month":{"type":["string","null"]},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"revoked_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"view_count":{"type":"integer"},"last_viewed_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","url","month","expires_at","revoked_at","view_count","last_viewed_at","created_by","created_at"]},"PortalShareCreate":{"type":"object","properties":{"expires_in_days":{"anyOf":[{"type":"number","enum":[7]},{"type":"number","enum":[30]},{"type":"number","enum":[90]}],"default":30},"month":{"type":["string","null"],"pattern":"^\\d{4}-(0[1-9]|1[0-2])$","description":"Mes fijo `YYYY-MM`; vacío = siempre el mes en curso"}}},"PublicPortal":{"type":"object","properties":{"summary":{"$ref":"#/components/schemas/PortalSummary"},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"fixed_month":{"type":"boolean","description":"`true` si el enlace muestra siempre el mismo mes"}},"required":["summary","expires_at","fixed_month"]},"AgencyOverview":{"type":"object","properties":{"org":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"days":{"type":"integer"},"generated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z","description":"Cuándo se calculó esta foto (se sirve desde caché hasta 5 min)"},"rows":{"type":"array","items":{"type":"object","properties":{"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"avatar":{"$ref":"#/components/schemas/WorkspaceAvatar"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"}},"required":["id","name","slug","avatar","currency"]},"leads":{"type":"integer"},"leads_prev":{"type":"integer"},"pipeline_amount":{"type":"integer"},"won_amount":{"type":"integer"},"won_count":{"type":"integer"},"sla_pct":{"type":["number","null"]},"spend":{"type":"integer"},"cpl":{"type":["integer","null"]},"cpl_prev":{"type":["integer","null"]},"score":{"type":["integer","null"]},"attention":{"type":"integer"}},"required":["workspace","leads","leads_prev","pipeline_amount","won_amount","won_count","sla_pct","spend","cpl","cpl_prev","score","attention"]}},"attention":{"type":"array","items":{"type":"object","properties":{"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"avatar":{"$ref":"#/components/schemas/WorkspaceAvatar"}},"required":["id","name","slug","avatar"]},"kind":{"type":"string","enum":["uncontacted_leads","cpl_up","stale_proposals","sla_low","no_leads"]},"severity":{"type":"string","enum":["high","medium","low"]},"count":{"type":["integer","null"]},"pct":{"type":["number","null"]},"amount":{"type":["integer","null"]},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"}},"required":["workspace","kind","severity","count","pct","amount","currency"]}}},"required":["org","days","generated_at","rows","attention"]},"WorkspaceTemplateList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceTemplate"}}},"required":["data"]},"WorkspaceTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"org_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"description":{"type":["string","null"]},"source_workspace":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"summary":{"type":"object","properties":{"pipelines":{"type":"integer"},"stages":{"type":"integer"},"custom_fields":{"type":"integer"},"tags":{"type":"integer"},"products":{"type":"integer"},"scoring_rules":{"type":"integer"},"automation_rules":{"type":"integer"},"forms":{"type":"integer"},"message_templates":{"type":"integer"}},"required":["pipelines","stages","custom_fields","tags","products","scoring_rules","automation_rules","forms","message_templates"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","org_id","name","description","source_workspace","summary","created_at"]},"WorkspaceTemplateCreate":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"description":{"type":["string","null"],"maxLength":500}},"required":["name"]},"InboxCounts":{"type":"object","properties":{"mine":{"type":"integer"},"unassigned":{"type":"integer"},"waiting_us":{"type":"integer"},"waiting_customer":{"type":"integer"},"snoozed":{"type":"integer"},"closed":{"type":"integer"},"all":{"type":"integer"}},"required":["mine","unassigned","waiting_us","waiting_customer","snoozed","closed","all"]},"ConversationUpdate":{"type":"object","properties":{"assignee_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"status":{"type":"string","enum":["open","closed"]},"snoozed_until":{"type":["string","null"],"format":"date-time","description":"Pospuesta hasta; un entrante nuevo la reabre antes"},"bot_active":{"type":"boolean","description":"Chat web: `false` = el equipo toma la conversación y el asistente deja de responder"}}},"ConversationTyping":{"type":"object","properties":{"text":{"type":["string","null"],"description":"Lo que el visitante lleva escrito sin enviar; null = no está escribiendo"},"at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["text","at"]},"ConversationNoteCreate":{"type":"object","properties":{"body":{"type":"string","minLength":1,"maxLength":5000}},"required":["body"]},"ConversationPresence":{"type":"object","properties":{"viewers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}}},"required":["viewers"]},"ConnectInfo":{"type":"object","properties":{"app_url":{"type":"string","description":"Web de Ordyum donde el usuario autoriza la conexión"},"api_version":{"type":"string"},"clients":{"type":"array","items":{"type":"string","enum":["wordpress"]}}},"required":["app_url","api_version","clients"]},"ConnectAuthorized":{"type":"object","properties":{"redirect_url":{"type":"string","description":"`redirect_uri` con `code` y `state` añadidos"},"expires_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["redirect_url","expires_at"]},"ConnectAuthorize":{"type":"object","properties":{"client":{"type":"string","enum":["wordpress"]},"site_url":{"type":"string","maxLength":500,"description":"Web que se conecta (p. ej. https://clinica.com)"},"redirect_uri":{"type":"string","maxLength":500,"description":"Vuelta al plugin; mismo dominio que `site_url`"},"state":{"type":"string","pattern":"^[A-Za-z0-9_-]{16,128}$","description":"Valor opaco del plugin; vuelve tal cual (anti-CSRF)"},"code_challenge":{"type":"string","pattern":"^[A-Za-z0-9_-]{43,128}$","description":"BASE64URL(SHA256(code_verifier))"},"code_challenge_method":{"type":"string","enum":["S256"]}},"required":["client","site_url","redirect_uri","state","code_challenge","code_challenge_method"]},"ConnectTokenResult":{"type":"object","properties":{"api_key":{"type":"string","description":"Secreto `ord_live_…` exclusivo de este sitio; solo se devuelve aquí"},"key_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"org_name":{"type":"string"}},"required":["id","name","slug","org_name"]},"connected_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"}},"required":["id","name","email"],"description":"Quién autorizó la conexión o creó la clave, para que el sitio muestre exactamente a qué cuenta está conectado"},"app_url":{"type":"string"}},"required":["api_key","key_id","workspace","connected_by","app_url"]},"ConnectToken":{"type":"object","properties":{"code":{"type":"string","minLength":10,"maxLength":200},"code_verifier":{"type":"string","pattern":"^[A-Za-z0-9_-]{43,128}$"},"site_url":{"type":"string","maxLength":500}},"required":["code","code_verifier","site_url"]},"ConnectStatus":{"type":"object","properties":{"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"org_name":{"type":"string"}},"required":["id","name","slug","org_name"]},"workspace_url":{"type":"string","description":"Enlace al espacio en la web de Ordyum"},"connected_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"}},"required":["id","name","email"],"description":"Quién autorizó la conexión o creó la clave, para que el sitio muestre exactamente a qué cuenta está conectado"},"app_url":{"type":"string"},"key":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"expires_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","name","prefix","scopes","created_at","expires_at"]}},"required":["workspace","workspace_url","connected_by","app_url","key"]},"CommissionOverview":{"type":"object","properties":{"enabled":{"type":"boolean"},"default_rate_bp":{"type":"integer"},"scope":{"type":"string","enum":["all","own"],"description":"`own`: un comercial solo ve lo suyo"},"stripe":{"type":"object","properties":{"connected":{"type":"boolean"},"source_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"last_received_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_error":{"type":["string","null"]}},"required":["connected","source_id","last_received_at","last_error"]},"reps":{"type":"array","items":{"$ref":"#/components/schemas/CommissionRep"}},"unmatched":{"type":"integer","description":"Cobros sin cliente o sin comercial que esperan a un admin"},"totals":{"type":"object","properties":{"pending":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"amount":{"type":"integer","description":"Unidades mínimas (céntimos)"}},"required":["currency","amount"]},"description":"Un total por moneda"},"paid":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"amount":{"type":"integer","description":"Unidades mínimas (céntimos)"}},"required":["currency","amount"]},"description":"Un total por moneda"},"month":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"amount":{"type":"integer","description":"Unidades mínimas (céntimos)"}},"required":["currency","amount"]},"description":"Un total por moneda"}},"required":["pending","paid","month"]}},"required":["enabled","default_rate_bp","scope","stripe","reps","unmatched","totals"]},"CommissionRep":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"email":{"type":"string"},"avatar_url":{"type":["string","null"],"description":"Foto de perfil lista para `<img>` (subida, ilustrada o del proveedor de acceso); null = iniciales"},"role":{"type":"string","enum":["admin","manager","sales","viewer"]},"joined_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"rate_bp":{"type":["integer","null"],"description":"% propio; null = el por defecto del espacio"},"effective_rate_bp":{"type":"integer","description":"El % que se aplica hoy (0 = no cobra comisión)"},"commission_since":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"clients":{"type":"integer","description":"Contactos de los que es responsable"},"pending":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"amount":{"type":"integer","description":"Unidades mínimas (céntimos)"}},"required":["currency","amount"]},"description":"Un total por moneda"},"paid":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"amount":{"type":"integer","description":"Unidades mínimas (céntimos)"}},"required":["currency","amount"]},"description":"Un total por moneda"},"month":{"type":"array","items":{"type":"object","properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"amount":{"type":"integer","description":"Unidades mínimas (céntimos)"}},"required":["currency","amount"]},"description":"Ganado este mes (neto de devoluciones)"}},"required":["user_id","name","email","avatar_url","role","joined_at","rate_bp","effective_rate_bp","commission_since","clients","pending","paid","month"]},"CommissionPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Commission"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"Commission":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"kind":{"type":"string","enum":["sale","refund"]},"status":{"type":"string","enum":["pending","paid","void"]},"amount":{"type":"integer","description":"Negativo en las devoluciones"},"base_amount":{"type":"integer"},"rate_bp":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"earned_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"paid_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"rep":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"payment":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"external_id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":["string","null"]},"description":{"type":["string","null"]},"product":{"type":["string","null"]},"livemode":{"type":"boolean"}},"required":["id","external_id","name","email","description","product","livemode"]},"note":{"type":["string","null"]}},"required":["id","kind","status","amount","base_amount","rate_bp","currency","earned_at","paid_at","rep","contact","payment","note"]},"CommissionPayoutResult":{"type":"object","properties":{"updated":{"type":"integer"}},"required":["updated"]},"CommissionPayout":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"minItems":1,"maxItems":500},"note":{"type":"string","maxLength":500}},"required":["ids"]},"CommissionUpdate":{"type":"object","properties":{"status":{"type":"string","enum":["pending","void"],"description":"`void` anula una pendiente; `pending` la recupera"},"note":{"type":["string","null"],"maxLength":500}},"required":["status"]},"CustomerPaymentPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomerPayment"}},"next_cursor":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"total":{"type":"integer","description":"Total con los mismos filtros; solo en la primera página (sin `cursor`) de los listados que lo soportan"}},"required":["data","next_cursor"]},"CustomerPayment":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"provider":{"type":"string","enum":["stripe"]},"external_id":{"type":"string"},"email":{"type":["string","null"]},"name":{"type":["string","null"]},"description":{"type":["string","null"]},"product":{"type":["string","null"],"description":"`metadata.ordyum_product` del cobro"},"amount":{"type":"integer"},"amount_refunded":{"type":"integer"},"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"paid_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"status":{"type":"string","enum":["matched","unmatched","ignored"]},"livemode":{"type":"boolean"},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"rep":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"commission":{"type":["object","null"],"properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$","example":"USD"},"amount":{"type":"integer","description":"Unidades mínimas (céntimos)"},"status":{"type":"string","enum":["pending","paid","void"]}},"required":["currency","amount","status"],"description":"Comisión neta del cobro (venta − devoluciones)"}},"required":["id","provider","external_id","email","name","description","product","amount","amount_refunded","currency","paid_at","status","livemode","contact","rep","commission"]},"CustomerPaymentUpdate":{"type":"object","properties":{"contact_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Cliente del cobro; sus cobros siguientes con el mismo cliente de Stripe se asocian solos"},"rep_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Comercial al que se atribuye (por defecto, el responsable del contacto)"},"ignored":{"type":"boolean","description":"No es una venta (p. ej. un cobro interno): sin comisión"}}},"ContactOwnerPeriod":{"type":"object","properties":{"user":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"avatar_url":{"type":["string","null"],"description":"Foto de perfil lista para `<img>` (subida, ilustrada o del proveedor de acceso); null = iniciales"}},"required":["id","name","avatar_url"]},"started_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"ended_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"changed_by":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]}},"required":["user","started_at","ended_at","changed_by"]},"AiStatus":{"type":"object","properties":{"available":{"type":"boolean","description":"El copiloto puede responder (activo, con clave y no desactivado)"},"website_bot":{"type":"boolean","description":"El asistente contesta ahora en el chat de la web (chat activo, clave válida, límite diario sin agotar)"},"configured":{"type":"boolean"},"can_configure":{"type":"boolean"},"name":{"type":["string","null"]},"model":{"type":["string","null"]}},"required":["available","website_bot","configured","can_configure","name","model"]},"AiSettings":{"type":"object","properties":{"enabled":{"type":"boolean"},"has_key":{"type":"boolean"},"key_hint":{"type":["string","null"],"description":"Últimos 4 caracteres de la clave; la clave nunca se devuelve"},"key_status":{"$ref":"#/components/schemas/AiKeyStatus"},"key_checked_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"model":{"type":"string"},"name":{"type":["string","null"]},"tone":{"$ref":"#/components/schemas/AiTone"},"instructions":{"type":"string"},"copilot_enabled":{"type":"boolean"},"widget_enabled":{"type":"boolean"},"widget_token":{"type":"string"},"widget":{"$ref":"#/components/schemas/AiWidgetSettings"},"embed_code":{"type":"string"},"script_url":{"type":"string"},"daily_limit":{"type":"integer"},"usage_today":{"type":"integer","description":"Respuestas del bot en la web hoy (UTC)"},"documents":{"type":"integer"},"knowledge_chars":{"type":"integer"},"last_error":{"type":["string","null"]},"last_error_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["enabled","has_key","key_hint","key_status","key_checked_at","model","name","tone","instructions","copilot_enabled","widget_enabled","widget_token","widget","embed_code","script_url","daily_limit","usage_today","documents","knowledge_chars","last_error","last_error_at","updated_at"]},"AiKeyStatus":{"type":"string","enum":["unverified","valid","invalid","quota"]},"AiTone":{"type":"string","enum":["warm","direct","professional","playful"]},"AiWidgetSettings":{"type":"object","properties":{"color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}$","default":"#4f46e5"},"position":{"type":"string","enum":["right","left"],"default":"right"},"greeting":{"type":["string","null"],"maxLength":300,"default":null},"suggestions":{"type":"array","items":{"type":"string","minLength":1,"maxLength":80},"maxItems":4,"default":[]},"collect_lead":{"$ref":"#/components/schemas/AiLeadMode"},"human_handoff":{"type":"boolean","default":true},"allowed_domains":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(\\*\\.)?([a-z0-9-]+\\.)+[a-z]{2,}$|^localhost$"},"maxItems":20,"default":[],"description":"Vacío = cualquier web. `*.dominio.com` incluye subdominios"},"show_branding":{"type":"boolean","default":true,"description":"Obsoleto: el crédito «Chat de Ordyum» con su logo se muestra siempre (se ignora `false`)"},"track_visitors":{"type":"boolean","default":true,"description":"`chat.js` registra las visitas (sección Visitantes). Nunca con Global Privacy Control activo en el navegador"},"notify_visits":{"$ref":"#/components/schemas/VisitAlerts"}}},"AiLeadMode":{"type":"string","enum":["off","optional","before_chat"],"default":"optional"},"VisitAlerts":{"type":"string","enum":["off","contacts","all"],"default":"all","description":"Aviso al llegar alguien a la web: nadie, solo contactos conocidos o cualquier visita (una por sesión)"},"AiSettingsUpdate":{"type":"object","properties":{"enabled":{"type":"boolean"},"openai_key":{"type":"string","maxLength":300,"pattern":"^sk-[A-Za-z0-9_-]{16,}$","description":"Se guarda cifrada y se verifica contra OpenAI"},"model":{"type":"string","pattern":"^[A-Za-z0-9._:-]{2,64}$"},"name":{"type":["string","null"],"maxLength":60},"tone":{"$ref":"#/components/schemas/AiTone"},"instructions":{"type":"string","maxLength":4000},"copilot_enabled":{"type":"boolean"},"widget_enabled":{"type":"boolean"},"widget":{"$ref":"#/components/schemas/AiWidgetSettings"},"daily_limit":{"type":"integer","minimum":10,"maximum":5000}}},"AiWidgetInfo":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Chat de la web activado en Ordyum"},"token":{"type":["string","null"]},"script_url":{"type":"string"}},"required":["enabled","token","script_url"]},"AiDocumentList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AiDocument"}},"total_chars":{"type":"integer"},"limit":{"type":"integer"}},"required":["data","total_chars","limit"]},"AiDocument":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"title":{"type":"string"},"source":{"type":"string","enum":["text","url"]},"url":{"type":["string","null"]},"chars":{"type":"integer"},"preview":{"type":"string"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","title","source","url","chars","preview","created_at","updated_at"]},"AiDocumentCreate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":160},"content":{"type":"string","minLength":1,"maxLength":60000}},"required":["title","content"]},"AiDocumentImport":{"type":"object","properties":{"url":{"type":"string","maxLength":2000,"format":"uri"},"title":{"type":["string","null"],"maxLength":160}},"required":["url"]},"AiDocumentDetail":{"allOf":[{"$ref":"#/components/schemas/AiDocument"},{"type":"object","properties":{"content":{"type":"string"}},"required":["content"]}]},"AiDocumentUpdate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":160},"content":{"type":"string","minLength":1,"maxLength":60000}}},"AiChatResponse":{"type":"object","properties":{"user_message":{"$ref":"#/components/schemas/AiChatMessage"},"message":{"$ref":"#/components/schemas/AiChatMessage"},"memories_saved":{"type":"array","items":{"type":"string"}}},"required":["user_message","message","memories_saved"]},"AiChatMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"role":{"type":"string","enum":["user","assistant"]},"content":{"type":"string"},"actions":{"type":"array","items":{"$ref":"#/components/schemas/AiAction"}},"suggestions":{"type":"array","items":{"type":"string"}},"feedback":{"type":["integer","null"]},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","role","content","actions","suggestions","feedback","created_at"]},"AiAction":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/AiActionType"},"label":{"type":"string"},"href":{"type":["string","null"],"description":"Ruta del CRM resuelta por el servidor (nunca la inventa el modelo)"},"task":{"type":["object","null"],"properties":{"title":{"type":"string"},"due_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"subject_type":{"type":["string","null"],"enum":["contact","deal",null]},"subject_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["title","due_at","subject_type","subject_id"],"description":"`create_task`: tarea propuesta; se crea al pulsar con `POST /v1/tasks`"}},"required":["type","label","href","task"]},"AiActionType":{"type":"string","enum":["open_contacts","open_contact","open_deals","open_deal","open_tasks","open_inbox","open_reports","open_calendar","create_task"]},"AiChatRequest":{"type":"object","properties":{"message":{"type":"string","minLength":1,"maxLength":2000}},"required":["message"]},"AiHistory":{"type":"object","properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/AiChatMessage"}},"suggestions":{"type":"array","items":{"type":"string"}}},"required":["messages","suggestions"]},"AiFeedback":{"type":"object","properties":{"value":{"anyOf":[{"type":"number","enum":[1]},{"type":"number","enum":[-1]},{"type":"number","enum":[0]}]}},"required":["value"]},"AiMemoryList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AiMemory"}}},"required":["data"]},"AiMemory":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"content":{"type":"string"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["id","content","created_at"]},"PublicChatConfig":{"type":"object","properties":{"workspace":{"type":"string"},"name":{"type":"string"},"greeting":{"type":["string","null"]},"suggestions":{"type":"array","items":{"type":"string"}},"color":{"type":"string"},"position":{"type":"string","enum":["right","left"]},"collect_lead":{"$ref":"#/components/schemas/AiLeadMode"},"human_handoff":{"type":"boolean"},"show_branding":{"type":"boolean","enum":[true],"description":"Siempre true: el chat lleva el logo y el crédito de Ordyum"},"bot_available":{"type":"boolean","description":"false = el equipo responde desde la bandeja (sin clave o límite diario alcanzado)"},"team_online":{"type":"boolean","description":"Alguien del equipo tiene Ordyum abierto ahora mismo"},"country":{"type":["string","null"],"minLength":2,"maxLength":2,"description":"País del visitante (ISO 3166-1) según la IP; el widget elige idioma con él si el navegador no lo indica"},"captcha":{"type":["object","null"],"properties":{"provider":{"type":"string","enum":["turnstile"]},"site_key":{"type":"string"}},"default":null,"required":["provider","site_key"],"description":"Anti-spam de la plataforma. Si una petición responde 428 `chat.captcha_required`, el widget resuelve Turnstile con esta clave y repite la petición con `captcha`. null = desactivado"}},"required":["workspace","name","greeting","suggestions","color","position","collect_lead","human_handoff","show_branding","bot_available","team_online","country"]},"PublicChatThread":{"type":"object","properties":{"visitor_id":{"type":"string","pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/PublicChatMessage"}},"bot_active":{"type":"boolean","description":"true = el asistente de IA responde al próximo mensaje (también cuando cubre al equipo porque no hay nadie conectado)"},"team_online":{"type":"boolean","description":"Alguien del equipo tiene Ordyum abierto ahora mismo"},"has_contact":{"type":"boolean","description":"El visitante ya dejó su nombre y correo o teléfono (la conversación tiene contacto)"},"taken_by":{"type":["string","null"],"default":null,"description":"Nombre de la persona del equipo que se hizo cargo; con ella al mando el asistente deja de responder"}},"required":["visitor_id","messages","bot_active","team_online","has_contact"]},"PublicChatMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"from":{"type":"string","enum":["visitor","bot","agent"]},"body":{"type":"string"},"author":{"type":["string","null"]},"sent_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/PublicChatAttachment"},"default":[]}},"required":["id","from","body","author","sent_at"]},"PublicChatAttachment":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"kind":{"type":"string","enum":["image","video","audio","document","sticker"]},"mime":{"type":"string"},"filename":{"type":["string","null"]},"size":{"type":["integer","null"]},"url":{"type":["string","null"],"description":"Ruta relativa al origen de la API (`/v1/public/chat/{token}/media/{id}?visitor_id=…`)"}},"required":["id","kind","mime","filename","size","url"]},"PublicChatSend":{"type":"object","properties":{"visitor_id":{"type":["string","null"],"pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"body":{"type":"string","minLength":1,"maxLength":2000},"page":{"type":["string","null"],"maxLength":2000},"referrer":{"type":["string","null"],"maxLength":2000},"locale":{"type":["string","null"],"maxLength":10},"lang":{"type":["string","null"],"maxLength":5,"description":"Idioma en el que se muestra el chat (el asistente responde en él)"},"attribution":{"$ref":"#/components/schemas/AttributionInput"},"captcha":{"type":["string","null"],"minLength":1,"maxLength":4096,"description":"Token de Cloudflare Turnstile (tras un 428 `chat.captcha_required`)"}},"required":["body"]},"PublicChatLeadResult":{"type":"object","properties":{"visitor_id":{"type":"string","pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"ok":{"type":"boolean"}},"required":["visitor_id","ok"]},"PublicChatLead":{"type":"object","properties":{"visitor_id":{"type":["string","null"],"pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"name":{"type":"string","minLength":1,"maxLength":200},"email":{"type":["string","null"],"maxLength":320,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"page":{"type":["string","null"],"maxLength":2000},"locale":{"type":["string","null"],"maxLength":10},"attribution":{"$ref":"#/components/schemas/AttributionInput"},"captcha":{"type":["string","null"],"minLength":1,"maxLength":4096,"description":"Token de Cloudflare Turnstile (tras un 428 `chat.captcha_required`)"}},"required":["name"]},"PublicChatTyping":{"type":"object","properties":{"visitor_id":{"type":"string","pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"text":{"type":"string","maxLength":2000,"description":"Lo que el visitante lleva escrito (vacío = dejó de escribir)"}},"required":["visitor_id","text"]},"PublicChatVisitResult":{"type":"object","properties":{"visitor_id":{"type":"string","pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"tracked":{"type":"boolean","description":"false = el espacio no registra visitas"},"conversation":{"type":"boolean","description":"true = ya hay conversación (p. ej. el equipo escribió primero): el widget empieza a consultar mensajes"}},"required":["visitor_id","tracked","conversation"]},"PublicChatVisit":{"type":"object","properties":{"visitor_id":{"type":["string","null"],"pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"kind":{"type":"string","enum":["view","ping"],"description":"`view` = página vista (también en webs de una sola página); `ping` = sigue en la web (cada ~45 s)"},"page":{"type":"string","maxLength":2000},"title":{"type":["string","null"],"maxLength":300},"referrer":{"type":["string","null"],"maxLength":2000},"locale":{"type":["string","null"],"maxLength":10},"attribution":{"$ref":"#/components/schemas/AttributionInput"}},"required":["kind","page"]},"SiteVisitorList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SiteVisitor"}},"online":{"type":"integer"},"last_24h":{"type":"integer"},"tracking":{"type":"boolean","description":"false = el chat de la web está apagado o no registra visitas"}},"required":["data","online","last_24h","tracking"]},"SiteVisitor":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string","description":"Nombre del contacto o «Visitor XXXX»"},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"}},"required":["id","name"]},"conversation_id":{"type":["string","null"],"format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"online":{"type":"boolean","description":"Con la web abierta (latido en los últimos 2 min)"},"page":{"type":["string","null"]},"title":{"type":["string","null"]},"referrer":{"type":["string","null"]},"utm":{"type":["object","null"],"additionalProperties":{"type":"string"}},"device":{"type":["string","null"]},"locale":{"type":["string","null"]},"country":{"type":["string","null"],"description":"ISO 3166-1 alfa-2 según el proxy (Cloudflare), si lo hay"},"sessions":{"type":"integer"},"page_views":{"type":"integer"},"first_seen_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"session_started_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"last_seen_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"pages":{"type":"array","items":{"$ref":"#/components/schemas/VisitorPage"},"description":"Últimas páginas vistas (20 como máximo), la más reciente primero"}},"required":["id","name","contact","conversation_id","online","page","title","referrer","utm","device","locale","country","sessions","page_views","first_seen_at","session_started_at","last_seen_at","pages"]},"VisitorPage":{"type":"object","properties":{"url":{"type":"string"},"title":{"type":["string","null"]},"at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["url","title","at"]},"SiteVisitorMessageResult":{"type":"object","properties":{"conversation_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}},"required":["conversation_id"]},"SiteVisitorMessage":{"type":"object","properties":{"body":{"type":"string","minLength":1,"maxLength":2000}},"required":["body"]},"LandingSummary":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"},"url":{"type":"string","description":"Dirección pública (`/lp/…`)"},"published":{"type":"boolean"},"blocked":{"type":"boolean","description":"Retirada por la plataforma: no se sirve"},"noindex":{"type":"boolean"},"views":{"type":"integer"},"published_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"created_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"},"workspace":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"],"description":"Null = página de la plataforma"}},"required":["id","name","slug","url","published","blocked","noindex","views","published_at","updated_at","created_at","workspace"]},"Landing":{"allOf":[{"$ref":"#/components/schemas/LandingSummary"},{"type":"object","properties":{"html":{"type":"string"},"css":{"type":"string"},"js":{"type":"string"},"seo_title":{"type":["string","null"]},"seo_description":{"type":["string","null"]},"og_image_url":{"type":["string","null"]},"lang":{"type":"string"}},"required":["html","css","js","seo_title","seo_description","og_image_url","lang"]}]},"LandingInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,78}[a-z0-9])?$"},"html":{"type":"string","maxLength":500000,"default":""},"css":{"type":"string","maxLength":200000,"default":""},"js":{"type":"string","maxLength":200000,"default":""},"lang":{"type":"string","pattern":"^[a-z]{2}(-[A-Z]{2})?$","default":"en"},"noindex":{"type":"boolean","default":false},"published":{"type":"boolean","default":false},"seo_title":{"type":["string","null"],"maxLength":120},"seo_description":{"type":["string","null"],"maxLength":320},"og_image_url":{"anyOf":[{"type":"string","enum":[""]},{"type":"string","maxLength":2000,"pattern":"^https:\\/\\/\\S+$"},{"type":"null"}]}},"required":["name","slug"]},"LandingUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,78}[a-z0-9])?$"},"html":{"type":"string","maxLength":500000},"css":{"type":"string","maxLength":200000},"js":{"type":"string","maxLength":200000},"lang":{"type":"string","pattern":"^[a-z]{2}(-[A-Z]{2})?$"},"noindex":{"type":"boolean"},"published":{"type":"boolean"},"seo_title":{"type":["string","null"],"maxLength":120},"seo_description":{"type":["string","null"],"maxLength":320},"og_image_url":{"anyOf":[{"type":"string","enum":[""]},{"type":"string","maxLength":2000,"pattern":"^https:\\/\\/\\S+$"},{"type":"null"}]}}},"LandingBlock":{"type":"object","properties":{"blocked":{"type":"boolean"}},"required":["blocked"]},"WpPluginOverview":{"type":"object","properties":{"latest":{"type":"string","description":"Versión publicada (la que ofrece el actualizador)"},"sites":{"type":"array","items":{"$ref":"#/components/schemas/WpPluginSite"}}},"required":["latest","sites"]},"WpPluginSite":{"type":"object","properties":{"key_id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"site":{"type":["string","null"]},"version":{"type":["string","null"]},"last_used_at":{"type":["string","null"],"format":"date-time","example":"2026-10-06T14:30:00.000Z"},"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]}},"required":["key_id","site","version","last_used_at","workspace"]},"PublicLanding":{"type":"object","properties":{"name":{"type":"string"},"html":{"type":"string"},"css":{"type":"string"},"js":{"type":"string"},"seo_title":{"type":["string","null"]},"seo_description":{"type":["string","null"]},"og_image_url":{"type":["string","null"]},"lang":{"type":"string"},"noindex":{"type":"boolean"},"url":{"type":"string"},"updated_at":{"type":"string","format":"date-time","example":"2026-10-06T14:30:00.000Z"}},"required":["name","html","css","js","seo_title","seo_description","og_image_url","lang","noindex","url","updated_at"]}},"parameters":{}},"paths":{"/v1/public/demo":{"post":{"tags":["Public"],"description":"Abre una demo de 24 h con datos de ejemplo y deja la sesión iniciada (cookie). Sin registro; limitada por IP y con un tope global. Con una demo ya abierta en el navegador, la reutiliza.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DemoStart"}}}},"responses":{"200":{"description":"Existing demo","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DemoStarted"}}}},"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DemoStarted"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/unsubscribe":{"post":{"tags":["Public"],"description":"Enlace de baja de los consejos de puesta en marcha (token firmado del propio correo). Sin sesión.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unsubscribe"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Perfil: nombre, idioma de la interfaz, zona horaria y respuesta a la pregunta de bienvenida (`guide_answer`).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/avatar":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Foto de perfil recortada en el navegador (data URL WebP/JPEG/PNG, máx. 200 KB). Sustituye al avatar ilustrado.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AvatarUpload"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Quita la foto o el avatar ilustrado (vuelven las iniciales).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/avatars/{userId}/{hash}":{"get":{"tags":["Account"],"description":"Público: foto de perfil. La URL incluye el hash del contenido, así que se cachea para siempre.","parameters":[{"schema":{"type":"string"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"hash","in":"path"}],"responses":{"200":{"description":"Image"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/sessions":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Sesiones abiertas de la cuenta (navegadores y apps), la actual marcada con `current`.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MySession"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Cierra sesiones propias: las de `ids` o, sin `ids`, todas menos la actual. La actual nunca se cierra aquí (`session.current`); para eso está cerrar sesión.","parameters":[{"schema":{"type":"string","description":"IDs separados por comas (máx. 200). Sin `ids`: todas menos la actual."},"required":false,"description":"IDs separados por comas (máx. 200). Sin `ids`: todas menos la actual.","name":"ids","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MySession"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/devices":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Dispositivos de confianza: entrar desde ellos no envía el aviso de inicio de sesión. El de esta sesión va primero.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/KnownDevice"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Deja de confiar en dispositivos (`keys`, o todos menos el actual): el próximo inicio de sesión desde ellos vuelve a avisar. No cierra sesiones.","parameters":[{"schema":{"type":"string","description":"Claves separadas por comas (máx. 200). Sin `keys`: todos menos el de esta sesión."},"required":false,"description":"Claves separadas por comas (máx. 200). Sin `keys`: todos menos el de esta sesión.","name":"keys","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/KnownDevice"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/push/config":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Si el servidor envía push y la configuración pública del SDK web de Firebase para suscribir este navegador.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PushConfig"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/push-devices":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Navegadores y apps que reciben push en esta cuenta; el de esta sesión va primero (`current`).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PushDevice"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Registra (o renueva) el token de Firebase de este navegador o app. Queda atado a la sesión: al cerrarla se da de baja solo. Sin Firebase en el servidor responde 409 `push.unavailable`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PushDeviceRegister"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PushDevice"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/push-devices/{id}/test":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Envía un push de prueba a ese navegador o app, en el idioma del usuario. Si Firebase ya no acepta el token, se da de baja y responde 404; un fallo de Firebase responde 502 `push.send_failed`.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/push-devices/{id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Deja de enviar push a ese navegador o app.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/security/not-me":{"post":{"tags":["Account"],"description":"Público (enlace del email de dispositivo nuevo). Cierra todas las sesiones, deja de confiar en ese dispositivo y, si la cuenta tiene contraseña, la invalida y envía el email para elegir otra. Cada enlace vale una vez (`security.link_used`) durante 7 días.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotMeRequest"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotMeResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Alta de agencia: organización + primer workspace + pipeline por defecto en el idioma elegido.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrganizationCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrganizationCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspaces":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Workspace de cliente dentro de la agencia (solo owner/admin de la organización).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspaces/{id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Owner/admin de la agencia: borra el espacio de cliente y todos sus datos. `confirm` debe ser el nombre del espacio (`delete.confirm_mismatch`). Irreversible.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteConfirm"}}}},"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Solo el owner: borra la agencia con todos sus espacios. `confirm` debe ser el nombre de la agencia. Con una suscripción viva responde `organization.active_subscription` (cancélala antes). Irreversible.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteConfirm"}}}},"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/invitations/{token}":{"get":{"tags":["Public"],"description":"Vista previa de una invitación para quien tiene el enlace: agencia, espacios, rol, quién invita, correo enmascarado y estado.","parameters":[{"schema":{"type":"string","maxLength":200},"required":true,"name":"token","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationPreview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/invitations/accept":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationAccept"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceSummary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspace":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. Nombre, moneda, idioma, zona horaria y ajustes del workspace.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceSummary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspace/setup":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Guía del primer día: país del espacio, fuente de leads, equipo, pipeline y anuncios (si el plan los incluye). Cada paso se marca solo a partir de los datos reales; sin país la guía no queda oculta.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceSetup"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. `pipeline_ok` da por buenas las etapas por defecto; `dismissed` oculta o vuelve a mostrar la guía.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceSetupUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceSetup"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organization/security":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Política «2FA obligatorio para administradores» de la agencia del workspace y, para propietarios/admins de la agencia, quién la tiene pendiente.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSecurity"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo propietario/admin de la agencia. Con `require_admin_2fa`, los administradores con contraseña y sin 2FA reciben 403 `auth.two_factor_required` hasta activarlo. Para activarla hace falta tener el 2FA propio (422 `security.enable_2fa_first`).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSecurityUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSecurity"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/members":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Member"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. Crea la cuenta (verificada) de alguien del equipo y lo añade al espacio y, con `workspace_ids`, a otros de la agencia. Sin `password` le llega un email para elegirla. Si el email ya tiene cuenta: 409 `member.email_taken` (hay que invitarlo). Cuenta como plaza (402).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberAccountCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberAccountCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/members/{user_id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. Cambia rol, visibilidad o comisión (`commission_rate_bp` en puntos básicos, null = el por defecto del espacio; `commission_since`). No se puede dejar el workspace sin admins (`member.last_admin`).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"user_id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Member"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Admin quita a un miembro; cualquier miembro puede salir (su propio `user_id`).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"user_id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/invitations":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. Invitaciones pendientes (no aceptadas ni caducadas).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Invitation"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. Envía el email (si hay SMTP) y devuelve el token una vez; la web construye `/invite/{token}`. Reemplaza una invitación pendiente al mismo email.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/invitations/{id}/resend":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. Genera un enlace nuevo (el anterior deja de valer), renueva la caducidad y reenvía el email.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvitationCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/invitations/{id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/api-keys":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/api-keys/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Cambia el nombre o la lista de IPs permitidas. Los permisos y la caducidad no se editan: crea o rota la clave.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKey"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/api-keys/{id}/rotate":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Emite un secreto nuevo con la misma configuración y revoca el anterior al instante. El secreto solo se devuelve aquí.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspace/export":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"summary":"Export all workspace data (ZIP)","description":"ZIP con un CSV por tipo (contactos, empresas, negocios, tareas, actividad) y un README con el recuento. Mismas columnas que la exportación de cada listado (reimportable). Solo administradores; queda en la auditoría.","responses":{"200":{"description":"Archivo","content":{"application/zip":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/custom-fields":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Custom fields"],"description":"Definiciones de campos personalizados (los valores viven en `custom` de cada registro, por clave).","parameters":[{"schema":{"type":"string","enum":["contact","company","deal"]},"required":false,"name":"entity","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Custom fields"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomField"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/custom-fields/order":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Custom fields"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldReorder"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/custom-fields/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Custom fields"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomField"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Custom fields"],"description":"Borra la definición. Los valores ya guardados no se pierden: reaparecen si se vuelve a crear la misma clave.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/saved-views":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Saved views"],"description":"Vistas guardadas de un listado: las propias y las compartidas del espacio.","parameters":[{"schema":{"type":"string","enum":["contact","company","deal"]},"required":true,"name":"entity","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SavedView"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Saved views"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedViewCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedView"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/saved-views/default":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Saved views"],"description":"Vista con la que el usuario abre el listado (propia o compartida). `view_id: null` la quita. Es personal: no cambia la de nadie más.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedViewDefault"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedViewDefault"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/saved-views/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Saved views"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedViewUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedView"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Saved views"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/tags":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tags"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Tag"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tags"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tag"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/tags/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tags"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tag"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tags"],"description":"La quita de todos los registros.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/products":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Products"],"parameters":[{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"include_inactive","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Products"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/products/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Products"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Products"],"description":"Las líneas de negocios existentes conservan nombre y precio.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/bulk":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Hasta 500 registros: cambia responsable, etapa de ciclo de vida (contactos), añade/quita etiquetas o elimina. Los ids fuera de tu visibilidad se omiten.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkAction"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/export":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"CSV (UTF-8 con BOM) con los mismos filtros que el listado, hasta 10 000 filas. Incluye etiquetas y una columna `custom.<clave>` por campo personalizado.","parameters":[{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"company_id","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}],"description":"`me` = registros del usuario autenticado"},"required":false,"description":"`me` = registros del usuario autenticado","name":"owner_id","in":"query"},{"schema":{"type":"string","enum":["lead","prospect","customer","churned","other"]},"required":false,"name":"lifecycle_stage","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"tag_id","in":"query"},{"schema":{"type":"string","enum":["review","no_prefix","invalid"],"description":"`review` = teléfonos sin prefijo o no válidos (no se envían a Google, Meta ni WhatsApp); `no_prefix` / `invalid` por separado"},"required":false,"description":"`review` = teléfonos sin prefijo o no válidos (no se envían a Google, Meta ni WhatsApp); `no_prefix` / `invalid` por separado","name":"phone_status","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies/bulk":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"description":"Hasta 500 registros: cambia responsable, etapa de ciclo de vida (contactos), añade/quita etiquetas o elimina. Los ids fuera de tu visibilidad se omiten.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkAction"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies/export":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"description":"CSV (UTF-8 con BOM) con los mismos filtros que el listado, hasta 10 000 filas. Incluye etiquetas y una columna `custom.<clave>` por campo personalizado.","parameters":[{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}],"description":"`me` = registros del usuario autenticado"},"required":false,"description":"`me` = registros del usuario autenticado","name":"owner_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"tag_id","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/deals/bulk":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"description":"Hasta 500 registros: cambia responsable, etapa de ciclo de vida (contactos), añade/quita etiquetas o elimina. Los ids fuera de tu visibilidad se omiten.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkAction"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/deals/export":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"description":"CSV (UTF-8 con BOM) con los mismos filtros que el listado, hasta 10 000 filas. Incluye etiquetas y una columna `custom.<clave>` por campo personalizado.","parameters":[{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"pipeline_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"stage_id","in":"query"},{"schema":{"type":"string","enum":["open","won","lost"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"owner_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"tag_id","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/{id}/merge":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Fusiona `source_id` en este contacto: mueve negocios, tareas, actividad, atribución y etiquetas, completa los campos vacíos y elimina el duplicado.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactMerge"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/automation-rules":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Smart Rules"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutomationRuleList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Smart Rules"],"description":"Solo admins. `deal.idle` usa `trigger_config.days` (por defecto 5). Máximo 50 reglas por workspace.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutomationRuleCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutomationRule"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/automation-rules/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Smart Rules"],"description":"El disparador no se puede cambiar (sus campos válidos dependen de él): crea otra regla.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutomationRuleUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutomationRule"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Smart Rules"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/automation-runs":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Smart Rules"],"description":"Historial de ejecuciones, más recientes primero.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"rule_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":30},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutomationRunPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/scoring-rules":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Lead scoring"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringRuleList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Lead scoring"],"description":"Solo admins. Cambiar las reglas recalcula las puntuaciones (las primeras 1000 al momento, el resto en segundo plano).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringRuleCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringRule"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/scoring-rules/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Lead scoring"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringRuleUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringRule"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Lead scoring"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/{id}/score":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Lead scoring"],"description":"Puntuación calculada en vivo con el detalle de cada regla que suma o resta.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoreBreakdown"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}],"description":"`me` = registros del usuario autenticado"},"required":false,"description":"`me` = registros del usuario autenticado","name":"owner_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"tag_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"company_id","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}],"description":"`me` = registros del usuario autenticado"},"required":false,"description":"`me` = registros del usuario autenticado","name":"owner_id","in":"query"},{"schema":{"type":"string","enum":["lead","prospect","customer","churned","other"]},"required":false,"name":"lifecycle_stage","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"tag_id","in":"query"},{"schema":{"type":"string","enum":["review","no_prefix","invalid"],"description":"`review` = teléfonos sin prefijo o no válidos (no se envían a Google, Meta ni WhatsApp); `no_prefix` / `invalid` por separado"},"required":false,"description":"`review` = teléfonos sin prefijo o no válidos (no se envían a Google, Meta ni WhatsApp); `no_prefix` / `invalid` por separado","name":"phone_status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Detecta duplicados por email/teléfono normalizado (409 `contact.duplicate`) salvo `?allow_duplicate=true`.","parameters":[{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"allow_duplicate","in":"query"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/phone-fix":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Teléfonos sin prefijo internacional y cómo quedarían con el país del espacio (o con `?country=`). Sin prefijo no se envían a Google, Meta ni WhatsApp. Solo admins.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","pattern":"^[A-Z]{2}$","example":"ES","description":"Probar con otro país antes de guardarlo en el espacio"},"required":false,"description":"Probar con otro país antes de guardarlo en el espacio","name":"country","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhoneFixPreview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Completa con el prefijo del país los teléfonos que lo admiten (todos o `contact_ids`). Los no válidos y los que ya tiene otro contacto se quedan igual. Solo admins; queda en la auditoría.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhoneFixApply"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhoneFixResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/{id}/attribution":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Primer y último touch (UTM, gclid, fbclid, landing) y canal de adquisición derivado.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactAttribution"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/imports/contacts":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Importación en bloque (hasta 2000 filas por petición, CSV ya mapeado). `dry_run` devuelve el resumen sin escribir. Errores por fila; el lote válido se aplica en una sola transacción.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactImport"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactImportResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/imports/companies":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Companies"],"description":"Importación de empresas (migraciones desde HubSpot, Pipedrive o Excel). Deduplica por nombre sin acentos ni mayúsculas, dominio o `external_id`. Mismas reglas de lote y `dry_run` que la importación de contactos.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyImport"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyImportResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/imports/deals":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"description":"Importación de negocios con sus fechas de alta y cierre. Etapa por nombre o estado (`won`/`lost`, «Closed Won»…), empresa por nombre y contacto por email (se crean si no existen). Deduplica por `external_id`. No notifica ni envía conversiones a plataformas de anuncios.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealImport"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealImportResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/pipelines":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Pipeline"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"description":"Solo admins. Etapas por defecto en el idioma del workspace, o copiadas de `copy_from`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PipelineCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/pipelines/reorder":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdsOrder"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Pipeline"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/pipelines/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PipelineUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"description":"Con deals exige `move_to` (409 `pipeline.has_deals`); el último pipeline no se borra (409 `pipeline.last`).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Pipeline destino de sus deals (cada deal va a la primera etapa de su mismo tipo)"},"required":false,"description":"Pipeline destino de sus deals (cada deal va a la primera etapa de su mismo tipo)","name":"move_to","in":"query"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/pipelines/{id}/stages":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"description":"Una etapa abierta se inserta antes de las de cierre.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StageCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/pipelines/{id}/stages/reorder":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdsOrder"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stages/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"description":"El tipo solo cambia en etapas sin deals; el pipeline debe conservar una etapa abierta, una ganada y una perdida.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StageUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Pipelines"],"description":"Con deals exige `move_to` (etapa del mismo pipeline y tipo).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Etapa destino de sus deals (mismo pipeline y mismo tipo); obligatoria si tiene deals"},"required":false,"description":"Etapa destino de sus deals (mismo pipeline y mismo tipo); obligatoria si tiene deals","name":"move_to","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/deals":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"pipeline_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"stage_id","in":"query"},{"schema":{"type":"string","enum":["open","won","lost"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"owner_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"tag_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"description":"Un deal en etapa abierta exige `next_step` (422 `deal.next_step_required`).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/deals/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/deals/{id}/move":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Deals"],"description":"Cambio de etapa. Abierta sin tarea pendiente → `next_step`; perdida → `lost_reason`.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealMove"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/tasks":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tasks"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["open","done","all"],"default":"open"},"required":false,"name":"status","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"}]},"required":false,"name":"assignee","in":"query"},{"schema":{"type":"string","enum":["contact","company","deal"]},"required":false,"name":"subject_type","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"subject_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tasks"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/tasks/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tasks"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tasks"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/tasks/{id}/complete":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tasks"],"description":"Si era la última tarea abierta de un deal abierto, `next_step` encadena la siguiente acción.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskComplete"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCompleted"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/tasks/{id}/reopen":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Tasks"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/activities":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Activities"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["contact","company","deal"]},"required":true,"name":"subject_type","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"subject_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Activities"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/today":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Today"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Today"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/reports/summary":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Reports"],"parameters":[{"schema":{"type":"string","format":"date","example":"2026-11-30"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","example":"2026-11-30"},"required":false,"name":"to","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Summary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/search":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Search"],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":200},"required":true,"name":"q","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/fx":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Reports"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FxRates"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/leads":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Leads"],"summary":"Capture a lead","description":"Para formularios (WordPress, landing pages, Zapier) con una API key `write` desde el servidor. Deduplica por email/teléfono, guarda la atribución (UTM, gclid, fbclid…), crea una tarea de seguimiento y emite `lead.received`. Responde 201 si crea el contacto y 200 si coincide con uno existente. Admite `Idempotency-Key`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadCreate"}}}},"responses":{"200":{"description":"Matched an existing contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadResult"}}}},"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Leads"],"summary":"Record an order","description":"Para tiendas (WooCommerce vía el plugin de WordPress, tiendas propias, pasarelas, Zapier) con una API key `write`. El comprador entra como contacto con la atribución del pedido (sin tarea de seguimiento) y queda una actividad en su ficha. `paid` lo marca como cliente; con `create_deal` crea un negocio ganado, que también se envía como conversión offline a Google Ads / Meta. Deduplica por `source` + `external_id` + estado; admite `Idempotency-Key`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCreate"}}}},"responses":{"200":{"description":"Recorded (or duplicate)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/leads/repeats":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Leads"],"summary":"Ignored repeat submissions","description":"Solo admin. Leads idénticos (mismo contacto, origen y mensaje en menos de 10 min) que se descartaron como reenvío, por origen y los 5 más recientes. Sirve para detectar formularios que envían dos veces.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":90,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadRepeatStats"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks/events":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"summary":"List subscribable event types","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","enum":["contact.created","contact.updated","contact.deleted","company.created","company.updated","company.deleted","deal.created","deal.updated","deal.stage_changed","deal.won","deal.lost","deal.deleted","task.created","task.updated","task.completed","activity.created","lead.received","form.submitted","message.received","message.sent"]}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"description":"Cada entrega es un `POST` JSON `{ id, type, created_at, workspace_id, data }` con las cabeceras `Ordyum-Event`, `Ordyum-Delivery` y `Ordyum-Signature: t=<unix>,v1=<hex>` (HMAC-SHA256 de `\"<t>.<cuerpo>\"` con el secreto). Responde 2xx en menos de 10 s; si no, se reintenta con backoff exponencial durante ~23 h.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEndpoint"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"description":"Devuelve el secreto de firma una sola vez.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpointCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpointCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"description":"`enabled: true` reactiva un endpoint desactivado y reanuda sus entregas pendientes.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpointUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpoint"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks/{id}/rotate-secret":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"description":"El secreto anterior deja de ser válido inmediatamente.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpointCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks/{id}/test":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"summary":"Send a test event","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"202":{"description":"Queued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDelivery"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhooks/{id}/deliveries":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["pending","succeeded","failed"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhook-deliveries/{id}/redeliver":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Webhooks"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"202":{"description":"Queued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDelivery"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions/connections":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"description":"Al ganar un negocio, Ordyum envía la venta a la plataforma con el clic que trajo al lead: Google Ads con gclid/gbraid/wbraid y, con Enhanced Conversions, email/teléfono con hash (respeta `ad_user_data_consent`); Meta (API de conversiones, integración CRM) con `_fbc`/fbclid, `lead_id` de Lead Ads y email/teléfono/nombre con hash. Opcional: etapas abiertas (`stage_ids`) que también se envían como conversión con valor = importe × probabilidad. Solo admins. Los tokens se guardan cifrados y nunca se devuelven.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdConnectionList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions/connections/{platform}":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"description":"Crea o actualiza la conexión. `config` se fusiona con la guardada (`null` borra una clave); `secret` omitido conserva el token.","parameters":[{"schema":{"type":"string","enum":["google_ads","meta"]},"required":true,"name":"platform","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdConnectionUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdConnection"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"description":"Borra la conexión y su token; las conversiones pendientes se cierran como `skipped`.","parameters":[{"schema":{"type":"string","enum":["google_ads","meta"]},"required":true,"name":"platform","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions/connections/{platform}/test":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"summary":"Check credentials","description":"Comprueba el token y que la acción de conversión (Google Ads) o el píxel (Meta) existen. No envía ninguna conversión.","parameters":[{"schema":{"type":"string","enum":["google_ads","meta"]},"required":true,"name":"platform","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdConnectionTest"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions/connections/{platform}/backfill":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"summary":"Send recent won deals","description":"Encola los negocios ganados en los últimos `days` días que aún no se enviaron (Meta: máximo 7 días).","parameters":[{"schema":{"type":"string","enum":["google_ads","meta"]},"required":true,"name":"platform","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdConnectionBackfill"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdConnectionBackfillResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions/uploads":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["google_ads","meta"]},"required":false,"name":"platform","in":"query"},{"schema":{"type":"string","enum":["pending","sent","failed","skipped"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversionUploadPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions/uploads/{id}/retry":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"202":{"description":"Queued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversionUpload"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions/connections/{platform}/sync-spend":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Conversions"],"summary":"Sync ad spend now","description":"Descarga el gasto diario por campaña de los últimos 30 días (Google Ads con la cuenta de cliente; Meta con `ad_account_id` y permiso `ads_read`). El worker lo repite cada 6 h. Responde 200 también si la plataforma falla: `ok: false` y `error`.","parameters":[{"schema":{"type":"string","enum":["google_ads","meta"]},"required":true,"name":"platform","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdSpendSyncResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/reports/ads":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Reports"],"summary":"Ad performance by campaign, ad set and ad","description":"Gasto, clics, leads, cualificados, ventas, CPL, coste por cualificado, CAC y ROAS por campaña de Google Ads y Meta, con desglose por conjunto/grupo y anuncio (`units`). Un lead cuenta para la campaña de su primer touch (`campaign_id` o `utm_campaign` con el id o el nombre). Admins (`audience: team`) y, con la función `client_reports`, el rol viewer como vista de cliente (`audience: client`, sin errores técnicos). Sales: 403.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdsReport"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/reports/ads/export":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Reports"],"summary":"Export ad performance (CSV)","description":"El informe de anuncios como CSV: plataformas, campañas y desglose por conjunto y anuncio. Mismo acceso que `/reports/ads` y, además, la función `report_exports` del plan (402 `plan.feature_unavailable` sin ella).","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"},{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"],"description":"Idioma de las cabeceras (por defecto, el del workspace)"},"required":false,"description":"Idioma de las cabeceras (por defecto, el del workspace)","name":"lang","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/audiences":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Audiences"],"description":"Segmentos del CRM (etapa, etiqueta, puntuación mínima, propietario) que se envían como lista de clientes a Google Customer Match o a Meta Custom Audiences. Solo email y teléfono, normalizados y con SHA-256; los contactos con consentimiento denegado nunca entran. Cada sincronización sustituye la lista entera; el worker la repite cada 24 h. Solo admins.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdAudienceList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Audiences"],"description":"Crea la audiencia. La lista en la plataforma se crea en la primera sincronización. Requiere la función `ads_audiences` y la cuenta publicitaria conectada.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdAudienceCreate"}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdAudience"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/audiences/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Audiences"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdAudienceUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdAudience"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Audiences"],"description":"Borra la audiencia en Ordyum. Por defecto la lista de la plataforma se conserva (puede estar en campañas activas). Con `remote=true` se borra antes en Google Ads / Meta; si la plataforma falla responde 502 `audience.remote_delete_failed` y no se borra nada en Ordyum.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"],"default":"false"},"required":false,"name":"remote","in":"query"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/audiences/{id}/sync":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Audiences"],"summary":"Sync audience now","description":"Envía ya la audiencia. Responde 200 también si la plataforma falla: `ok: false` y `error`.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdAudienceSyncResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/reports":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Reports"],"description":"Informe del periodo (por defecto, últimos 90 días) para un pipeline: totales, win rate, embudo por etapas, pipeline abierto, evolución mensual (12 meses), pronóstico por mes de cierre, rendimiento por responsable, motivos de pérdida, origen de leads y actividad.","parameters":[{"schema":{"type":"string","format":"date","example":"2026-11-30","description":"Por defecto: hace 90 días"},"required":false,"description":"Por defecto: hace 90 días","name":"from","in":"query"},{"schema":{"type":"string","format":"date","example":"2026-11-30","description":"Por defecto: hoy (zona horaria del workspace)"},"required":false,"description":"Por defecto: hoy (zona horaria del workspace)","name":"to","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Por defecto: el pipeline principal"},"required":false,"description":"Por defecto: el pipeline principal","name":"pipeline_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Report"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/reports/export":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Reports"],"description":"El mismo informe como descarga: `csv` (una tabla por sección, importes en decimal) o `pdf` (A4 listo para presentar al cliente).","parameters":[{"schema":{"type":"string","format":"date","example":"2026-11-30","description":"Por defecto: hace 90 días"},"required":false,"description":"Por defecto: hace 90 días","name":"from","in":"query"},{"schema":{"type":"string","format":"date","example":"2026-11-30","description":"Por defecto: hoy (zona horaria del workspace)"},"required":false,"description":"Por defecto: hoy (zona horaria del workspace)","name":"to","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Por defecto: el pipeline principal"},"required":false,"description":"Por defecto: el pipeline principal","name":"pipeline_id","in":"query"},{"schema":{"type":"string","enum":["csv","pdf"],"default":"csv"},"required":false,"name":"format","in":"query"},{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"],"description":"Idioma del documento (por defecto, el del workspace)"},"required":false,"description":"Idioma del documento (por defecto, el del workspace)","name":"lang","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"text/csv":{"schema":{"type":"string"}},"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/notifications":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Notifications"],"description":"Notificaciones del usuario en el workspace actual (más recientes primero) y número de no leídas.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":50,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"unread","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/notifications/read":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Notifications"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationsRead"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationsUnread"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/notification-settings":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Notifications"],"description":"Preferencias del usuario en este workspace: por tipo, aviso in-app y/o email; y si recibe el informe semanal.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationSettings"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Notifications"],"description":"Actualización parcial: solo cambian los tipos y campos enviados.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationSettingsUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationSettings"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/audit-logs":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Workspace"],"description":"Solo admin. Registro inmutable de acciones sensibles del workspace (equipo, API keys, webhooks, borrados, importaciones…).","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":60,"description":"Acción exacta o prefijo (`member.`); varias separadas por comas"},"required":false,"description":"Acción exacta o prefijo (`member.`); varias separadas por comas","name":"action","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"actor_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuditPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/overview":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformOverview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/workspaces":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Todos los espacios de todas las agencias, con uso","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"org_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminWorkspacePage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/contacts":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Contactos y leads de todas las agencias (búsqueda por nombre, email o teléfono)","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"org_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"workspace_id","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"channel","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminContactPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/deals":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Negocios de todas las agencias","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"org_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"workspace_id","in":"query"},{"schema":{"type":"string","enum":["open","won","lost"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminDealPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/organizations":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["active","trial","suspended","paying","past_due"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/organizations/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Plan, fin de prueba y suspensión. Suspender corta el acceso de todos sus workspaces y API keys (403 `organization.suspended`).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Borra la agencia, sus workspaces y datos. 409 `organization.active_subscription` si tiene una suscripción viva en Stripe.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["active","suspended","admins"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Crea una cuenta (verificada). Sin `password` se le envía un email para crearla. Con `workspace_id` entra en ese workspace (y en su agencia como `member`), respetando el límite de plazas del plan (402).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Nombre, email (único; uno nuevo queda sin verificar salvo `email_verified`), idioma, zona horaria, acceso de admin de plataforma y suspensión (suspender cierra todas sus sesiones).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Borra la cuenta. Sus registros del CRM quedan sin asignar. 409 `admin.last_owner` / `member.last_admin` si dejaría una agencia sin owner o un workspace sin admin: cambia esos roles antes.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}/password":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Fija una contraseña nueva y cierra todas sus sesiones.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserPassword"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}/password-reset":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Envía el email de restablecimiento de contraseña (enlace válido 1 h).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordResetSent"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}/sessions":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Cierra todas sus sesiones (en todos los dispositivos) o solo las de `ids` (separados por comas, máx. 200).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string"},"required":false,"name":"ids","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}/sessions/{session_id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"session_id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}/organizations/{org_id}":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Añade a la agencia con ese rol o lo cambia. Una agencia conserva siempre al menos un owner.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"org_id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgMembershipInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Lo quita de la agencia y de todos sus workspaces.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"org_id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}/workspaces/{workspace_id}":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Añade al workspace (y a su agencia si hacía falta) o cambia rol y visibilidad.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"workspace_id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminWorkspaceMembershipInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"workspace_id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminUserDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/workspaces/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Nombre, dirección (slug), moneda, idioma, zona horaria y días para considerar un negocio estancado.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminWorkspaceUpdate"}}}},"responses":{"204":{"description":"Updated"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Borra el workspace con todos sus datos del CRM. Irreversible.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/users/{id}/impersonate":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Soporte: «ver como este usuario» durante 30 min en solo lectura (toda escritura devuelve 403 `impersonation.read_only`). Se registra en la auditoría. Fija una cookie HttpOnly firmada; terminar con `DELETE /admin/impersonation`.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationStarted"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/impersonation":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Termina la suplantación activa (idempotente) y lo registra en la auditoría.","responses":{"204":{"description":"Ended"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/audit-logs":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":60,"description":"Acción exacta o prefijo (`member.`); varias separadas por comas"},"required":false,"description":"Acción exacta o prefijo (`member.`); varias separadas por comas","name":"action","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"actor_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"org_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuditPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/system":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemHealth"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/backups":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Estado de las copias de seguridad","description":"Último backup y si está en el bucket externo, último simulacro de restauración y copias locales y externas. Lo lee de los archivos de estado que deja el contenedor de backups; el API no accede a los dumps ni a las claves del bucket. `stale` = ningún backup correcto en las últimas `stale_after_hours` horas.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BackupStatus"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/vitals":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Core Web Vitals de campo","description":"Percentil 75 de LCP, INP, CLS, FCP y TTFB medidos en visitas reales (últimos `days` días, 7 por defecto) y las rutas más lentas.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebVitalsSummary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/vitals":{"post":{"tags":["Public"],"description":"Métricas Web Vitals de una visita (la web las envía al salir de la página). Anónimas: no se guarda usuario ni IP, y los ids de la ruta se sustituyen por `[id]`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebVitalsReport"}}}},"responses":{"204":{"description":"Recorded"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/system/reset":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Qué borraría el reinicio de datos","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformResetPreview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Reinicia los datos de la plataforma conservando las cuentas","description":"Borra todas las agencias (espacios, CRM, bandeja, cobros, comisiones, asistente…), las colas y, si se pide, las solicitudes de contacto, la auditoría y las cuentas que no son admin de plataforma (`include_users`, desactivado por defecto). Conserva los admins, sus sesiones y 2FA, planes, configuración, marca y testimonios. Exige escribir `RESET` y la contraseña del operador; queda auditado como `platform.data_reset`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformResetInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformResetResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/maintenance":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Maintenance"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Activa o desactiva el modo mantenimiento","description":"Con el modo activo, la API responde 503 `maintenance` a todos menos a los admins de plataforma y la web lleva también sus páginas públicas a /maintenance. Siguen abiertos los endpoints públicos (formularios embebidos, estado) y los webhooks entrantes.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MaintenanceUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Maintenance"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/testimonials":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Testimonial"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Cita de un cliente real. `consent_note` recoge cómo dio permiso (obligatorio). Solo sale en la web si `published`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestimonialInput"}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Testimonial"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/testimonials/{id}":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestimonialInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Testimonial"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/testimonials":{"get":{"tags":["Public"],"description":"Testimonios publicados para un idioma (los escritos en él y los marcados para todos). Vacío mientras no haya ninguno.","parameters":[{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"required":false,"name":"locale","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PublicTestimonial"}}}}}}}},"/v1/public/testimonials/{id}/logo/{hash}":{"get":{"tags":["Public"],"description":"Logo de la empresa de un testimonio publicado. La URL lleva el hash del contenido: se cachea para siempre.","parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","maxLength":64},"required":true,"name":"hash","in":"path"}],"responses":{"200":{"description":"Image"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/config":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Servicios de la plataforma. Los secretos nunca se devuelven: solo si hay valor y sus últimos caracteres.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformConfig"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/config/{section}":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Guarda una sección de la configuración","description":"Se aplica al momento en este proceso y en el resto en menos de 30 s. Secretos: ausente = se conserva, `null` = se borra. Todo vacío = servicio desactivado. Stripe y PayPal: basta con las claves; el webhook (secreto o ID) y el entorno de PayPal se obtienen del proveedor si llegan vacíos.","parameters":[{"schema":{"type":"string","enum":["email","push","stripe","paypal","google_ads","inbox_oauth","meta_messaging","social_login","cdn","captcha"]},"required":true,"name":"section","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformConfigUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformConfig"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Vuelve a las variables de entorno","parameters":[{"schema":{"type":"string","enum":["email","push","stripe","paypal","google_ads","inbox_oauth","meta_messaging","social_login","cdn","captcha"]},"required":true,"name":"section","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformConfig"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/config/{section}/test":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Comprueba una sección","description":"Correo: envía un mensaje de prueba (por defecto al propio admin). El resto valida las credenciales contra el proveedor sin crear nada.","parameters":[{"schema":{"type":"string","enum":["email","push","stripe","paypal","google_ads","inbox_oauth","meta_messaging","social_login","cdn","captcha"]},"required":true,"name":"section","in":"path"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformConfigTest"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformConfigTestResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/config/cdn/purge":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Vacía la caché de Cloudflare","description":"Purga toda la zona configurada en la sección CDN (necesita Zone ID y un token con permiso «Cache Purge»). Queda auditado como `platform.cdn_purged`.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformConfigTestResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/mail-templates":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Plantillas de correo","description":"Todas las plantillas con su categoría, los idiomas con textos editados y el remitente de cada categoría.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplateList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/mail-templates/{key}/{locale}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Textos y vista previa de una plantilla","description":"Copia de serie con `{variable}`, textos guardados y el correo de ejemplo tal como sale ahora.","parameters":[{"schema":{"type":"string","pattern":"^[a-z0-9_.]{2,80}$"},"required":true,"name":"key","in":"path"},{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"required":true,"name":"locale","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplateDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Guarda los textos de una plantilla","description":"Solo se guardan los campos que cambian respecto a la copia de serie. Se aplica al momento; el worker lo recoge en menos de 30 s. Auditado.","parameters":[{"schema":{"type":"string","pattern":"^[a-z0-9_.]{2,80}$"},"required":true,"name":"key","in":"path"},{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"required":true,"name":"locale","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplateTexts"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplateDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Vuelve a los textos de serie","parameters":[{"schema":{"type":"string","pattern":"^[a-z0-9_.]{2,80}$"},"required":true,"name":"key","in":"path"},{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"required":true,"name":"locale","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplateDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/mail-templates/{key}/{locale}/preview":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Vista previa con textos sin guardar","parameters":[{"schema":{"type":"string","pattern":"^[a-z0-9_.]{2,80}$"},"required":true,"name":"key","in":"path"},{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"required":true,"name":"locale","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplatePreviewInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplatePreview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/mail-templates/{key}/{locale}/test":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Envía la plantilla de ejemplo","description":"Con los datos de ejemplo y, si se pasan, los textos sin guardar. Sale con el remitente de su categoría; por defecto al propio admin.","parameters":[{"schema":{"type":"string","pattern":"^[a-z0-9_.]{2,80}$"},"required":true,"name":"key","in":"path"},{"schema":{"type":"string","enum":["en","es","fr","de","it","pt","nl","pl","tr","ar","fa"]},"required":true,"name":"locale","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplateTestInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MailTemplateTestResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/status":{"get":{"tags":["Public"],"description":"Estado público: versión y modo mantenimiento. La página de mantenimiento lo consulta para volver sola.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicStatus"}}}}}}},"/v1/public/geo":{"get":{"tags":["Public"],"description":"País aproximado del visitante por su IP (cabecera del CDN, p. ej. `CF-IPCountry`). El alta lo usa para proponer país y moneda; null sin un proxy de confianza delante.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicGeo"}}}}}}},"/v1/public/auth-providers":{"get":{"tags":["Public"],"description":"Proveedores de «Continuar con…» activos. Las páginas de acceso y registro solo muestran estos botones.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthProviders"}}}}}}},"/v1/public/uptime":{"get":{"tags":["Public"],"description":"Página de estado: situación actual (API, base de datos, tareas en segundo plano, copias de seguridad) y disponibilidad diaria de los últimos 90 días. Muestras cada 5 minutos; un tramo sin muestra cuenta como caída. Caché de 60 s.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicUptime"}}}}}}},"/v1/public/subprocessors":{"get":{"tags":["Public"],"description":"Servicios de terceros activos en esta instalación (pagos, push, CDN, copias externas, correo, acceso social, bandejas, Google Ads). Solo indicadores: ninguna credencial.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicSubprocessors"}}}}}}},"/v1/public/branding":{"get":{"tags":["Public"],"description":"Identidad pública del CRM. La web la lee al renderizar (metadatos, logo, favicon, tema e idioma por defecto) y para mostrar u ocultar el registro.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Branding"}}}}}}},"/v1/public/brand/{kind}/{hash}":{"get":{"tags":["Public"],"description":"Logo o favicon subido en la consola. La URL lleva el hash del contenido: se cachea para siempre.","parameters":[{"schema":{"type":"string","enum":["logo_light","logo_dark","favicon"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","maxLength":64},"required":true,"name":"hash","in":"path"}],"responses":{"200":{"description":"Image"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/branding":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminBranding"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Cambia nombre, eslogan, registro, idioma o tema por defecto","description":"Solo los campos enviados. `tagline` vacío o `null` vuelve al eslogan de serie; `default_locale: null` usa el idioma del navegador.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrandingUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminBranding"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/branding/{kind}":{"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Sube un logo o el favicon","description":"Data URL PNG, WebP o JPEG (el favicon admite también ICO). El tipo se comprueba por el contenido; SVG no se acepta.","parameters":[{"schema":{"type":"string","enum":["logo_light","logo_dark","favicon"]},"required":true,"name":"kind","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrandAssetUpload"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminBranding"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"summary":"Vuelve al logo o favicon de serie","parameters":[{"schema":{"type":"string","enum":["logo_light","logo_dark","favicon"]},"required":true,"name":"kind","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminBranding"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/payments/summary":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Cifras exactas del libro de cobros (sumas de filas, sin estimaciones): cobrado, reembolsado, fallos, por pasarela, por plan, últimos 12 meses y suscripciones por plan y estado.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPaymentSummary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/payments":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Todos los cobros, fallos y reembolsos de todas las agencias, del más reciente al más antiguo.","parameters":[{"schema":{"type":"string"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":30},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"org_id","in":"query"},{"schema":{"type":"string","enum":["stripe","paypal"]},"required":false,"name":"provider","in":"query"},{"schema":{"type":"string","enum":["succeeded","failed","refunded","pending"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["charge","refund"]},"required":false,"name":"kind","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPaymentPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/plans":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Catálogo completo (también ocultos y retirados) con agencias por plan y el estado del price en Stripe.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AdminPlan"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPlanCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPlan"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/plans/stripe-sync":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Crea en Stripe los prices que faltan (base y anual) de cada plan de pago y sustituye los que no coinciden con su importe; los anteriores siguen reconociéndose para las suscripciones existentes.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanStripeSync"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/plans/{id}/rename":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Cambia el código del plan y lo actualiza en agencias, cobros y solicitudes. El de prueba conserva el suyo (409 `plan.trial_code_locked`).","parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"required":true,"description":"Código estable del plan (minúsculas, números y _)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPlanRename"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPlan"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/plans/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Los límites nuevos se aplican al instante a las altas futuras; lo existente no se borra.","parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"required":true,"description":"Código estable del plan (minúsculas, números y _)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPlanUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPlan"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Solo planes sin agencias (409 `plan.in_use`); el de prueba no se borra.","parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,39}$","example":"agency","description":"Código estable del plan (minúsculas, números y _)"},"required":true,"description":"Código estable del plan (minúsculas, números y _)","name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Plan y estado de facturación de la agencia del workspace. Responde también con la agencia suspendida (para poder pagar).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingInfo"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/checkout":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin de la agencia. Crea una sesión de Stripe Checkout para suscribirse al plan y devuelve su URL.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingCheckout"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingRedirect"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/portal":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Portal de cliente de Stripe: cambiar plan, método de pago, facturas y cancelación.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingRedirect"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/payments":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Historial de cobros, fallos y reembolsos de la agencia tal como los registró la pasarela (Stripe/PayPal), con enlace al recibo.","parameters":[{"schema":{"type":"string"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":30},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/paypal/confirm":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Al volver de PayPal: sincroniza la suscripción aprobada (solo si pertenece a esta agencia) sin esperar al webhook.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaypalConfirm"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingStatusResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/cancel":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Cancela al final del periodo pagado: Stripe con `cancel_at_period_end` (reanudable con `/billing/resume`); PayPal se cancela allí y una nueva suscripción no cobra hasta que acabe lo pagado.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingStatusResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/resume":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Reanuda una suscripción de Stripe cancelada al final del periodo (sin cobro nuevo).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingStatusResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/change/preview":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Lo que Stripe cobraría hoy (prorrateo e impuestos) o dejaría a favor al cambiar de plan o de periodo.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanChangeInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanChangePreview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/change":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Cambia de plan al momento con prorrateo (`proration_date` de la vista previa). Si el banco pide autenticación, `payment_required` + `invoice_url` y el plan cambia al pagar.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanChangeApply"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanChangeResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/extras/preview":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Lo que Stripe cobraría hoy (prorrateo e impuestos) por dejar los extras (usuarios, espacios, paquetes de contactos) en estas cantidades.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BillingExtras"},{"description":"Extras contratados; se cobran en la suscripción de Stripe junto con el plan"}]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtrasPreview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/extras":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Cambia los extras al momento: se cobra hoy la parte proporcional y desde la renovación van en la cuota. Si el banco pide autenticación, `payment_required` + `invoice_url`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtrasApply"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtrasResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/details":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Datos de facturación guardados en Stripe: nombre, país, dirección y CIF/NIF (con su verificación).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingDetails"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Billing"],"description":"Owner/admin. Guarda los datos fiscales en el cliente de Stripe; con Stripe Tax el impuesto de las facturas sale de aquí.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingDetailsUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingDetails"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/plans":{"get":{"tags":["Billing"],"description":"Público (sin sesión): planes contratables con precios, límites y textos en/es/fr, y la prueba gratuita. Lo usa la landing.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicPlans"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbound-sources":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbound"],"description":"Plataformas que envían leads sin código. **Google Ads**: formularios de clientes potenciales → pega la URL y la clave en «Integración de CRM / webhook» del formulario. **Meta Lead Ads**: en tu app de Meta, Webhooks → Page → campo `leadgen`, con la URL y el token de verificación de la fuente; Ordyum lee cada lead con el token de página. **Shopify**: Ajustes → Notificaciones → Webhooks, temas `customers/create`, `orders/create` y `orders/paid` en JSON, y pega aquí la clave de firma de la tienda. **Stripe** (cuenta del cliente, para comisiones): Developers → Webhooks → endpoint con la URL, eventos `charge.succeeded`, `charge.refunded`, `checkout.session.completed` e `invoice.paid`; pega aquí su secreto de firma (`whsec_…`). Una por espacio.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/InboundSource"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbound"],"description":"Devuelve la clave completa una sola vez (Google Ads la genera Ordyum; Shopify usa la de la tienda).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundSourceCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundSourceCreated"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbound-sources/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbound"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundSourceUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundSource"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbound"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbound-sources/{id}/test":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbound"],"summary":"Check a Meta Lead Ads source","description":"Comprueba el token de página y suscribe la app de Meta a los leads de la página (`subscribed_apps`, campo `leadgen`).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundSourceTest"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbound-sources/{id}/import":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbound"],"summary":"Import recent Meta leads","description":"Trae los leads de todos los formularios de la página de los últimos `days` días (máx. 2000). Los ya recibidos no se duplican.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundImport"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundImportResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/contact":{"post":{"tags":["Public"],"description":"Formulario de ventas/demo de la web. Sin sesión; limitado por IP y por email. Avisa a la plataforma y envía acuse al remitente.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactRequestCreate"}}}},"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/feedback":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Feedback desde la app (se pierde, va lento, falta o sobra algo, fallo). Requiere sesión de usuario; llega a la consola con agencia, espacio y pantalla.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactRequest"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/support":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Solicitud de soporte con sesión de usuario: llega a la consola con asunto, categoría y el espacio (si es miembro). Envía acuse al usuario.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupportRequestCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SupportRequest"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Account"],"description":"Mis solicitudes de soporte (las 50 más recientes) con su estado.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SupportRequest"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/contact-requests":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["new","contacted","closed"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["sales","demo","partnership","support","privacy","feedback"]},"required":false,"name":"topic","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactRequestPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/contact-requests/counts":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactRequestCounts"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/contact-requests/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactRequestUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactRequest"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/templates":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Templates"],"parameters":[{"schema":{"$ref":"#/components/schemas/MessageChannel"},"required":false,"name":"channel","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MessageTemplate"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Templates"],"description":"Variables: `{{contact.first_name}}`, `{{contact.full_name}}`, `{{company.name}}`, `{{deal.title}}`, `{{deal.amount}}`, `{{user.name}}`, `{{workspace.name}}`…","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageTemplateCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageTemplate"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/templates/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Templates"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageTemplateUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageTemplate"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Templates"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/templates/{id}/render":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Templates"],"description":"Resuelve las variables para un contacto o negocio (con la visibilidad del usuario).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateRenderInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateRendered"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/templates/preview":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Templates"],"description":"Previsualiza `subject`/`body` sin guardar (editor).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateRenderInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateRendered"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/forms":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Forms"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/HostedForm"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Forms"],"description":"Solo admins. Cada envío crea o actualiza el contacto (lead) con la atribución UTM de la página.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HostedFormCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HostedForm"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/forms/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Forms"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HostedFormUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HostedForm"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Forms"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/forms/{token}":{"get":{"tags":["Public"],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicForm"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/forms/{token}/submit":{"post":{"tags":["Public"],"description":"Sin sesión. Limitado por IP y formulario. Campo trampa `website` y tiempo mínimo de relleno contra bots.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicFormSubmit"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicFormResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/calendar":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Calendar"],"description":"Tareas, reuniones y cierres previstos entre `from` y `to` (máx. 62 días).","parameters":[{"schema":{"type":"string","format":"date"},"required":true,"name":"from","in":"query"},{"schema":{"type":"string","format":"date"},"required":true,"name":"to","in":"query"},{"schema":{"type":"string","enum":["true","false"],"description":"`true` = solo lo asignado al usuario"},"required":false,"description":"`true` = solo lo asignado al usuario","name":"mine","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalendarResponse"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/calendar/meetings/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Calendar"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"occurred_at":{"type":"string","format":"date-time"}},"required":["occurred_at"]}}}},"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/calendar/feed":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Calendar"],"description":"URL privada ICS (Google Calendar, Outlook, Apple).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalendarFeed"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/calendar/feed/rotate":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Calendar"],"description":"Invalida la URL anterior.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalendarFeed"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/dashboard":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Dashboard"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardLayout"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Dashboard"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardLayout"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardLayout"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dashboard/hot-leads":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Dashboard"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dashboard/activity":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Dashboard"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/RecentActivity"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/channels":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/InboxChannel"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"**email**: buzón IMAP/SMTP personal (se prueba la conexión antes de guardar). **whatsapp**: número de WhatsApp Cloud API (solo admins); pega la `webhook_url` y el `verify_token` devueltos en la app de Meta y suscribe el campo `messages`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxChannelCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxChannel"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/channels/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxChannelUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxChannel"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/channels/{id}/sync":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxSyncResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/oauth/providers":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Proveedores con los que se puede conectar un buzón sin contraseña (Gmail / Microsoft 365).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxOAuthProviders"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/oauth/{provider}/start":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Devuelve la URL de consentimiento de Google o Microsoft. Tras aceptar, el proveedor vuelve a `/v1/hooks/inbox-oauth/{provider}/callback`, que crea el buzón (o reconecta `channel_id`) y redirige a Ajustes → Canales con `inbox_oauth=connected|denied|failed|…`.","parameters":[{"schema":{"type":"string","enum":["google","microsoft"]},"required":true,"name":"provider","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxOAuthStart"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxOAuthRedirect"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/meta/start":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Devuelve la URL de «Continuar con Facebook» (app de Meta de la plataforma). Tras aceptar, Meta vuelve a `/v1/hooks/meta/oauth`, que guarda las páginas autorizadas 30 min y redirige a Ajustes → Canales con `meta_connect={id}` para elegir cuáles conectar.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxOAuthRedirect"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/meta/requests/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Páginas de Facebook (y su cuenta profesional de Instagram) que el usuario autorizó, con lo que ya está conectado aquí o en otro espacio.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetaConnectRequest"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/meta/requests/{id}/connect":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Conecta Messenger y/o Instagram de las páginas elegidas: suscribe la app a cada página y crea (o reconecta) los canales compartidos.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetaConnectInput"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetaConnectResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/channels/{id}/whatsapp-templates":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Plantillas aprobadas por Meta del número (requiere `waba_id`). Se envían con `whatsapp_template` en el mensaje, también fuera de la ventana de 24 h.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsAppTemplateList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/conversations":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"channel_id","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"unread","in":"query"},{"schema":{"type":"string","enum":["mine","unassigned","waiting_us","waiting_customer","snoozed","closed","all"],"description":"Vista del smart inbox; sin vista = abiertas y no pospuestas"},"required":false,"description":"Vista del smart inbox; sin vista = abiertas y no pospuestas","name":"view","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Primer mensaje a un contacto. En WhatsApp, fuera de la ventana de 24 h Meta exige una plantilla aprobada (`whatsapp_template`); sin ella se rechaza con `inbox.window_closed`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewConversation"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"conversation_id":{"type":"string"},"message":{"$ref":"#/components/schemas/Message"}},"required":["conversation_id","message"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/conversations/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Últimos 200 mensajes; marca la conversación como leída.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Asignar, cerrar / reabrir o posponer una conversación.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Conversation"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/conversations/{id}/messages":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageSend"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/uploads":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Sube un adjunto para enviarlo después con `attachment_id` (JPG o PNG hasta 5 MB, PDF o vídeo MP4 hasta 16 MB). Si no se envía, se borra a las 24 h.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"}}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageAttachment"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/attachments/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Contenido de un adjunto (foto, audio, vídeo o documento). `?download=1` fuerza la descarga. Admite `Range`.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["1"]},"required":false,"name":"download","in":"query"},{"schema":{"type":"string"},"required":false,"name":"workspace","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"application/octet-stream":{"schema":{}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/revenue/campaign":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Campaña → ingresos: gasto, clics, leads, contactados, cualificados, oportunidades, propuestas, clientes e ingresos, con CPL, CAC, ROAS y tasa de cierre.","parameters":[{"schema":{"type":"string","enum":["google_ads","meta"]},"required":true,"name":"platform","in":"query"},{"schema":{"type":"string","maxLength":100},"required":false,"name":"campaign_id","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Nombre de campaña (filas sin id de plataforma)"},"required":false,"description":"Nombre de campaña (filas sin id de plataforma)","name":"campaign","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CampaignJourney"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/{id}/journey":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Recorrido del lead: anuncio, visitas, formulario, primera respuesta, mensajes, actividades, negocio, etapas y venta.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactJourney"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/deals/{id}/replay":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Audit replay: cambios de etapa, importe, responsable y fecha de cierre (de → a), contactos, tareas y automatizaciones; tiempo en cada etapa.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealReplay"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/insights/attribution":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Leads, ventas e ingresos por canal: primer touch frente al touch que convirtió.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttributionCompare"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/insights/leaks":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Revenue Leak Detector: negocios sin seguimiento, leads sin contactar, propuestas paradas, gasto sin leads cualificados (admin), negocios sin tarea y clientes sin respuesta.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeakReport"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/insights/speed":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Speed-to-lead: % dentro del SLA, mediana de respuesta, por responsable y canal, distribución y últimos leads.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpeedReport"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/insights/pipeline-health":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Salud del pipeline 0–100 con cada componente (cobertura, estancados, sin tarea, win rate, ciclo) y reparto de deal rot.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"pipeline_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PipelineHealth"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/insights/lost":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Lost intelligence: motivos estructurados y su reparto por vendedor, canal, campaña o producto, con hallazgos.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":365,"default":90},"required":false,"name":"days","in":"query"},{"schema":{"type":"string","enum":["owner","channel","campaign","product"],"default":"owner"},"required":false,"name":"by","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LostAnalysis"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/insights/score":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Revenue"],"description":"Ordyum Score semanal (0–100): velocidad de respuesta, seguimiento, higiene, conversión y velocidad del pipeline; variación frente a la semana anterior.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrdyumScore"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/portal/summary":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"description":"Portal del cliente: resumen mensual (inversión, leads, atendidos, cualificados, clientes, ingresos, ROAS/CPL/CAC). Viewer: requiere informes para clientes en el plan.","parameters":[{"schema":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$","description":"YYYY-MM en la zona del workspace (por defecto, el mes actual)"},"required":false,"description":"YYYY-MM en la zona del workspace (por defecto, el mes actual)","name":"month","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortalSummary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/portal/shares":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"description":"Enlaces de solo lectura al informe del cliente: vivos y los caducados o revocados de los últimos 30 días. Solo admins.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortalShareList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"description":"Crea un enlace de solo lectura que caduca a los 7, 30 o 90 días (mes fijo o siempre el mes en curso). Solo admins con informes para clientes en el plan.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortalShareCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortalShareLink"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/portal/shares/{id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"description":"Revoca el enlace al momento: quien lo abra verá que ya no está disponible.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/portal/{token}":{"get":{"tags":["Public"],"description":"Sin sesión. Informe del cliente por enlace compartido (solo lectura; nombres de leads abreviados). 404 si no existe, caducó o se revocó.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicPortal"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/agency/overview":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"description":"Agency Command Center: todos los workspaces de la agencia y qué requiere atención. Solo owner/admin de la agencia.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"org_id","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"},{"schema":{"type":"string","enum":["true","false"],"description":"`true` recalcula ahora en vez de servir la foto en caché (hasta 5 min)"},"required":false,"description":"`true` recalcula ahora en vez de servir la foto en caché (hasta 5 min)","name":"refresh","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgencyOverview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspace-templates":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"description":"Plantillas de configuración de la agencia (solo owner/admin).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"org_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceTemplateList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"description":"Guarda la configuración del workspace actual (pipelines, campos, etiquetas, productos, reglas, plantillas, formularios y ajustes; nunca datos) como plantilla de la agencia.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceTemplateCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceTemplate"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspace-templates/{id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Agency"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/counts":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Contadores de las vistas del smart inbox.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxCounts"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/conversations/{id}/typing":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Chat de la web: lo que el visitante está escribiendo ahora, sin enviar (`text: null` si nada). Se pide al recibir la señal `inbox` con `kind: typing`.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationTyping"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"El agente escribe en un chat de la web: el visitante ve «{nombre} está escribiendo…». Llamar como mucho cada 3 s.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/conversations/{id}/notes":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Nota interna del equipo (nunca se envía al cliente).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationNoteCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationNote"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/inbox/conversations/{id}/presence":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Latido de presencia (~20 s con la conversación abierta); devuelve quién más la está viendo.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationPresence"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Inbox"],"description":"Deja de figurar como «viendo». Admite `fetch(…, {keepalive: true})` al cerrar la pestaña.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/connect/info":{"get":{"tags":["Connect"],"summary":"Where to send the user to connect","description":"Público. Devuelve la web donde el usuario autoriza la conexión (en instalaciones propias puede ser otro dominio que el API).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectInfo"}}}}}}},"/v1/connect/authorize":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Connect"],"summary":"Authorize a plugin","description":"Solo admin del espacio, con sesión (no API key). Crea un código de un solo uso (10 min) ligado al sitio, a la URL de vuelta (mismo dominio que `site_url`; https salvo localhost/*.local/*.test) y al `code_challenge` PKCE.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectAuthorize"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectAuthorized"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/connect/token":{"post":{"tags":["Connect"],"summary":"Exchange the code for an API key","description":"Público, servidor a servidor, limitado por IP. Canjea el código con el `code_verifier` y devuelve una API key de lectura y escritura exclusiva del sitio (`WordPress · dominio`). Reconectar el mismo sitio revoca su clave anterior. Cualquier fallo responde `connect.code_invalid`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectToken"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectTokenResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/connect/me":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Connect"],"summary":"Connection status for the current API key","description":"Con API key: espacio, agencia y datos de la clave. 401 `api_key.invalid` si se revocó.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectStatus"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Connect"],"summary":"Disconnect (revoke the current API key)","responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/commissions/overview":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Commissions"],"description":"Comisiones de los comerciales sobre los cobros de la cuenta de Stripe del espacio (fuente entrante `stripe`). Admin: configuración, todos los comerciales con su %, clientes y totales por moneda. Ventas/Gestor: solo lo suyo (`scope: own`).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommissionOverview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/commissions":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Commissions"],"description":"Movimientos (venta y devolución) del más reciente al más antiguo. Un comercial solo ve los suyos.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Solo admins; un comercial siempre ve las suyas"},"required":false,"description":"Solo admins; un comercial siempre ve las suyas","name":"user_id","in":"query"},{"schema":{"type":"string","enum":["pending","paid","void"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommissionPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/commissions/export":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Commissions"],"description":"Solo admin. CSV (UTF-8 con BOM) para nómina: comisiones pagadas en el periodo (por fecha de pago) o pendientes (por fecha de devengo), de todos o de un comercial, ordenadas por comercial. Las devoluciones salen en negativo. Hasta 50 000 filas.","parameters":[{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"Primer día (YYYY-MM-DD, zona horaria del espacio)","example":"2026-09-01"},"required":true,"description":"Primer día (YYYY-MM-DD, zona horaria del espacio)","name":"from","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"Último día incluido (YYYY-MM-DD)","example":"2026-09-30"},"required":true,"description":"Último día incluido (YYYY-MM-DD)","name":"to","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6","description":"Solo las de este comercial"},"required":false,"description":"Solo las de este comercial","name":"user_id","in":"query"},{"schema":{"type":"string","enum":["paid","pending"],"default":"paid","description":"`paid` filtra por fecha de pago (nómina); `pending` por fecha de devengo"},"required":false,"description":"`paid` filtra por fecha de pago (nómina); `pending` por fecha de devengo","name":"status","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/commissions/payout":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Commissions"],"description":"Solo admin. Marca como pagadas las comisiones pendientes indicadas (las demás se ignoran).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommissionPayout"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommissionPayoutResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/commissions/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Commissions"],"description":"Solo admin. `void` anula una pendiente (409 `commission.not_pending`); `pending` recupera una anulada (409 `commission.conflict` si el cobro ya tiene otra).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommissionUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Commission"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/customer-payments":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Commissions"],"description":"Solo admin. Cobros recibidos de Stripe; `status=unmatched` son los que no se pudieron atribuir a un comercial.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["matched","unmatched","ignored"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerPaymentPage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/customer-payments/{id}":{"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Commissions"],"description":"Solo admin. Asigna el cliente y/o el comercial de un cobro, o lo marca como «no es una venta». Cambiar el comercial anula la comisión pendiente y genera la del nuevo (409 `commission.already_paid` si ya estaba pagada).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerPaymentUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerPayment"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/{id}/owner-history":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Contacts"],"description":"Responsables que ha tenido el contacto y desde/hasta cuándo (el primero es el actual si `ended_at` es null).","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ContactOwnerPeriod"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Si el copiloto está disponible para el usuario.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiStatus"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/settings":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Solo admin. La clave nunca se devuelve (solo `key_hint`).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSettings"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Solo admin. `openai_key` se verifica contra OpenAI y se guarda cifrada (422 `assistant.key_invalid` si la rechaza).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSettingsUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSettings"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/settings/verify":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Solo admin. Vuelve a comprobar la clave guardada.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSettings"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/settings/key":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Solo admin. Borra la clave y desactiva el asistente.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSettings"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/widget":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Token y script del chat de la web (lo usa el plugin de WordPress con su clave API).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiWidgetInfo"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/documents":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocumentList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocumentCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocument"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/documents/import":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Descarga una página pública (sin redes privadas, 10 s, 1,5 MB) y guarda su texto.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocumentImport"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocument"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/documents/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocumentDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocumentUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiDocument"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/chat":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Pregunta al copiloto con el contexto del CRM del usuario. Las acciones las resuelve el servidor (rutas e ids del contexto).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiChatRequest"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiChatResponse"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/history":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiHistory"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/messages/{id}/feedback":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiFeedback"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiChatMessage"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/memory":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiMemoryList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/assistant/memory/{id}":{"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/chat/{token}":{"get":{"tags":["Public"],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatConfig"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/chat/{token}/messages":{"post":{"tags":["Public"],"description":"Sin sesión. Guarda el mensaje del visitante en la bandeja y devuelve la respuesta del asistente si está activo.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatSend"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatThread"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["Public"],"description":"Respuestas nuevas para el visitante (sondeo con el chat abierto).","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"},{"schema":{"type":"string","pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"required":true,"description":"Identificador del visitante que guarda `chat.js` en su navegador","name":"visitor_id","in":"query"},{"schema":{"type":"string","maxLength":40,"description":"Solo mensajes posteriores a esta fecha ISO"},"required":false,"description":"Solo mensajes posteriores a esta fecha ISO","name":"after","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatThread"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/chat/{token}/lead":{"post":{"tags":["Public"],"description":"Datos de contacto del visitante (formulario del chat): crea o actualiza el lead.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatLead"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatLeadResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/chat/{token}/typing":{"post":{"tags":["Public"],"description":"Sin sesión. Lo que el visitante lleva escrito (cada ~1 s mientras escribe; `text` vacío al enviar o borrar). El equipo lo ve en vivo en la bandeja. Pasado el cupo se descarta con 204.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatTyping"}}}},"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/chat/{token}/upload":{"post":{"tags":["Public"],"description":"Sin sesión. Foto (JPG, PNG, WebP o GIF, hasta 10 MB) o vídeo (MP4, WebM o MOV, hasta 20 MB) del visitante, en el campo `file`. `captcha`: token de Turnstile si la respuesta anterior fue `chat.captcha_required`.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"},{"schema":{"type":"string","pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"required":false,"description":"Identificador del visitante que guarda `chat.js` en su navegador","name":"visitor_id","in":"query"},{"schema":{"type":"string","maxLength":5},"required":false,"name":"lang","in":"query"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"},"captcha":{"type":"string","maxLength":4096}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatThread"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/chat/{token}/media/{id}":{"get":{"tags":["Public"],"description":"Sin sesión. Archivo de la conversación del propio visitante (`visitor_id`). Admite `Range` para vídeo.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"},{"schema":{"type":"string","maxLength":64},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","pattern":"^v_[A-Za-z0-9_-]{16,40}$","description":"Identificador del visitante que guarda `chat.js` en su navegador"},"required":true,"description":"Identificador del visitante que guarda `chat.js` en su navegador","name":"visitor_id","in":"query"},{"schema":{"type":"string","enum":["1"]},"required":false,"name":"download","in":"query"}],"responses":{"200":{"description":"Archivo","content":{"application/octet-stream":{"schema":{}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/chat/{token}/visit":{"post":{"tags":["Public"],"description":"Sin sesión. Página vista (`view`) o latido (`ping`) del visitante para la sección Visitantes. Con `Sec-GPC: 1` no se registra nada (`tracked: false`).","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":80},"required":true,"name":"token","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatVisit"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicChatVisitResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/visitors":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Quién está en la web ahora (`online`) o pasó en las últimas 24 h / 7 / 30 días, con páginas, origen y contacto si se conoce.","parameters":[{"schema":{"type":"string","enum":["online","24h","7d","30d"],"default":"online"},"required":false,"name":"range","in":"query"},{"schema":{"type":"string","maxLength":100},"required":false,"name":"q","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteVisitorList"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/visitors/{id}/message":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Assistant"],"description":"Escribe primero al visitante: abre la conversación del chat web (aparta al asistente) y la devuelve. 409 `visitors.chat_off` si el chat está apagado.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteVisitorMessage"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteVisitorMessageResult"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/landings":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Landing pages"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LandingSummary"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Landing pages"],"description":"Solo admins. Se publica en `/lp/{espacio}/{slug}`, aislada del CRM (CSP sandbox).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LandingInput"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Landing"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/landings/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Landing pages"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Landing"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Landing pages"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LandingUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Landing"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Landing pages"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/landings":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LandingSummary"}}},"required":["data"]}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Página de la plataforma: `/lp/{slug}`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LandingInput"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Landing"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/landings/{id}":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Landing"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LandingUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Landing"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"No content"},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/landings/{id}/block":{"post":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Retira (o devuelve) una página de cualquier espacio. Retirada no se sirve y su espacio no puede publicarla.","parameters":[{"schema":{"type":"string","format":"uuid","example":"0192f1a2-7b3c-7d4e-8f90-a1b2c3d4e5f6"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LandingBlock"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LandingSummary"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/wp-plugin":{"get":{"security":[{"cookieAuth":[]},{"bearerAuth":[]}],"tags":["Platform admin"],"description":"Versión publicada del plugin de WordPress y la que usa cada web conectada (según su User-Agent).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WpPluginOverview"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/public/landing":{"get":{"tags":["Public"],"description":"Contenido de una landing publicada (lo usa la web para servir `/lp/…`). Cuenta la visita.","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":170,"description":"`slug` (plataforma) o `espacio/slug`"},"required":true,"description":"`slug` (plataforma) o `espacio/slug`","name":"path","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicLanding"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not authenticated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{}}