{
    "openapi": "3.0.0",
    "info": {
        "title": "Tecmil Connect API - LINCA",
        "description": "A documentação apresenta contratos lógicos, isto é, os objetos antes da criptografia da requisição e depois da descriptografia da resposta. Nas rotas protegidas, o transporte real exige envelope E2EE com payload, key, iv e tag, além do header X-Client-Key para criptografar a resposta. O Swagger UI não produz esse envelope: o Try it out com o JSON lógico não executa diretamente essas operações. Em uploads híbridos, os metadados lógicos são criptografados e os arquivos permanecem como partes binárias multipart.",
        "version": "0.0.1"
    },
    "servers": [
        {
            "url": "/api/public/api"
        }
    ],
    "paths": {
        "/calendario/eventos": {
            "get": {
                "tags": [
                    "Calendário"
                ],
                "summary": "Listar eventos do calendário",
                "description": "Retorna eventos visíveis ao perfil autenticado: empresa, usuário ou atendente. Não recebe filtros nem request body.",
                "operationId": "5b574a13fcb412362b76fac7972e8749",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Eventos lógicos após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer"
                                                    },
                                                    "title": {
                                                        "type": "string"
                                                    },
                                                    "description": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "start_date": {
                                                        "type": "string",
                                                        "format": "date"
                                                    },
                                                    "start_time": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "end_date": {
                                                        "type": "string",
                                                        "format": "date",
                                                        "nullable": true
                                                    },
                                                    "end_time": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "recurrence": {
                                                        "nullable": true
                                                    },
                                                    "period": {
                                                        "nullable": true
                                                    },
                                                    "category": {
                                                        "type": "integer",
                                                        "nullable": true
                                                    },
                                                    "event_color": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "creator": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "reminder": {
                                                        "nullable": true
                                                    },
                                                    "empresa_id": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "usuario_id": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "atendente_id": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "prioridade_id": {
                                                        "type": "integer",
                                                        "nullable": true
                                                    },
                                                    "tipo_info": {
                                                        "properties": {
                                                            "id": {
                                                                "type": "integer"
                                                            },
                                                            "nome": {
                                                                "type": "string"
                                                            },
                                                            "descricao": {
                                                                "type": "string",
                                                                "nullable": true
                                                            },
                                                            "icone": {
                                                                "type": "string",
                                                                "nullable": true
                                                            },
                                                            "cor": {
                                                                "type": "string",
                                                                "nullable": true
                                                            },
                                                            "ordem": {
                                                                "type": "integer"
                                                            }
                                                        },
                                                        "type": "object",
                                                        "nullable": true
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Perfil sem acesso.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/ia/tecmilia/query": {
            "post": {
                "tags": [
                    "TecmilIA"
                ],
                "summary": "Consultar a TecmilIA",
                "description": "Disponível para empresa e atendente. O contexto conversacional é gerado pelo Connect e compartilhado por empresa.",
                "operationId": "4ea9284cd89f6f1e4ffb387fe4bbe3f1",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "question"
                                ],
                                "properties": {
                                    "question": {
                                        "type": "string",
                                        "example": "Como faço para abrir uma solicitação?"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica da TecmilIA dentro do envelope success.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "object",
                                            "example": {
                                                "answer": "Resposta da TecmilIA"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Perfil sem acesso ou vínculo de empresa inválido."
                    },
                    "404": {
                        "description": "Parâmetro obrigatório da integração não configurado."
                    },
                    "422": {
                        "description": "Falha de validação."
                    },
                    "502": {
                        "description": "Falha de autenticação, conexão ou resposta da API TecmilIA."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/integracao/login": {
            "post": {
                "tags": [
                    "Autenticação"
                ],
                "summary": "Autenticar identidade técnica de integração",
                "description": "O schema representa email e senha antes da criptografia E2EE. A rota não exige Bearer porque emite o JWT; a resposta lógica é criptografada usando X-Client-Key.",
                "operationId": "afb3fccc0cd6f03700ed3c8b4794a6cb",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "email",
                                    "senha"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "senha": {
                                        "type": "string",
                                        "format": "password"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Autenticação lógica.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "auth",
                                                "usuario",
                                                "tipo"
                                            ],
                                            "properties": {
                                                "auth": {
                                                    "required": [
                                                        "access_token",
                                                        "token_type",
                                                        "expires_in"
                                                    ],
                                                    "properties": {
                                                        "access_token": {
                                                            "type": "string"
                                                        },
                                                        "token_type": {
                                                            "type": "string",
                                                            "example": "bearer"
                                                        },
                                                        "expires_in": {
                                                            "type": "integer"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "usuario": {
                                                    "required": [
                                                        "id",
                                                        "nome"
                                                    ],
                                                    "properties": {
                                                        "id": {
                                                            "type": "string"
                                                        },
                                                        "nome": {
                                                            "type": "string"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "tipo": {
                                                    "required": [
                                                        "id",
                                                        "nome"
                                                    ],
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer"
                                                        },
                                                        "nome": {
                                                            "type": "string"
                                                        }
                                                    },
                                                    "type": "object"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "X-Client-Key ausente ou inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Credenciais inválidas.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Envelope ou payload lógico inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/ApiValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ApiErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Tipo de usuário não encontrado ou falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": []
            }
        },
        "/integracao/whatsapp/webhooks/inbound": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Receber evento WhatsApp encaminhado pelo Tecmil Comunicação",
                "description": "Contrato lógico protegido por JWT técnico e E2EE. O ACK somente é emitido após persistência durável ou reconhecimento idempotente. O Try it out não produz o envelope criptográfico.",
                "operationId": "53511415d871013a23664b4161f6165e",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappInboundPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Evento aceito ou duplicata compatível.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "status",
                                                "duplicado"
                                            ],
                                            "properties": {
                                                "status": {
                                                    "type": "string",
                                                    "enum": [
                                                        "aceito",
                                                        "duplicado"
                                                    ]
                                                },
                                                "duplicado": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Chave cliente ausente ou inválida.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT técnico ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Serviço ou contexto empresarial incompatível.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Chave idempotente reutilizada para conteúdo incompatível.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Envelope ou contrato lógico inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/ApiValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ApiErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Persistência durável indisponível.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/chave/registrar": {
            "post": {
                "tags": [
                    "Autenticação"
                ],
                "summary": "Registrar ou atualizar chave pública do cliente",
                "description": "Rota sem JWT e sem E2EE de request. Associa uma chave pública opcional ao device_id para permitir respostas E2EE posteriores.",
                "operationId": "7f58bd0b31bc16c020d7275fc98815b4",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "device_id"
                                ],
                                "properties": {
                                    "device_id": {
                                        "type": "string",
                                        "example": "dispositivo-app-01"
                                    },
                                    "public_key": {
                                        "description": "Chave pública PEM do cliente.",
                                        "type": "string",
                                        "nullable": true
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Chave registrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "key_id"
                                            ],
                                            "properties": {
                                                "key_id": {
                                                    "type": "integer"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Falha de validação.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": []
            }
        },
        "/solicitacao/listar": {
            "get": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Listar solicitações",
                "description": "Cliente vê as próprias solicitações nas empresas com vínculo ativo; atendente vê as atribuídas a ele; empresa vê as da própria empresa; IA vê somente solicitações cujo ia_id corresponde ao seu JWT. A ordem operacional considera ação esperada do perfil, ordem da prioridade, atualização decrescente e ID decrescente.",
                "operationId": "7b3ac7e097110de8ca8af7169770528c",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/SolicitacaoResumo"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/estado": {
            "get": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Consultar estado atual da solicitação",
                "description": "Retorna um único card no mesmo formato da listagem, respeitando o escopo atual do usuário, inclusive ia_id igual ao JWT para IA. Solicitação inexistente ou fora do escopo retorna 404.",
                "operationId": "2ad28cad3eeffa354d91c00ac6f272b6",
                "parameters": [
                    {
                        "name": "solicitacao_id",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/SolicitacaoResumo"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "404": {
                        "description": "Solicitação inexistente ou fora do escopo atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "solicitacao_id ausente ou inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoValidacao"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/tipos": {
            "get": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Listar tipos ativos",
                "description": "Disponível aos usuários autenticados.",
                "operationId": "eabca4c255bc65e113f02a4855106898",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/SolicitacaoCatalogo"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/tipos/prioridade": {
            "get": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Listar prioridades ativas",
                "description": "Disponível aos usuários autenticados.",
                "operationId": "80cc6ae9637b1bafdc3fa69a1612c080",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/SolicitacaoPrioridade"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/criar": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Criar solicitação",
                "description": "Cliente cria apenas para si e deve informar empresa_id com vínculo ativo. Empresa e atendente criam para cliente da própria empresa, sem vínculo prévio entre atendente e cliente; empresa_id recebida é ignorada nesses perfis.",
                "operationId": "aee769cf802e0dbaa8177cddd7ae828b",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoCriarPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "integer",
                                            "example": 123
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Atendente não encontrado na empresa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/fechar": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Fechar solicitação",
                "description": "Cliente dono, atendente associado ou empresa da solicitação. Solicitação já fechada: 403. Limpa prioridade.",
                "operationId": "8e3c93a697e570e2fdf22fabfac51714",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoFecharPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Solicitação encerrada com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/ia/exportar": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Exportar solicitação fechada para a TecmilIA",
                "description": "Operação explícita. Empresa exporta solicitações da própria empresa; atendente exporta solicitações atribuídas a ele na empresa vinculada; cliente exporta somente as próprias solicitações. Feedback é opcional.",
                "operationId": "0ee00979a20fd05b158bbe09696826f1",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoIAExportarPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Histórico processado pela API TecmilIA.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Solicitação fora do escopo ou ainda não fechada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, tipo ou parâmetro obrigatório não encontrado.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "solicitacao_id ausente ou inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoValidacao"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Falha segura na comunicação com a API TecmilIA.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/mensagens": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Listar mensagens",
                "description": "Cliente dono, atendente associado, empresa da solicitação ou IA atribuída. Ordem decrescente de criado_em; somente anexos ativos. usuario_id do request não define identidade.",
                "operationId": "a91d7b9133ce8e3a4c35b55bc2fdbdd2",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoMensagensPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/SolicitacaoMensagem"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/responder": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Responder com mensagem e anexos",
                "description": "Cliente dono, atendente associado, empresa da solicitação ou IA atribuída. Exige solicitação aberta. IA deve enviar somente texto não vazio e mensagem_origem_id de uma mensagem do cliente na mesma solicitação; perfis humanos não podem enviar origem não nula. Máximo 4 anexos; 5 MB (5120 KB) por arquivo; JPG/JPEG/PNG/PDF/MP3/OGG/M4A/WAV. Autor vem exclusivamente do JWT.",
                "operationId": "6c95931b8ebda3dc7ead6c586c737559",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoResponderPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Mensagem enviada com sucesso"
                                        },
                                        "zap": {
                                            "description": "Resultado da notificação externa, ou null.",
                                            "properties": {
                                                "success": {
                                                    "type": "string"
                                                },
                                                "error": {
                                                    "type": "string"
                                                },
                                                "celular": {
                                                    "type": "string"
                                                },
                                                "mensagem": {
                                                    "type": "string"
                                                },
                                                "response": {
                                                    "description": "Resposta do provedor externo."
                                                }
                                            },
                                            "type": "object",
                                            "nullable": true
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/mensagem/editar": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Editar mensagem",
                "description": "Exige acesso à solicitação, autoria da mensagem e solicitação aberta.",
                "operationId": "0cb50a1ff47eb4f31cb163c459b02a6c",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoEditarMsgPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Mensagem editada com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/mensagem/apagar": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Apagar mensagem",
                "description": "Exige acesso e solicitação aberta. EMPRESA pode excluir mensagens de qualquer perfil; ATENDENTE pode excluir mensagens de ATENDENTE, CLIENTE e IA; CLIENTE pode excluir somente a própria mensagem; IA não pode excluir. Mantém o registro, desativa anexos e usa os textos Mensagem apagada pela empresa., Mensagem apagada pelo atendente. ou Mensagem apagada pelo usuário., conforme quem realizou a exclusão.",
                "operationId": "d76e625799706180a23dbf04628970ac",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoApagarMsgPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Mensagem apagada com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/feedback": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Enviar feedback",
                "description": "Exige acesso e solicitação fechada; mantém 401 se aberta. Sem novos limites de nota ou impedimento de repetição.",
                "operationId": "a51a3de0e2f242744f279fb3bbfacdb1",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoFeedbackPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Feedback salvo com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado; solicitação aberta no feedback."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/tipo/editar": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Alterar tipo",
                "description": "Somente empresa da solicitação ou atendente associado. Cliente não pode. Aceita tipo existente ou null para remoção; mantém alteração em solicitação fechada.",
                "operationId": "c54705a621781c52c19a9fc761ced9ca",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoEditarTipoPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Tipo alterado com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/tipo/prioridade": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Alterar prioridade",
                "description": "Somente empresa da solicitação ou atendente associado. Cliente não pode. Aceita prioridade existente ou null para remoção; solicitação deve estar aberta.",
                "operationId": "30d37a56747aba674da929d876348220",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoEditarPrioridadePayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Prioridade atribuída com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/solicitacao/transferir": {
            "post": {
                "tags": [
                    "Solicitações"
                ],
                "summary": "Transferir solicitação",
                "description": "Somente empresa da solicitação ou atendente atualmente associado. Cliente não pode. Solicitação aberta; atendente_id é obrigatório, aceita atendente ativo da mesma empresa ou null para remover a atribuição.",
                "operationId": "d9209a6dedb51caaf7bd1dcc6383081f",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SolicitacaoTransferirPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resposta lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Solicitação transferida com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Sem vínculo/permissão, autoria inválida ou operação vedada no estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Solicitação, mensagem ou referência indicada não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validação de campos/arquivos ou erro de descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/SolicitacaoErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna de persistência ou configuração.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SolicitacaoErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/tecmilia/ingestao/execucoes": {
            "post": {
                "tags": [
                    "TecmilIA"
                ],
                "summary": "Agendar ingestão manual na TecmilIA",
                "description": "Operação exclusiva para administradores Connect explicitamente autorizados. Não aceita payload.",
                "operationId": "085142e46ac79eee881792b571f309c3",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "202": {
                        "description": "Execução agendada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "id",
                                                "status"
                                            ],
                                            "properties": {
                                                "id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "status": {
                                                    "type": "string",
                                                    "example": "pending"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Administrador não autorizado."
                    },
                    "409": {
                        "description": "Já existe execução ativa."
                    },
                    "422": {
                        "description": "O agendamento não aceita parâmetros."
                    },
                    "502": {
                        "description": "Falha ou confirmação incerta da integração."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/tecmilia/ingestao/execucoes/{id}": {
            "get": {
                "tags": [
                    "TecmilIA"
                ],
                "summary": "Consultar execução de ingestão da TecmilIA",
                "operationId": "c9067401ea8c5128ee2802d56d9acbb4",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Estado atual da execução.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "id",
                                                "status"
                                            ],
                                            "properties": {
                                                "id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "status": {
                                                    "type": "string"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Administrador não autorizado."
                    },
                    "404": {
                        "description": "Execução inexistente."
                    },
                    "422": {
                        "description": "UUID inválido."
                    },
                    "502": {
                        "description": "Falha da integração."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/integracao/telemetria/lotes": {
            "post": {
                "tags": [
                    "Telemetria"
                ],
                "summary": "Ingerir lote técnico de telemetria",
                "description": "Contrato lógico v1 protegido por JWT técnico e E2EE. A rota permanece indisponível enquanto a ingestão HTTP não for ativada e a identidade produtora não for explicitamente configurada.",
                "operationId": "6526f72297b67cd9c195a23935f0cf05",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "schema_version",
                                    "batch_id",
                                    "created_at",
                                    "producer",
                                    "events"
                                ],
                                "properties": {
                                    "schema_version": {
                                        "type": "string",
                                        "example": "1.0",
                                        "enum": [
                                            "1.0"
                                        ]
                                    },
                                    "batch_id": {
                                        "type": "string",
                                        "format": "uuid",
                                        "example": "013abfd2-602a-4cda-97af-35da3d18bf72"
                                    },
                                    "created_at": {
                                        "type": "string",
                                        "format": "date-time",
                                        "example": "2026-11-10T14:30:02.000Z"
                                    },
                                    "producer": {
                                        "required": [
                                            "service",
                                            "environment",
                                            "instance_id"
                                        ],
                                        "properties": {
                                            "service": {
                                                "type": "string",
                                                "example": "tecmil_comunicacao"
                                            },
                                            "environment": {
                                                "type": "string",
                                                "example": "production"
                                            },
                                            "instance_id": {
                                                "type": "string",
                                                "example": "comunicacao-primary"
                                            }
                                        },
                                        "type": "object"
                                    },
                                    "events": {
                                        "type": "array",
                                        "items": {
                                            "required": [
                                                "schema_version",
                                                "event_id",
                                                "trace_id",
                                                "span_id",
                                                "parent_span_id",
                                                "event_kind",
                                                "name",
                                                "producer",
                                                "timing",
                                                "result",
                                                "correlation",
                                                "attributes"
                                            ],
                                            "properties": {
                                                "schema_version": {
                                                    "type": "string",
                                                    "example": "1.0",
                                                    "enum": [
                                                        "1.0"
                                                    ]
                                                },
                                                "event_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "trace_id": {
                                                    "type": "string",
                                                    "pattern": "^[0-9a-f]{32}$"
                                                },
                                                "span_id": {
                                                    "type": "string",
                                                    "pattern": "^[0-9a-f]{16}$"
                                                },
                                                "parent_span_id": {
                                                    "type": "string",
                                                    "pattern": "^[0-9a-f]{16}$",
                                                    "nullable": true
                                                },
                                                "event_kind": {
                                                    "type": "string",
                                                    "enum": [
                                                        "span",
                                                        "wait",
                                                        "observation",
                                                        "counter"
                                                    ]
                                                },
                                                "name": {
                                                    "description": "Nome controlado pela allowlist do produtor.",
                                                    "type": "string"
                                                },
                                                "producer": {
                                                    "required": [
                                                        "service",
                                                        "component",
                                                        "environment"
                                                    ],
                                                    "properties": {
                                                        "service": {
                                                            "type": "string"
                                                        },
                                                        "component": {
                                                            "type": "string"
                                                        },
                                                        "environment": {
                                                            "type": "string"
                                                        },
                                                        "runtime": {
                                                            "type": "string"
                                                        },
                                                        "version": {
                                                            "type": "string"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "timing": {
                                                    "required": [
                                                        "started_at",
                                                        "ended_at",
                                                        "duration_ns",
                                                        "clock"
                                                    ],
                                                    "properties": {
                                                        "started_at": {
                                                            "type": "string",
                                                            "format": "date-time"
                                                        },
                                                        "ended_at": {
                                                            "type": "string",
                                                            "format": "date-time",
                                                            "nullable": true
                                                        },
                                                        "duration_ns": {
                                                            "type": "integer",
                                                            "format": "int64",
                                                            "nullable": true,
                                                            "minimum": 0
                                                        },
                                                        "clock": {
                                                            "type": "string",
                                                            "enum": [
                                                                "monotonic",
                                                                "wall",
                                                                "database"
                                                            ]
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "result": {
                                                    "required": [
                                                        "status"
                                                    ],
                                                    "properties": {
                                                        "status": {
                                                            "type": "string",
                                                            "enum": [
                                                                "success",
                                                                "error",
                                                                "timeout",
                                                                "cancelled",
                                                                "ambiguous",
                                                                "blocked",
                                                                "discarded"
                                                            ]
                                                        },
                                                        "category": {
                                                            "type": "string",
                                                            "nullable": true
                                                        },
                                                        "http_status": {
                                                            "type": "integer",
                                                            "nullable": true,
                                                            "maximum": 599,
                                                            "minimum": 100
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "attempt": {
                                                    "required": [
                                                        "phase",
                                                        "number",
                                                        "claim_generation",
                                                        "redrive"
                                                    ],
                                                    "properties": {
                                                        "phase": {
                                                            "type": "string"
                                                        },
                                                        "number": {
                                                            "type": "integer",
                                                            "minimum": 1
                                                        },
                                                        "claim_generation": {
                                                            "type": "integer",
                                                            "nullable": true,
                                                            "minimum": 1
                                                        },
                                                        "redrive": {
                                                            "type": "boolean"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "correlation": {
                                                    "description": "Identificadores técnicos opcionais previstos no contrato v1.",
                                                    "properties": {
                                                        "request_id": {
                                                            "type": "string",
                                                            "nullable": true
                                                        },
                                                        "job_id": {
                                                            "type": "string",
                                                            "nullable": true
                                                        },
                                                        "redrive_id": {
                                                            "type": "string",
                                                            "nullable": true
                                                        },
                                                        "claim_generation": {
                                                            "type": "integer",
                                                            "nullable": true,
                                                            "minimum": 1
                                                        },
                                                        "solicitacao_id": {
                                                            "type": "integer",
                                                            "nullable": true,
                                                            "minimum": 1
                                                        },
                                                        "conversa_id": {
                                                            "type": "integer",
                                                            "nullable": true,
                                                            "minimum": 1
                                                        },
                                                        "mensagem_id": {
                                                            "type": "integer",
                                                            "nullable": true,
                                                            "minimum": 1
                                                        },
                                                        "mensagem_origem_id": {
                                                            "type": "integer",
                                                            "nullable": true,
                                                            "minimum": 1
                                                        },
                                                        "provider_event_id": {
                                                            "type": "string",
                                                            "nullable": true
                                                        },
                                                        "provider_message_id": {
                                                            "type": "string",
                                                            "nullable": true
                                                        },
                                                        "target_provider_message_id": {
                                                            "type": "string",
                                                            "nullable": true
                                                        },
                                                        "idempotency_key_hash": {
                                                            "type": "string",
                                                            "pattern": "^[0-9a-f]{64}$",
                                                            "nullable": true
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "attributes": {
                                                    "description": "Somente o subconjunto escalar autorizado para o produtor e o nome do evento.",
                                                    "properties": {
                                                        "http.method": {
                                                            "type": "string",
                                                            "enum": [
                                                                "GET",
                                                                "POST",
                                                                "PUT",
                                                                "PATCH",
                                                                "DELETE",
                                                                "HEAD",
                                                                "OPTIONS"
                                                            ]
                                                        },
                                                        "http.route": {
                                                            "type": "string"
                                                        },
                                                        "network.transport": {
                                                            "type": "string",
                                                            "enum": [
                                                                "http",
                                                                "https",
                                                                "ws",
                                                                "wss"
                                                            ]
                                                        },
                                                        "db.operation": {
                                                            "type": "string",
                                                            "enum": [
                                                                "select",
                                                                "insert",
                                                                "update",
                                                                "delete",
                                                                "transaction",
                                                                "claim",
                                                                "append"
                                                            ]
                                                        },
                                                        "queue.name": {
                                                            "type": "string"
                                                        },
                                                        "model.name": {
                                                            "type": "string"
                                                        },
                                                        "cache.hit": {
                                                            "type": "boolean"
                                                        },
                                                        "provider.accepted": {
                                                            "type": "boolean"
                                                        },
                                                        "payload.size_bytes": {
                                                            "type": "integer",
                                                            "minimum": 0
                                                        },
                                                        "counter.value": {
                                                            "type": "integer",
                                                            "minimum": 0
                                                        },
                                                        "counter.unit": {
                                                            "type": "string",
                                                            "enum": [
                                                                "events",
                                                                "items",
                                                                "bytes"
                                                            ]
                                                        },
                                                        "counter.mode": {
                                                            "type": "string",
                                                            "enum": [
                                                                "delta"
                                                            ]
                                                        }
                                                    },
                                                    "type": "object"
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "minItems": 1
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "ACK emitido após persistência recuperável ou deduplicação durável.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "schema_version",
                                                "batch_id",
                                                "accepted",
                                                "duplicates",
                                                "rejected"
                                            ],
                                            "properties": {
                                                "schema_version": {
                                                    "type": "string",
                                                    "example": "1.0",
                                                    "enum": [
                                                        "1.0"
                                                    ]
                                                },
                                                "batch_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "accepted": {
                                                    "type": "integer",
                                                    "minimum": 0
                                                },
                                                "duplicates": {
                                                    "type": "integer",
                                                    "minimum": 0
                                                },
                                                "rejected": {
                                                    "type": "integer",
                                                    "minimum": 0
                                                },
                                                "rejections": {
                                                    "type": "array",
                                                    "items": {
                                                        "required": [
                                                            "index",
                                                            "event_id",
                                                            "code"
                                                        ],
                                                        "properties": {
                                                            "index": {
                                                                "type": "integer",
                                                                "minimum": 0
                                                            },
                                                            "event_id": {
                                                                "type": "string",
                                                                "format": "uuid",
                                                                "nullable": true
                                                            },
                                                            "code": {
                                                                "type": "string"
                                                            }
                                                        },
                                                        "type": "object"
                                                    }
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Chave cliente ausente ou inválida."
                    },
                    "401": {
                        "description": "JWT técnico ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Identidade ou produtor não autorizado."
                    },
                    "404": {
                        "description": "Ingestão HTTP desabilitada."
                    },
                    "413": {
                        "description": "Lote excede o limite de transporte."
                    },
                    "422": {
                        "description": "Envelope ou contrato lógico inválido."
                    },
                    "429": {
                        "description": "Rate limit da identidade produtora excedido."
                    },
                    "503": {
                        "description": "Persistência ou controle de ingestão indisponível."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/telemetria/lotes": {
            "post": {
                "tags": [
                    "Telemetria"
                ],
                "summary": "Ingerir lote de telemetria do Connect APP",
                "description": "Contrato lógico v1 protegido pelo JWT do usuário ativo, E2EE e chave cliente previamente vinculada. Aceita exclusivamente producer.service=connect_app e permanece desabilitado por padrão.",
                "operationId": "ingerirTelemetriaConnectApp",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "schema_version",
                                    "batch_id",
                                    "created_at",
                                    "producer",
                                    "events"
                                ],
                                "properties": {
                                    "schema_version": {
                                        "type": "string",
                                        "enum": [
                                            "1.0"
                                        ]
                                    },
                                    "batch_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "created_at": {
                                        "type": "string",
                                        "format": "date-time"
                                    },
                                    "producer": {
                                        "required": [
                                            "service",
                                            "environment",
                                            "instance_id"
                                        ],
                                        "properties": {
                                            "service": {
                                                "type": "string",
                                                "enum": [
                                                    "connect_app"
                                                ]
                                            },
                                            "environment": {
                                                "type": "string"
                                            },
                                            "instance_id": {
                                                "type": "string"
                                            }
                                        },
                                        "type": "object"
                                    },
                                    "events": {
                                        "type": "array",
                                        "items": {
                                            "description": "Evento v1 validado pela allowlist connect_app do contrato central.",
                                            "type": "object"
                                        },
                                        "minItems": 1
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "ACK após persistência recuperável ou deduplicação durável.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "schema_version",
                                                "batch_id",
                                                "accepted",
                                                "duplicates",
                                                "rejected"
                                            ],
                                            "properties": {
                                                "schema_version": {
                                                    "type": "string",
                                                    "enum": [
                                                        "1.0"
                                                    ]
                                                },
                                                "batch_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "accepted": {
                                                    "type": "integer",
                                                    "minimum": 0
                                                },
                                                "duplicates": {
                                                    "type": "integer",
                                                    "minimum": 0
                                                },
                                                "rejected": {
                                                    "type": "integer",
                                                    "minimum": 0
                                                },
                                                "rejections": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "object"
                                                    }
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Chave cliente ausente ou inválida."
                    },
                    "401": {
                        "description": "JWT de usuário ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Usuário, vínculo E2EE ou produtor não autorizado."
                    },
                    "404": {
                        "description": "Ingestão do APP desabilitada."
                    },
                    "413": {
                        "description": "Lote excede o limite de transporte."
                    },
                    "422": {
                        "description": "Envelope ou contrato lógico inválido."
                    },
                    "429": {
                        "description": "Rate limit do usuário excedido."
                    },
                    "503": {
                        "description": "Persistência ou controle de ingestão indisponível."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/user/broadcasting/auth": {
            "post": {
                "tags": [
                    "Autenticação"
                ],
                "summary": "Autorizar assinatura em canal privado Reverb",
                "description": "Esta rota usa Bearer JWT, mas é exceção ao E2EE: recebe e retorna diretamente o contrato exigido pelo protocolo de broadcasting.",
                "operationId": "803099670a28f4d84d076e71d25dc91b",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "socket_id",
                                    "channel_name"
                                ],
                                "properties": {
                                    "socket_id": {
                                        "type": "string",
                                        "example": "123.456"
                                    },
                                    "channel_name": {
                                        "type": "string",
                                        "example": "private-whatsapp.conversa.10"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Assinatura autorizada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "auth"
                                    ],
                                    "properties": {
                                        "auth": {
                                            "type": "string"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Usuário sem acesso ao canal."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/user/push-token": {
            "post": {
                "tags": [
                    "Usuários"
                ],
                "summary": "Registrar dispositivo para notificações push",
                "description": "Vincula idempotentemente um Expo Push Token à identidade do JWT. Um token anteriormente vinculado a outra identidade é transferido atomicamente.",
                "operationId": "dbdde2260276307aeed9a297c138a2a0",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "token"
                                ],
                                "properties": {
                                    "token": {
                                        "type": "string",
                                        "example": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
                                        "maxLength": 255
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Token vinculado.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "properties": {
                                                "registrado": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "422": {
                        "description": "Token inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "delete": {
                "tags": [
                    "Usuários"
                ],
                "summary": "Desvincular dispositivo das notificações push",
                "description": "Remove somente o Expo Push Token vinculado à identidade do JWT atual.",
                "operationId": "a9499d0c59f20cb50755f2402cda3416",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "token"
                                ],
                                "properties": {
                                    "token": {
                                        "type": "string",
                                        "example": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
                                        "maxLength": 255
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Operação idempotente concluída.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "properties": {
                                                "desvinculado": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "422": {
                        "description": "Token inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/user/login": {
            "post": {
                "tags": [
                    "Autenticação"
                ],
                "summary": "Autenticar usuário do Connect",
                "description": "Contrato lógico antes do E2EE. A rota não exige Bearer; senha é opcional apenas para perfis cujo fluxo atual não a exige. O Try it out não cifra o payload.",
                "operationId": "df2c1d79263b8ad0f88e3f04c5767310",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "email"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "senha": {
                                        "type": "string",
                                        "format": "password",
                                        "nullable": true
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Login ou solicitação de senha.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "required": [
                                                "reverb_channel_prefix"
                                            ],
                                            "properties": {
                                                "auth": {
                                                    "properties": {
                                                        "access_token": {
                                                            "type": "string"
                                                        },
                                                        "token_type": {
                                                            "type": "string",
                                                            "example": "bearer"
                                                        },
                                                        "expires_in": {
                                                            "type": "integer"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "usuario": {
                                                    "description": "Registro autenticado da view de usuários.",
                                                    "type": "object"
                                                },
                                                "tipo": {
                                                    "type": "object"
                                                },
                                                "cliente": {
                                                    "type": "object",
                                                    "nullable": true
                                                },
                                                "sistema": {
                                                    "type": "object",
                                                    "nullable": true
                                                },
                                                "empresa": {
                                                    "type": "object",
                                                    "nullable": true
                                                },
                                                "tema": {
                                                    "type": "object",
                                                    "nullable": true
                                                },
                                                "reverb_channel_prefix": {
                                                    "description": "Prefixo da instalação nos canais privados Reverb.",
                                                    "type": "string",
                                                    "pattern": "^[a-z0-9_-]+$"
                                                }
                                            },
                                            "type": "object",
                                            "nullable": true
                                        },
                                        "password": {
                                            "properties": {
                                                "message": {
                                                    "type": "string"
                                                },
                                                "requiresPassword": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "type": "object",
                                            "nullable": true
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "X-Client-Key ausente ou inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Credenciais ou vínculos inválidos.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Usuário inexistente ou desativado.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Envelope ou payload lógico inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/ApiValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ApiErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Prefixo Reverb da instalação ausente ou inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": []
            }
        },
        "/user/menus": {
            "get": {
                "tags": [
                    "Usuários"
                ],
                "summary": "Listar menus autorizados",
                "description": "Retorna somente menus ativos compatíveis com o tipo do usuário autenticado. path é derivado de tela.",
                "operationId": "5ecbdbbc3c23c24993707f2dffe4002b",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Menus lógicos.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer"
                                                    },
                                                    "nome": {
                                                        "type": "string"
                                                    },
                                                    "icone": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "tela": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "acao": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "path": {
                                                        "type": "string",
                                                        "nullable": true
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Perfil sem acesso.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/user/users": {
            "get": {
                "tags": [
                    "Usuários"
                ],
                "summary": "Listar usuários da empresa",
                "description": "empresa_id é contextual e opcional conforme o perfil. Usuário final recebe somente o próprio cadastro.",
                "operationId": "4aa900d97be372078140747806cff296",
                "parameters": [
                    {
                        "name": "empresa_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Usuários lógicos.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer"
                                                    },
                                                    "usuario_id": {
                                                        "type": "string"
                                                    },
                                                    "nome": {
                                                        "type": "string"
                                                    },
                                                    "documento": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "email": {
                                                        "type": "string",
                                                        "format": "email"
                                                    },
                                                    "celular": {
                                                        "type": "string",
                                                        "nullable": true
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Empresa fora do escopo.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Contexto empresarial ausente ou inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/user/workers": {
            "get": {
                "tags": [
                    "Usuários"
                ],
                "summary": "Listar atendentes ativos da empresa",
                "description": "empresa_id é contextual e opcional conforme o perfil autenticado.",
                "operationId": "6093a365b2aaea1b26a03929c7e93a1b",
                "parameters": [
                    {
                        "name": "empresa_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Atendentes lógicos.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer"
                                                    },
                                                    "atendente_id": {
                                                        "type": "string"
                                                    },
                                                    "nome": {
                                                        "type": "string"
                                                    },
                                                    "documento": {
                                                        "type": "string",
                                                        "nullable": true
                                                    },
                                                    "email": {
                                                        "type": "string",
                                                        "format": "email"
                                                    },
                                                    "celular": {
                                                        "type": "string",
                                                        "nullable": true
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Empresa fora do escopo.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Contexto empresarial ausente ou inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/ia/exportar": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Exportar conversa WhatsApp fechada para a TecmilIA",
                "description": "Operação manual. Permite exportação pela empresa da conversa ou pelo atendente atualmente atribuído. Preserva somente textos e legendas visíveis, incluindo respostas IA confirmadas.",
                "operationId": "95001fb6af3f079128b5c61feda1655f",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "description": "ID da chave pública registrada para a resposta E2EE.",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappConversaIdPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Histórico processado pela API TecmilIA.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente, inválido ou expirado."
                    },
                    "403": {
                        "description": "Usuário sem autorização ou conversa ainda aberta.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Payload, fechamento ou autoria de mensagem inválidos.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/ApiValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ApiErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Falha segura na comunicação com a API TecmilIA.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/mensagens/ia/preparar": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Preparar intenção idempotente de resposta IA no WhatsApp",
                "description": "Operação exclusiva da IA atribuída. Persiste somente a intenção; não envia ao provedor nesta etapa.",
                "operationId": "3043fa5768289dfa344d82ecc34e0aba",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappIaRespostaPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Intenção pendente criada ou já existente.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappIaRespostaPreparada"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "IA não atribuída, inativa ou conversa indisponível."
                    },
                    "409": {
                        "description": "Identidade reutilizada com conteúdo divergente."
                    },
                    "422": {
                        "description": "Payload ou mensagem de origem inválida."
                    },
                    "503": {
                        "description": "Estrutura persistente ainda indisponível."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/mensagens/ia/estado": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Consultar estado de entrega de uma resposta IA no WhatsApp",
                "description": "Consulta somente leitura, exclusiva da IA autora e da empresa da conversa. Não aciona o executor.",
                "operationId": "8a378aedd77d8fc60c6d6bbb630b0cb5",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "empresa_id",
                                    "request_id"
                                ],
                                "properties": {
                                    "empresa_id": {
                                        "type": "string",
                                        "maxLength": 8
                                    },
                                    "request_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Estado persistido da entrega.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappIaEntregaEstado"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "IA ou empresa sem autorização para a mensagem."
                    },
                    "404": {
                        "description": "Intenção não encontrada."
                    },
                    "422": {
                        "description": "Identidade de consulta inválida."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/mensagens/ia/cancelar": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Cancelar intenção pendente de resposta IA no WhatsApp",
                "description": "Operação idempotente exclusiva da IA autora. Somente uma intenção ainda pendente pode ser cancelada com segurança antes do envio.",
                "operationId": "709319f5a96d5393ba889bd16d9ebbf0",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "empresa_id",
                                    "request_id"
                                ],
                                "properties": {
                                    "empresa_id": {
                                        "type": "string",
                                        "maxLength": 8
                                    },
                                    "request_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Estado persistente após a tentativa de cancelamento.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappIaCancelamento"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "IA ou empresa sem autorização para a mensagem."
                    },
                    "404": {
                        "description": "Intenção não encontrada."
                    },
                    "422": {
                        "description": "Identidade de cancelamento inválida."
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/status": {
            "get": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Consultar estado da instância WhatsApp",
                "description": "Contrato lógico. O transporte da resposta é E2EE; empresa_id é opcional e sempre validado contra o usuário autenticado.",
                "operationId": "37d115a77aab872b25109f9340cc0402",
                "parameters": [
                    {
                        "name": "empresa_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 8
                        }
                    },
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Estado lógico da instância.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "properties": {
                                                "conectado": {
                                                    "type": "boolean"
                                                },
                                                "numero": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "nome": {
                                                    "type": "string",
                                                    "nullable": true
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Perfil ou empresa sem autorização.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Contexto empresarial inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Falha no Tecmil Comunicação.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/qrcode": {
            "get": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Consultar QR Code da instância WhatsApp",
                "description": "Contrato lógico. A resposta real é protegida por E2EE.",
                "operationId": "f86c1b4ed2d22ac7213421eca3d5d6f6",
                "parameters": [
                    {
                        "name": "empresa_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 8
                        }
                    },
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "QR Code lógico.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "properties": {
                                                "qrcode": {
                                                    "type": "string",
                                                    "nullable": true
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Perfil ou empresa sem autorização.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Falha no Tecmil Comunicação.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/restart": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Reiniciar instância WhatsApp",
                "description": "O body documenta o objeto lógico antes da criptografia E2EE.",
                "operationId": "2d7dc5874a91c16bfcfcfaa9b2cd1b21",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappEmpresaPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resultado lógico da reinicialização.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Perfil ou empresa sem autorização.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Payload lógico inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Falha no Tecmil Comunicação.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/logout": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Desconectar instância WhatsApp",
                "description": "O body documenta o objeto lógico antes da criptografia E2EE.",
                "operationId": "09e089d2d6c6ca3c8348ebe8b1e6f336",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappEmpresaPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resultado lógico da desconexão.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Perfil ou empresa sem autorização.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Payload lógico inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Falha no Tecmil Comunicação.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas": {
            "get": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Listar conversas WhatsApp",
                "description": "Sem request body. Retorna conversas autorizadas na ordem operacional oficial: grupo, prioridade, atualização decrescente e ID decrescente.",
                "operationId": "64f9cb799e061a82b82763efb70f5f9f",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lista lógica após descriptografia.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/WhatsappConversa"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Perfil sem acesso.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Falha interna.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/estado": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Consultar estado de uma conversa WhatsApp",
                "description": "Request e response representam os objetos lógicos protegidos pelo transporte E2EE.",
                "operationId": "592edd4a69db81b6a210e9ce3cb46e0c",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappConversaIdPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Conversa autorizada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappConversa"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Sem acesso à conversa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa inexistente.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "conversa_id inválido ou fora do payload criptografado.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/mensagens/listar": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Listar histórico de mensagens WhatsApp",
                "description": "Retorna mensagens em ordem cronológica. remetente é calculado relativamente ao usuário autenticado; anexos incluem URL pública estável.",
                "operationId": "8c6d22327b248a806038d2ee10a29e65",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappConversaIdPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Histórico lógico.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/WhatsappMensagem"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Sem acesso à conversa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa inexistente.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "conversa_id inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/mensagens/enviar": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Enviar texto ou mídia para uma conversa WhatsApp",
                "description": "Os schemas representam os contratos lógicos. No transporte JSON, conversa_id e mensagem são criptografados. No multipart híbrido, conversa_id, legenda e visualizacao_unica ficam dentro do envelope E2EE e somente anexo é parte binária. Formatos: JPEG, PNG, PDF, MP4, MP3, OGG, M4A e WAV; máximo de 5 MiB. O Try it out não monta o envelope criptográfico.",
                "operationId": "1a84c5bd220cf224ddc3678b1afc83ce",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappTextoPayload"
                            }
                        },
                        "multipart/form-data": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappMidiaPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Mensagem aceita pelo provedor e persistida.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappMensagem"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Sem acesso à conversa ou envio de mídia não permitido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Arquivo ou metadados inválidos, ou conversa fechada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/ApiValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ApiErro"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Envio externo confirmado, mas persistência local falhou.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Falha controlada ou ambígua no Tecmil Comunicação.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/transferir": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Transferir conversa WhatsApp",
                "description": "EMPRESA administra conversas do próprio escopo; ATENDENTE somente a conversa atualmente atribuída. atendente_id null remove a atribuição.",
                "operationId": "674b0d64fc170240154bfc7123200fba",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappTransferirPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Transferência concluída ou já correspondente ao estado atual.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "type": "string",
                                            "example": "Conversa transferida com sucesso"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Sem permissão, escopo ou atendente de destino válido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa inexistente.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Payload inválido ou conversa finalizada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/ApiValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ApiErro"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/categoria": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Alterar categoria da conversa WhatsApp",
                "description": "categoria_id é obrigatório e aceita null para remoção. Usuários autorizados podem classificar conversas abertas ou fechadas. Operações sem mudança são idempotentes.",
                "operationId": "8da6ebdf0d0933b878ce21a9754894f8",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappCategoriaPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Estado oficial completo da conversa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappConversa"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Sem permissão administrativa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa ou categoria ativa não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Payload inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/prioridade": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Alterar prioridade da conversa WhatsApp",
                "description": "prioridade_id é obrigatório e aceita null para remoção. A resposta contém a ordenação oficial recalculada.",
                "operationId": "f9a594858b40f9b3025de05b5c231d4f",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappPrioridadePayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Estado oficial completo da conversa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappConversa"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Sem permissão administrativa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa ou prioridade ativa não encontrada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Payload inválido ou conversa finalizada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/ApiValidacao"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ApiErro"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/whatsapp/conversas/finalizar": {
            "post": {
                "tags": [
                    "WhatsApp"
                ],
                "summary": "Finalizar conversa WhatsApp",
                "description": "Define o status oficial como Fechado. A operação repetida é idempotente e não altera timestamps nem gera eventos adicionais.",
                "operationId": "4886756f6f4e3291b80b8570b480ee90",
                "parameters": [
                    {
                        "name": "X-Client-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WhatsappConversaIdPayload"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Estado oficial completo da conversa fechada.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "required": [
                                        "success"
                                    ],
                                    "properties": {
                                        "success": {
                                            "$ref": "#/components/schemas/WhatsappConversa"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "JWT ausente ou inválido."
                    },
                    "403": {
                        "description": "Sem permissão administrativa.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Conversa inexistente.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiErro"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "conversa_id inválido.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ApiValidacao"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        }
    },
    "components": {
        "schemas": {
            "WhatsappInboundPayload": {
                "required": [
                    "versao",
                    "chave_idempotencia",
                    "servico_remetente",
                    "empresa",
                    "empresa_id",
                    "instancia",
                    "tipo_evento",
                    "natureza",
                    "identificador_externo",
                    "evento",
                    "payload_original_base64",
                    "payload_hash"
                ],
                "properties": {
                    "versao": {
                        "type": "integer",
                        "example": 1,
                        "enum": [
                            1
                        ]
                    },
                    "chave_idempotencia": {
                        "type": "string",
                        "example": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
                        "maxLength": 64,
                        "minLength": 64
                    },
                    "servico_remetente": {
                        "type": "string",
                        "enum": [
                            "tecmil_comunicacao"
                        ]
                    },
                    "empresa": {
                        "type": "string",
                        "example": "tecmil",
                        "maxLength": 20
                    },
                    "empresa_id": {
                        "type": "string",
                        "example": "E1",
                        "maxLength": 8
                    },
                    "instancia": {
                        "type": "string",
                        "example": "instancia-tecmil",
                        "maxLength": 255
                    },
                    "tipo_evento": {
                        "type": "string",
                        "example": "MESSAGE",
                        "maxLength": 100
                    },
                    "natureza": {
                        "type": "string",
                        "enum": [
                            "texto",
                            "midia",
                            "status",
                            "evento"
                        ]
                    },
                    "identificador_externo": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 255
                    },
                    "evento": {
                        "type": "object",
                        "additionalProperties": true
                    },
                    "payload_original_base64": {
                        "description": "Bytes exatos recebidos pelo Comunicação, codificados em Base64 dentro do E2EE.",
                        "type": "string",
                        "format": "byte"
                    },
                    "payload_hash": {
                        "description": "SHA-256 dos bytes decodificados de payload_original_base64.",
                        "type": "string",
                        "maxLength": 64,
                        "minLength": 64
                    }
                },
                "type": "object"
            },
            "ApiErro": {
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "ApiValidacao": {
                "type": "object",
                "additionalProperties": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            },
            "SolicitacaoErro": {
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string",
                        "example": "Acesso à solicitação negado."
                    }
                },
                "type": "object"
            },
            "SolicitacaoValidacao": {
                "type": "object",
                "additionalProperties": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            },
            "SolicitacaoCatalogo": {
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "nome": {
                        "type": "string"
                    },
                    "descricao": {
                        "type": "string",
                        "nullable": true
                    },
                    "icone": {
                        "type": "string",
                        "nullable": true
                    },
                    "cor": {
                        "type": "string",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "SolicitacaoPrioridade": {
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "nome": {
                        "type": "string"
                    },
                    "descricao": {
                        "type": "string",
                        "nullable": true
                    },
                    "icone": {
                        "type": "string",
                        "nullable": true
                    },
                    "cor": {
                        "type": "string",
                        "nullable": true
                    },
                    "ordem": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "SolicitacaoOrdenacao": {
                "required": [
                    "grupo",
                    "prioridade"
                ],
                "properties": {
                    "grupo": {
                        "description": "0 exige ação do perfil atual; 1 aguarda a outra parte; 2 está encerrada.",
                        "type": "integer",
                        "maximum": 2,
                        "minimum": 0
                    },
                    "prioridade": {
                        "description": "Ordem do catálogo de prioridades; 2147483647 representa ausência de prioridade.",
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "SolicitacaoStatus": {
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "nome": {
                        "type": "string"
                    },
                    "icone": {
                        "type": "string",
                        "nullable": true
                    },
                    "cor": {
                        "type": "string",
                        "nullable": true
                    },
                    "condicao": {
                        "type": "string",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "SolicitacaoAnexo": {
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "anexo": {
                        "type": "string"
                    },
                    "status": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            },
            "SolicitacaoMensagem": {
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "solicitacao_id": {
                        "type": "integer"
                    },
                    "usuario_id": {
                        "type": "string"
                    },
                    "mensagem": {
                        "type": "string",
                        "nullable": true
                    },
                    "mensagem_origem_id": {
                        "description": "Mensagem do cliente que originou uma resposta automática da IA.",
                        "type": "integer",
                        "nullable": true
                    },
                    "criado_em": {
                        "type": "string",
                        "example": "2026-09-09 10:00:00"
                    },
                    "remetente": {
                        "description": "Somente nesta listagem HTTP: indica autoria relativa ao JWT; não integra mensagem.enviada.",
                        "type": "boolean"
                    },
                    "autor": {
                        "type": "string",
                        "nullable": true
                    },
                    "autor_tipo": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/SolicitacaoCatalogo"
                            }
                        ],
                        "nullable": true
                    },
                    "anexos": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/SolicitacaoAnexo"
                        }
                    }
                },
                "type": "object"
            },
            "SolicitacaoResumo": {
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "usuario_id": {
                        "type": "string"
                    },
                    "empresa_id": {
                        "type": "string"
                    },
                    "atendente_id": {
                        "type": "string",
                        "nullable": true
                    },
                    "tipo_solicitacao": {
                        "type": "integer"
                    },
                    "titulo": {
                        "type": "string"
                    },
                    "descricao": {
                        "type": "string"
                    },
                    "status": {
                        "type": "integer"
                    },
                    "prioridade_id": {
                        "type": "integer",
                        "nullable": true
                    },
                    "ia_id": {
                        "description": "IA atualmente atribuída à solicitação, quando houver.",
                        "type": "string",
                        "nullable": true
                    },
                    "protocolo": {
                        "description": "Protocolo retornado pela aplicação."
                    },
                    "criado_em": {
                        "type": "string"
                    },
                    "atualizado_em": {
                        "type": "string",
                        "nullable": true
                    },
                    "autorId": {
                        "type": "string"
                    },
                    "autor": {
                        "type": "string",
                        "nullable": true
                    },
                    "atendente_nome": {
                        "type": "string",
                        "nullable": true
                    },
                    "status_info": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/SolicitacaoStatus"
                            }
                        ],
                        "nullable": true
                    },
                    "tipo_info": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/SolicitacaoCatalogo"
                            }
                        ],
                        "nullable": true
                    },
                    "prioridade_info": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/SolicitacaoPrioridade"
                            }
                        ],
                        "nullable": true
                    },
                    "ordenacao": {
                        "$ref": "#/components/schemas/SolicitacaoOrdenacao"
                    }
                },
                "type": "object"
            },
            "SolicitacaoCriarClientePayload": {
                "required": [
                    "empresa_id",
                    "tipo_solicitacao",
                    "titulo",
                    "descricao"
                ],
                "properties": {
                    "usuario_id": {
                        "description": "Cliente destinatário. Cliente autenticado só pode informar a si; obrigatório para empresa e atendente.",
                        "type": "string",
                        "nullable": true
                    },
                    "empresa_id": {
                        "description": "Obrigatória para cliente, com vínculo ativo. Ignorada para empresa e atendente.",
                        "type": "string"
                    },
                    "atendente_id": {
                        "description": "Atendente ativo da empresa da solicitação.",
                        "type": "string",
                        "nullable": true
                    },
                    "tipo_solicitacao": {
                        "type": "integer"
                    },
                    "titulo": {
                        "type": "string"
                    },
                    "descricao": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "SolicitacaoCriarEquipePayload": {
                "required": [
                    "usuario_id",
                    "tipo_solicitacao",
                    "titulo",
                    "descricao"
                ],
                "properties": {
                    "usuario_id": {
                        "description": "Cliente destinatário. Cliente autenticado só pode informar a si; obrigatório para empresa e atendente.",
                        "type": "string",
                        "nullable": false
                    },
                    "empresa_id": {
                        "description": "Obrigatória para cliente, com vínculo ativo. Ignorada para empresa e atendente.",
                        "type": "string"
                    },
                    "atendente_id": {
                        "description": "Atendente ativo da empresa da solicitação.",
                        "type": "string",
                        "nullable": true
                    },
                    "tipo_solicitacao": {
                        "type": "integer"
                    },
                    "titulo": {
                        "type": "string"
                    },
                    "descricao": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "SolicitacaoCriarPayload": {
                "description": "Contrato depende do perfil JWT: cliente informa empresa_id; empresa e atendente informam usuario_id, derivando a empresa da autenticação.",
                "anyOf": [
                    {
                        "$ref": "#/components/schemas/SolicitacaoCriarClientePayload"
                    },
                    {
                        "$ref": "#/components/schemas/SolicitacaoCriarEquipePayload"
                    }
                ]
            },
            "SolicitacaoFecharPayload": {
                "required": [
                    "solicitacao_id"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "SolicitacaoIAExportarPayload": {
                "required": [
                    "solicitacao_id"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer",
                        "minimum": 1
                    }
                },
                "type": "object"
            },
            "SolicitacaoFeedbackPayload": {
                "required": [
                    "solicitacao_id",
                    "nota"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer"
                    },
                    "nota": {
                        "type": "integer"
                    },
                    "mensagem": {
                        "type": "string",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "SolicitacaoTransferirPayload": {
                "required": [
                    "solicitacao_id",
                    "atendente_id"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer"
                    },
                    "atendente_id": {
                        "description": "Atendente ativo da empresa; null remove a atribuição atual.",
                        "type": "string",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "SolicitacaoMensagensPayload": {
                "required": [
                    "solicitacao_id"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "SolicitacaoResponderPayload": {
                "required": [
                    "solicitacao_id"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer"
                    },
                    "mensagem": {
                        "type": "string",
                        "nullable": true
                    },
                    "mensagem_origem_id": {
                        "description": "Obrigatório exclusivamente para IA; deve identificar uma mensagem de cliente da mesma solicitação. Perfis humanos não podem enviar valor não nulo.",
                        "type": "integer",
                        "nullable": true
                    },
                    "anexo": {
                        "description": "Até 4 arquivos JPG/JPEG/PNG/PDF; até 5 MB (5120 KB) cada. Nome multipart: anexo[].",
                        "type": "array",
                        "items": {
                            "type": "string",
                            "format": "binary"
                        },
                        "maxItems": 4
                    }
                },
                "type": "object"
            },
            "SolicitacaoEditarMsgPayload": {
                "required": [
                    "mensagem_id",
                    "mensagem"
                ],
                "properties": {
                    "mensagem_id": {
                        "type": "integer"
                    },
                    "mensagem": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "SolicitacaoApagarMsgPayload": {
                "required": [
                    "mensagem_id"
                ],
                "properties": {
                    "mensagem_id": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "SolicitacaoEditarTipoPayload": {
                "required": [
                    "solicitacao_id",
                    "tipo_solicitacao"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer"
                    },
                    "tipo_solicitacao": {
                        "type": "integer",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "SolicitacaoEditarPrioridadePayload": {
                "required": [
                    "solicitacao_id",
                    "prioridade_id"
                ],
                "properties": {
                    "solicitacao_id": {
                        "type": "integer"
                    },
                    "prioridade_id": {
                        "type": "integer",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "WhatsappMetadata": {
                "required": [
                    "id",
                    "nome"
                ],
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "nome": {
                        "type": "string"
                    },
                    "icone": {
                        "type": "string",
                        "nullable": true
                    },
                    "cor": {
                        "type": "string",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "WhatsappPrioridade": {
                "required": [
                    "id",
                    "nome",
                    "ordem"
                ],
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "nome": {
                        "type": "string"
                    },
                    "icone": {
                        "type": "string",
                        "nullable": true
                    },
                    "cor": {
                        "type": "string",
                        "nullable": true
                    },
                    "ordem": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "WhatsappStatus": {
                "required": [
                    "id",
                    "nome"
                ],
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "nome": {
                        "type": "string"
                    },
                    "icone": {
                        "type": "string",
                        "nullable": true
                    },
                    "cor": {
                        "type": "string",
                        "nullable": true
                    },
                    "condicao": {
                        "type": "string",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "WhatsappOrdenacao": {
                "required": [
                    "grupo",
                    "prioridade"
                ],
                "properties": {
                    "grupo": {
                        "type": "integer",
                        "maximum": 2,
                        "minimum": 0
                    },
                    "prioridade": {
                        "description": "Ordem oficial da prioridade; 2147483647 representa ausência de prioridade.",
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "WhatsappConversa": {
                "required": [
                    "id",
                    "empresa_id",
                    "celular",
                    "status",
                    "finalizado",
                    "ordenacao"
                ],
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "empresa_id": {
                        "type": "string"
                    },
                    "usuario_id": {
                        "type": "string",
                        "nullable": true
                    },
                    "atendente_id": {
                        "type": "string",
                        "nullable": true
                    },
                    "atendente_nome": {
                        "type": "string",
                        "nullable": true
                    },
                    "zap_nome": {
                        "type": "string",
                        "nullable": true
                    },
                    "celular": {
                        "type": "string"
                    },
                    "atendido": {
                        "description": "Campo legado mantido por compatibilidade; não define o estado operacional.",
                        "type": "boolean"
                    },
                    "status": {
                        "type": "integer"
                    },
                    "status_info": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/WhatsappStatus"
                            }
                        ],
                        "nullable": true
                    },
                    "categoria_id": {
                        "type": "integer",
                        "nullable": true
                    },
                    "categoria_info": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/WhatsappMetadata"
                            }
                        ],
                        "nullable": true
                    },
                    "prioridade_id": {
                        "type": "integer",
                        "nullable": true
                    },
                    "prioridade_info": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/WhatsappPrioridade"
                            }
                        ],
                        "nullable": true
                    },
                    "criado_em": {
                        "type": "string"
                    },
                    "atualizado_em": {
                        "type": "string",
                        "nullable": true
                    },
                    "finalizado": {
                        "description": "Derivado de status igual a 3.",
                        "type": "boolean"
                    },
                    "ordenacao": {
                        "$ref": "#/components/schemas/WhatsappOrdenacao"
                    }
                },
                "type": "object"
            },
            "WhatsappAnexo": {
                "required": [
                    "id",
                    "anexo",
                    "nome_original",
                    "mime_type",
                    "tamanho",
                    "tipo",
                    "visualizacao_unica",
                    "enviado_em",
                    "url"
                ],
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "anexo": {
                        "description": "Path persistido no armazenamento compartilhado.",
                        "type": "string"
                    },
                    "nome_original": {
                        "type": "string"
                    },
                    "mime_type": {
                        "type": "string"
                    },
                    "tamanho": {
                        "type": "integer"
                    },
                    "tipo": {
                        "type": "string",
                        "enum": [
                            "image",
                            "video",
                            "audio",
                            "document"
                        ]
                    },
                    "legenda": {
                        "type": "string",
                        "nullable": true
                    },
                    "visualizacao_unica": {
                        "type": "boolean"
                    },
                    "enviado_em": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    }
                },
                "type": "object"
            },
            "WhatsappMensagem": {
                "required": [
                    "id",
                    "conversa_id",
                    "remetente_id",
                    "criado_em",
                    "connect",
                    "provider_status",
                    "provider_status_atualizado_em"
                ],
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "conversa_id": {
                        "type": "integer"
                    },
                    "remetente_id": {
                        "type": "string",
                        "nullable": true
                    },
                    "remetente_celular": {
                        "type": "string",
                        "nullable": true
                    },
                    "mensagem": {
                        "type": "string",
                        "nullable": true
                    },
                    "criado_em": {
                        "type": "string"
                    },
                    "connect": {
                        "description": "Origem da mensagem: true para Connect e false para webhook WhatsApp.",
                        "type": "boolean"
                    },
                    "provider_status": {
                        "description": "Confirmação do provedor: 2 enviado, 3 entregue e 4 lido.",
                        "type": "integer",
                        "nullable": true,
                        "enum": [
                            2,
                            3,
                            4
                        ]
                    },
                    "provider_status_atualizado_em": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "tipo_mensagem": {
                        "description": "Classificação informativa opcional derivada da própria mensagem persistida.",
                        "type": "string",
                        "nullable": true,
                        "enum": [
                            "aviso_visualizacao_unica"
                        ]
                    },
                    "remetente": {
                        "description": "Presente no histórico e na resposta de mídia; autoria relativa ao usuário autenticado.",
                        "type": "boolean"
                    },
                    "anexos": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/WhatsappAnexo"
                        }
                    }
                },
                "type": "object"
            },
            "WhatsappConversaIdPayload": {
                "required": [
                    "conversa_id"
                ],
                "properties": {
                    "conversa_id": {
                        "type": "integer",
                        "example": 10,
                        "minimum": 1
                    }
                },
                "type": "object"
            },
            "WhatsappEmpresaPayload": {
                "properties": {
                    "empresa_id": {
                        "description": "Contexto empresarial opcional; empresa e atendente são validados pelo JWT.",
                        "type": "string",
                        "nullable": true,
                        "maxLength": 8
                    }
                },
                "type": "object"
            },
            "WhatsappCategoriaPayload": {
                "required": [
                    "conversa_id",
                    "categoria_id"
                ],
                "properties": {
                    "conversa_id": {
                        "type": "integer",
                        "example": 10,
                        "minimum": 1
                    },
                    "categoria_id": {
                        "type": "integer",
                        "example": 3,
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "WhatsappPrioridadePayload": {
                "required": [
                    "conversa_id",
                    "prioridade_id"
                ],
                "properties": {
                    "conversa_id": {
                        "type": "integer",
                        "example": 10,
                        "minimum": 1
                    },
                    "prioridade_id": {
                        "type": "integer",
                        "example": 2,
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "WhatsappTransferirPayload": {
                "required": [
                    "conversa_id",
                    "atendente_id"
                ],
                "properties": {
                    "conversa_id": {
                        "type": "integer",
                        "example": 10,
                        "minimum": 1
                    },
                    "atendente_id": {
                        "type": "string",
                        "example": "A1",
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "WhatsappTextoPayload": {
                "required": [
                    "conversa_id",
                    "mensagem"
                ],
                "properties": {
                    "conversa_id": {
                        "type": "integer",
                        "example": 10,
                        "minimum": 1
                    },
                    "mensagem": {
                        "type": "string",
                        "example": "Olá!"
                    }
                },
                "type": "object"
            },
            "WhatsappMidiaPayload": {
                "required": [
                    "conversa_id",
                    "anexo"
                ],
                "properties": {
                    "conversa_id": {
                        "description": "Metadado lógico criptografado no payload E2EE; não é uma parte multipart plaintext.",
                        "type": "integer",
                        "example": 10,
                        "minimum": 1
                    },
                    "legenda": {
                        "type": "string",
                        "example": "Foto do equipamento",
                        "nullable": true,
                        "maxLength": 4096
                    },
                    "visualizacao_unica": {
                        "type": "boolean",
                        "default": false
                    },
                    "anexo": {
                        "description": "Parte binária multipart, até 5 MiB. Formatos: JPEG, PNG, PDF, MP4, MP3, OGG, M4A e WAV.",
                        "type": "string",
                        "format": "binary"
                    }
                },
                "type": "object"
            },
            "WhatsappIaRespostaPayload": {
                "required": [
                    "empresa_id",
                    "conversa_id",
                    "mensagem_origem_id",
                    "request_id",
                    "response_sha256",
                    "mensagem"
                ],
                "properties": {
                    "empresa_id": {
                        "type": "string",
                        "example": "E1",
                        "maxLength": 8
                    },
                    "conversa_id": {
                        "type": "integer",
                        "example": 10,
                        "minimum": 1
                    },
                    "mensagem_origem_id": {
                        "type": "integer",
                        "example": 456,
                        "minimum": 1
                    },
                    "request_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "response_sha256": {
                        "type": "string",
                        "maxLength": 64,
                        "minLength": 64
                    },
                    "mensagem": {
                        "type": "string",
                        "example": "Resposta produzida pela IA."
                    }
                },
                "type": "object"
            },
            "WhatsappIaRespostaPreparada": {
                "required": [
                    "mensagem_id",
                    "request_id",
                    "status",
                    "created"
                ],
                "properties": {
                    "mensagem_id": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "request_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "sending",
                            "sent",
                            "failed",
                            "uncertain"
                        ]
                    },
                    "created": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            },
            "WhatsappIaEntregaEstado": {
                "required": [
                    "request_id",
                    "mensagem_id",
                    "status",
                    "provider_confirmed",
                    "delivery_authorized"
                ],
                "properties": {
                    "request_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "mensagem_id": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "sending",
                            "sent",
                            "failed",
                            "uncertain"
                        ]
                    },
                    "provider_confirmed": {
                        "type": "boolean"
                    },
                    "delivery_authorized": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            },
            "WhatsappIaCancelamento": {
                "required": [
                    "request_id",
                    "mensagem_id",
                    "status",
                    "canceled",
                    "safe_to_discard"
                ],
                "properties": {
                    "request_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "mensagem_id": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "sending",
                            "sent",
                            "failed",
                            "uncertain"
                        ]
                    },
                    "canceled": {
                        "type": "boolean"
                    },
                    "safe_to_discard": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            }
        },
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "bearerFormat": "JWT",
                "scheme": "bearer"
            }
        }
    },
    "tags": [
        {
            "name": "Autenticação",
            "description": "Autenticação, credenciais de integração e autorização Reverb"
        },
        {
            "name": "Calendário",
            "description": "Consultas e operações relacionadas ao calendário"
        },
        {
            "name": "TecmilIA",
            "description": "Integração e operações da TecmilIA"
        },
        {
            "name": "Solicitações",
            "description": "Gestão de solicitações e mensagens"
        },
        {
            "name": "Telemetria",
            "description": "Ingestão técnica de telemetria de desempenho"
        },
        {
            "name": "Usuários",
            "description": "Usuários, menus e trabalhadores/atendentes"
        },
        {
            "name": "WhatsApp",
            "description": "Instância, conversas, mensagens e operações WhatsApp"
        }
    ]
}