> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wegly.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Consulta de chat

> Retorna os detalhes completos de um chat específico com participantes, vínculo CRM e última mensagem.



## OpenAPI

````yaml /openapi.json get /integrations/external/chats/{id}
openapi: 3.0.3
info:
  title: >-
    Integração Externa - Leads, Oportunidades, Tarefas, Arquivos, Propostas,
    Chats, Satisfação e Campos Personalizados
  version: 1.0.0
  description: >
    Documentação oficial da API externa da Wegly para campos personalizados,
    leads, oportunidades, tarefas, arquivos, propostas, chats e satisfação
    (`/integrations/external/custom-fields`, `/integrations/external/files`,
    `/integrations/external/leads`, `/integrations/external/deals`,
    `/integrations/external/tasks`, `/integrations/external/proposals`,
    `/integrations/external/chats` e `/integrations/external/satisfaction`).
    Todas as descrições estão em português e refletem as regras aplicadas pelo
    serviço.
servers:
  - url: https://api.wegly.com.br
    description: Ambiente de produção Wegly
security:
  - bearerAuth: []
tags:
  - name: Campos Personalizados
    description: >-
      Consulta dos campos personalizados disponíveis para uso nas integrações
      externas.
  - name: Arquivos
    description: >-
      Upload de arquivos públicos de integração vinculados diretamente a leads
      ou oportunidades.
  - name: Leads
    description: >-
      Operações de listagem, criação, consulta e atualização de leads via
      integração externa.
  - name: Oportunidades
    description: Operações de criação de oportunidades (deals) via integração externa.
  - name: Tarefas
    description: >-
      Operações de listagem, criação, consulta, atualização e remoção de tarefas
      vinculadas a leads, oportunidades, entregas, pessoas ou organizações.
  - name: Satisfação
    description: >-
      Geração de links públicos para formulários de satisfação via integração
      externa.
  - name: Propostas
    description: >-
      Operações de listagem, criação, consulta, atualização e remoção de
      propostas via integração externa.
  - name: Chats
    description: >-
      Operações principais de listagem, criação, consulta e resumo de não lidas
      de chats via integração externa.
paths:
  /integrations/external/chats/{id}:
    get:
      tags:
        - Chats
      summary: Consulta de chat
      description: >-
        Retorna os detalhes completos de um chat específico com participantes,
        vínculo CRM e última mensagem.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: UUID do chat.
      responses:
        '200':
          description: Detalhes completos do chat.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatDetails'
        '401':
          description: Token de integração ausente ou inválido.
        '403':
          description: Permissão `crm/chats.read` ausente ou chat fora do escopo da chave.
        '404':
          description: Chat não encontrado.
