> ## 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 lead

> Retorna detalhes completos do lead informado. O `id` pode ser UUID ou o código numérico interno. Considera visibilidade do usuário criador da chave.




## OpenAPI

````yaml /openapi.json get /integrations/external/leads/{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/leads/{id}:
    get:
      tags:
        - Leads
      summary: Consulta de lead
      description: >
        Retorna detalhes completos do lead informado. O `id` pode ser UUID ou o
        código numérico interno. Considera visibilidade do usuário criador da
        chave.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: UUID do lead ou código numérico interno.
      responses:
        '200':
          description: Detalhes do lead.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeadDetails'
        '401':
          description: Token de integração ausente ou inválido.
        '403':
          description: >-
            Permissão `crm/lead.read` ausente ou domínio de origem não
            autorizado na chave.
        '404':
          description: Lead não encontrado ou inacessível ao usuário da chave.
components:
  schemas:
    LeadDetails:
      type: object
      description: >-
        Detalhamento completo retornado no GET
        /integrations/external/leads/{id}.
      properties:
        id:
          type: string
        code:
          type: integer
        title:
          type: string
        created_by:
          type: object
          nullable: true
          properties:
            id:
              type: string
            name:
              type: string
            avatar:
              type: string
        stage:
          type: object
          nullable: true
          properties:
            id:
              type: string
            name:
              type: string
            pipeline:
              type: object
              nullable: true
              properties:
                id:
                  type: string
                name:
                  type: string
        pipeline_stages:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
              position:
                type: integer
        responsible:
          type: object
          nullable: true
          properties:
            id:
              type: string
            name:
              type: string
            avatar:
              type: string
        lead_source:
          type: object
          nullable: true
          description: Origem direta do lead (crm_lead_source).
          properties:
            id:
              type: string
            name:
              type: string
            logo:
              type: string
        marketing_lead_source:
          type: object
          nullable: true
          description: >-
            Último registro de rastreio (crm_marketing_lead_source). Valores
            textuais têm prioridade sobre relações.
          properties:
            id:
              type: string
            utm_search_term:
              type: string
              nullable: true
            lead_source:
              type: object
              nullable: true
              properties:
                id:
                  type: string
                name:
                  type: string
                logo:
                  type: string
            url_conversion:
              type: string
              nullable: true
            campaing_name:
              type: string
              nullable: true
            ad_set_name:
              type: string
              nullable: true
            content_name:
              type: string
              nullable: true
            displayed_on_name:
              type: string
              nullable: true
            conversion_tool_name:
              type: string
              nullable: true
            creative:
              type: object
              nullable: true
              properties:
                id:
                  type: string
                value:
                  type: string
                creative_uri:
                  type: string
        quality_rating:
          type: integer
          nullable: true
        quality_reason:
          type: string
          nullable: true
        won_date:
          type: string
          format: date-time
          nullable: true
        lost_date:
          type: string
          format: date-time
          nullable: true
        crm_loss_reason:
          type: object
          nullable: true
          properties:
            id:
              type: string
            name:
              type: string
        lost_reason_description:
          type: string
          nullable: true
        visibility:
          $ref: '#/components/schemas/LeadVisibility'
        negotiation_mode:
          type: integer
        created_at:
          type: string
          format: date-time
        archived_at:
          type: string
          format: date-time
          nullable: true
        last_activity_at:
          type: string
          format: date-time
          nullable: true
        participants:
          type: array
          description: Participantes do lead com informações de contato.
          items:
            type: object
            properties:
              id:
                type: string
              role:
                type: object
                nullable: true
                properties:
                  id:
                    type: string
                  name:
                    type: string
              notes:
                type: string
                nullable: true
              person:
                type: object
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  contacts:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        type:
                          $ref: '#/components/schemas/PersonContactType'
                        value:
                          type: string
                        primary:
                          type: boolean
        organization:
          type: object
          nullable: true
          properties:
            id:
              type: string
            name:
              type: string
            logo:
              type: string
        custom_fields:
          type: array
          description: Respostas de campos customizados agrupadas por campo.
          items:
            type: object
            properties:
              field_id:
                type: string
              field_name:
                type: string
              field_type:
                type: integer
              answers:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    option_id:
                      type: string
                      nullable: true
                    option_value:
                      type: string
                      nullable: true
                    value:
                      type: string
        tags:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
              color:
                type: string
        stage_durations:
          type: array
          description: Tempo acumulado por etapa (segundos e texto legível).
          items:
            type: object
            properties:
              stage_id:
                type: string
              stage_name:
                type: string
                nullable: true
              total_seconds:
                type: integer
              human_readable:
                type: string
        value:
          type: number
          nullable: true
        views_count:
          type: integer
        associations_count:
          type: object
          properties:
            items:
              type: integer
            tasks:
              type: integer
            qualifications:
              type: integer
            notes:
              type: integer
            files:
              type: integer
            activities:
              type: integer
            proposals:
              type: integer
        proposals:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              code:
                type: integer
              version:
                type: integer
              title:
                type: string
              status:
                type: integer
              is_primary:
                type: boolean
              discount_type:
                type: integer
                nullable: true
              discount_value:
                type: number
                nullable: true
              subtotal:
                type: number
                nullable: true
              total:
                type: number
                nullable: true
              valid_until:
                type: string
                format: date-time
                nullable: true
              created_at:
                type: string
                format: date-time
              updated_at:
                type: string
                format: date-time
              approved_at:
                type: string
                format: date-time
                nullable: true
              archived_at:
                type: string
                format: date-time
                nullable: true
              rejected_at:
                type: string
                format: date-time
                nullable: true
              created_by:
                type: object
                nullable: true
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  avatar:
                    type: string
              approved_by:
                type: object
                nullable: true
                properties:
                  id:
                    type: string
                  name:
                    type: string
        followers:
          type: array
          items:
            type: object
            properties:
              role:
                type: object
                nullable: true
                properties:
                  id:
                    type: string
                  name:
                    type: string
              user:
                type: object
                nullable: true
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  avatar:
                    type: string
              notes:
                type: string
                nullable: true
    LeadVisibility:
      type: integer
      enum:
        - 0
        - 1
      description: >
        0 = privado (responsável, membros dos times do responsável e
        supervisores), 1 = restrito ao responsável e times relacionados.
    PersonContactType:
      type: integer
      enum:
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        - 6
        - 7
      description: >
        0=WhatsApp, 1=Email, 2=Celular, 3=Telefone, 4=Instagram, 5=Facebook,
        6=LinkedIn, 7=Outros.
  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.

````