components:
  schemas:
    ChatDetails:
      allOf:
        - $ref: '#/components/schemas/ChatSummary'
        - type: object
          properties:
            remote_profile_name:
              type: string
              nullable: true
            last_customer_msg_at:
              type: string
              format: date-time
              nullable: true
            session_expires_at:
              type: string
              format: date-time
              nullable: true
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
            participants:
              type: array
              items:
                $ref: '#/components/schemas/ChatAgentSummary'
            phone_number:
              $ref: '#/components/schemas/ChatPhoneDetails'
            crm_person:
              type: object
              allOf:
                - $ref: '#/components/schemas/ChatPersonDetails'
              nullable: true
            crm_marketing_lead_source:
              type: array
              nullable: true
              items:
                type: object
                additionalProperties: true
            assignable_agents:
              type: array
              nullable: true
              items:
                $ref: '#/components/schemas/ChatAssignableAgentSummary'
    ChatSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        wa_contact_id:
          type: string
        contact_name:
          type: string
        contact_number:
          type: string
        status:
          $ref: '#/components/schemas/ChatStatusEnum'
        chat_type:
          $ref: '#/components/schemas/ChatTypeEnum'
        unread_count:
          type: integer
        is_manually_unread:
          type: boolean
        priority:
          $ref: '#/components/schemas/ChatPriorityValue'
        archived_at:
          type: string
          format: date-time
          nullable: true
        assigned_agent_id:
          type: string
          format: uuid
          nullable: true
        phone_number:
          $ref: '#/components/schemas/ChatPhoneSummary'
        assigned_agent:
          type: object
          allOf:
            - $ref: '#/components/schemas/ChatAgentSummary'
          nullable: true
        last_message_at:
          type: string
          format: date-time
          nullable: true
        last_message:
          type: object
          allOf:
            - $ref: '#/components/schemas/ChatMessageSummary'
          nullable: true
        crm_person:
          type: object
          allOf:
            - $ref: '#/components/schemas/ChatCrmPersonSummary'
          nullable: true
    ChatAgentSummary:
      type: object
      properties:
        agent_id:
          type: string
          format: uuid
        user:
          type: object
          allOf:
            - $ref: '#/components/schemas/ExternalUserSummary'
          nullable: true
    ChatPhoneDetails:
      allOf:
        - $ref: '#/components/schemas/ChatPhoneSummary'
        - type: object
          properties:
            raw_number:
              type: string
            phone_number_id:
              type: string
    ChatPersonDetails:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        birth_date:
          type: string
          format: date
          nullable: true
        gender:
          type: integer
          nullable: true
        notes:
          type: string
          nullable: true
        contacts:
          type: array
          items:
            $ref: '#/components/schemas/ChatPersonContact'
        documents:
          type: array
          items:
            $ref: '#/components/schemas/ChatPersonDocument'
        address:
          type: object
          allOf:
            - $ref: '#/components/schemas/ChatPersonAddress'
          nullable: true
    ChatAssignableAgentSummary:
      type: object
      properties:
        agent_id:
          type: string
          format: uuid
        status:
          type: string
        user:
          $ref: '#/components/schemas/ExternalUserSummary'
    ChatStatusEnum:
      type: string
      enum:
        - OPEN
        - RESOLVED
        - SNOOZED
    ChatTypeEnum:
      type: string
      enum:
        - INDIVIDUAL
        - GROUP
    ChatPriorityValue:
      type: integer
      enum:
        - 0
        - 1
        - 2
        - 3
      description: 0 = baixa, 1 = normal, 2 = alta, 3 = urgente.
    ChatPhoneSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        display_number:
          type: string
          nullable: true
    ChatMessageSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        type:
          $ref: '#/components/schemas/ChatMessageTypeEnum'
        origin:
          $ref: '#/components/schemas/ChatMessageOriginEnum'
        from_me:
          type: boolean
        sent_via:
          $ref: '#/components/schemas/ChatMessageSentViaEnum'
        status:
          $ref: '#/components/schemas/ChatMessageDeliveryStatusEnum'
        body_text:
          type: string
          nullable: true
        content_payload:
          type: object
          nullable: true
          additionalProperties: true
        reactions:
          type: array
          items:
            $ref: '#/components/schemas/ChatReaction'
        meta_timestamp:
          type: string
        is_history:
          type: boolean
        history_phase:
          type: integer
          nullable: true
        history_chunk_order:
          type: integer
          nullable: true
        history_progress:
          type: integer
          nullable: true
        is_media_placeholder:
          type: boolean
        agent:
          type: object
          nullable: true
          properties:
            id:
              type: string
              format: uuid
            user:
              type: object
              allOf:
                - $ref: '#/components/schemas/ExternalUserSummary'
              nullable: true
        user:
          type: object
          allOf:
            - $ref: '#/components/schemas/ExternalUserSummary'
          nullable: true
        crm_marketing_lead_source:
          type: array
          nullable: true
          items:
            type: object
            additionalProperties: true
    ChatCrmPersonSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
    ExternalUserSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        avatar:
          type: string
          nullable: true
    ChatPersonContact:
      type: object
      properties:
        id:
          type: string
          format: uuid
        type:
          type: integer
        value:
          type: string
        primary:
          type: boolean
    ChatPersonDocument:
      type: object
      properties:
        id:
          type: string
          format: uuid
        type:
          type: integer
        label:
          type: string
          nullable: true
        value:
          type: string
    ChatPersonAddress:
      type: object
      properties:
        id:
          type: string
          format: uuid
        status:
          type: integer
        type:
          type: integer
        name:
          type: string
          nullable: true
        street:
          type: string
          nullable: true
        number:
          type: string
          nullable: true
        complement:
          type: string
          nullable: true
        district:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        state:
          type: string
          nullable: true
        postal_code:
          type: string
          nullable: true
    ChatMessageTypeEnum:
      type: string
      enum:
        - text
        - reaction
        - image
        - video
        - audio
        - document
        - template
        - interactive
        - location
        - call
        - contacts
        - unsupported
    ChatMessageOriginEnum:
      type: string
      enum:
        - INBOUND
        - API_OUTBOUND
        - MOBILE_APP_ECHO
        - SYSTEM
    ChatMessageSentViaEnum:
      type: string
      enum:
        - CONTACT
        - API
        - MOBILE_DEVICE
        - SYSTEM
    ChatMessageDeliveryStatusEnum:
      type: string
      enum:
        - processing
        - sent
        - delivered
        - read
        - failed
        - received
        - deleted
    ChatReaction:
      type: object
      properties:
        id:
          type: string
          format: uuid
        emoji:
          type: string
        actor:
          type: string
          enum:
            - CONTACT
            - BUSINESS
        reactor_wa_id:
          type: string
        reactor_user_id:
          type: string
          format: uuid
          nullable: true
        created_at:
          type: string
          format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Utilize o token de integração no header `Authorization: Bearer {token}`.
        O domínio de origem (Origin/Referer) deve respeitar `allowed_domain`,
        quando configurado na chave.

````