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

# Editar Lead

> Atualiza dados cadastrais de um lead — **update parcial**: envie só o que mudou. Campo omitido permanece como está; `null` explícito limpa o campo (nos campos anuláveis).

- **Telefone e etapa do funil não são editáveis por aqui.** O telefone é a identidade WhatsApp do lead; a etapa muda por `PUT /v1/leads/{id}/stage`, que registra o histórico da transição.
- `document` aceita CPF ou CNPJ. Enviando só `document`, o `document_type` é inferido pelo tamanho.

Retorna o cadastro completo já atualizado.



## OpenAPI

````yaml /openapi.json patch /v1/leads/{id}
openapi: 3.1.0
info:
  title: Superlead API
  version: 1.0.0
  description: >

    API oficial do Superlead para envio de mensagens WhatsApp aos **seus
    leads**.


    ## Autenticação

    Toda chamada exige `Authorization: Bearer sk_...` (crie a chave no painel
    Superlead

    em Integrações → API). A chave é escopada à sua empresa.


    ## Início rápido

    ```bash

    curl -X POST https://api.superlead.app/v1/whatsapp/messages \
      -H "Authorization: Bearer sk_SUACHAVE" \
      -H "Idempotency-Key: pedido-8734" \
      -H "Content-Type: application/json" \
      -d '{"to":"+5511999999999","type":"text","text":{"body":"Olá!"}}'
    ```

    No n8n: nó **HTTP Request**, método POST, header Authorization como acima.


    ## Endereçamento

    O campo `to` aceita **telefone E.164** (`+5511999999999`) ou **BSUID**

    (`BR.13491208655302741918` — o `fromUserId` entregue nos webhooks quando o
    contato

    usa username do WhatsApp; usernames nunca endereçam). O destinatário precisa
    ser um

    lead existente da sua empresa — o envio nunca cria leads. Para outreach,
    crie antes

    com `POST /v1/leads`. Use `external_id` para reconciliar com o seu sistema.


    ## Janela de 24h (regra da Meta)

    Mensagens de formato livre (text, image, ...) só são entregues se o lead
    falou com você

    nas últimas 24 horas. Fora da janela, use `type: "template"` com um template
    aprovado

    (liste-os em `GET /v1/whatsapp/templates`). Fora da janela a Meta pode
    rejeitar o envio na hora

    (`outside_24h_window`) OU aceitá-lo (201, status `accepted`) e falhá-lo de
    forma

    assíncrona segundos depois — a mensagem passa ao status `failed`. Confirme
    em

    `GET /v1/whatsapp/messages/{id}` ou pelo webhook `whatsapp.message.updated`.


    ## Idempotência

    Envie o header `Idempotency-Key` (recomendado). Retries com a mesma chave e
    mesmo body

    retornam a resposta original sem reenviar. Validade: 24h.


    ## Rate limit

    60 requisições/min por chave (headers `X-RateLimit-*`; `429` inclui
    `Retry-After`).


    ## Status da mensagem

    A resposta traz o status inicial. Acompanhe `sent → delivered → read` (ou
    `failed`)

    pelos webhooks do Superlead (evento `whatsapp.message.updated`) ou por

    `GET /v1/whatsapp/messages/{id}`. O evento de status identifica a mensagem
    pelo `wamid`

    retornado na resposta do envio.


    ## Erros

    Envelope estável `{ "error": { "code", "message", "request_id" } }`. Trate
    códigos

    desconhecidos pelo HTTP status (novos códigos são mudança aditiva).


    | HTTP | code | Meaning |

    |---|---|---|

    | 400 | `invalid_request` | The request body is invalid. Check the details
    field and the API reference. |

    | 401 | `invalid_api_key` | Missing or invalid API key. Send it as
    'Authorization: Bearer sk_...'. |

    | 404 | `lead_not_found` | No lead matches this recipient in your company.
    The API only messages existing leads. |

    | 404 | `message_not_found` | No message with this id exists in your
    company. |

    | 404 | `stage_not_found` | No funnel stage with this id exists in your
    company. List valid stages with GET /v1/funnel/stages. |

    | 409 | `idempotency_conflict` | This Idempotency-Key was already used with
    a different request body, or the original request is still in progress. |

    | 409 | `lead_already_exists` | A lead with this phone number already exists
    in your company. You can message it directly via POST /v1/whatsapp/messages.
    |

    | 422 | `funnel_not_configured` | Your company has no funnel stages
    configured. Set up the funnel in the Superlead panel first. |

    | 422 | `no_active_connection` | Your company has no active WhatsApp
    connection. Connect a number in the Superlead panel first. |

    | 422 | `connection_expired` | Your WhatsApp connection is no longer
    authorized. Reconnect it in the Superlead panel. |

    | 422 | `channel_capability_unsupported` | Your company's WhatsApp
    connection type does not support this operation. |

    | 422 | `outside_24h_window` | Free-form messages require the lead to have
    messaged you within the last 24 hours. Send an approved template instead. |

    | 422 | `template_not_found` | Template not found. Check the exact name and
    language with GET /v1/whatsapp/templates. |

    | 422 | `template_params_invalid` | Template parameters do not match the
    approved template. Check count, format and language. |

    | 422 | `recipient_unavailable` | The recipient cannot receive this message
    on WhatsApp right now. |

    | 422 | `media_unsupported` | WhatsApp could not fetch or process the media.
    Check that the link is public and direct, the format is supported and the
    file is within the size limit for its type. |

    | 422 | `message_blocked` | Meta blocked this message (spam or ecosystem
    limits). Reduce volume to this recipient and review quality. |

    | 429 | `rate_limit_exceeded` | Rate limit for this API key exceeded. Retry
    after the time in the Retry-After header. |

    | 429 | `channel_rate_limit` | WhatsApp is throttling your number. Slow down
    and retry later. |

    | 502 | `channel_error` | The messaging provider returned an unexpected
    error. Our team was notified; retry later. |

    | 500 | `internal_error` | Internal error. Our team was notified; retry
    later. |


    ## Versionamento

    Caminho `/v1/`. Mudanças incompatíveis só em `/v2/`. Campos novos opcionais
    podem

    aparecer a qualquer momento — ignore campos desconhecidos.
servers:
  - url: https://api.superlead.app
    description: Produção
security: []
paths:
  /v1/leads/{id}:
    patch:
      summary: Editar Lead
      description: >-
        Atualiza dados cadastrais de um lead — **update parcial**: envie só o
        que mudou. Campo omitido permanece como está; `null` explícito limpa o
        campo (nos campos anuláveis).


        - **Telefone e etapa do funil não são editáveis por aqui.** O telefone é
        a identidade WhatsApp do lead; a etapa muda por `PUT
        /v1/leads/{id}/stage`, que registra o histórico da transição.

        - `document` aceita CPF ou CNPJ. Enviando só `document`, o
        `document_type` é inferido pelo tamanho.


        Retorna o cadastro completo já atualizado.
      operationId: updateLead
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: >-
            Id do lead (`lead_...`), retornado por `POST /v1/leads`, `GET
            /v1/leads?phone=...` ou `GET /v1/leads/{id}`.
          example: lead_0b5f8a3e-1a2b-3c4d-5e6f-7a8b9c0d1e2f
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: Nome do lead, até 200 caracteres. Não aceita `null`.
                  example: João Silva
                email:
                  type:
                    - string
                    - 'null'
                  description: E-mail do lead. Envie `null` para limpar.
                  format: email
                  example: joao@empresa.com
                notes:
                  type:
                    - string
                    - 'null'
                  description: >-
                    Observações livres, até 2000 caracteres. Envie `null` para
                    limpar.
                  maxLength: 2000
                source:
                  type: string
                  minLength: 1
                  maxLength: 120
                  description: Origem do lead exibida no painel. Não aceita `null`.
                  example: Indicação
                channel:
                  type:
                    - string
                    - 'null'
                  description: Canal de origem. Envie `null` para limpar.
                  minLength: 1
                  maxLength: 120
                  example: WhatsApp
                entry_point:
                  type:
                    - string
                    - 'null'
                  description: Ponto de entrada da conversão. Envie `null` para limpar.
                  minLength: 1
                  maxLength: 120
                utm_source:
                  type:
                    - string
                    - 'null'
                  description: 'Atribuição: origem da campanha. Envie `null` para limpar.'
                  minLength: 1
                  maxLength: 255
                  example: google
                utm_medium:
                  type:
                    - string
                    - 'null'
                  description: 'Atribuição: mídia. Envie `null` para limpar.'
                  minLength: 1
                  maxLength: 255
                  example: cpc
                utm_campaign:
                  type:
                    - string
                    - 'null'
                  description: 'Atribuição: campanha. Envie `null` para limpar.'
                  minLength: 1
                  maxLength: 255
                utm_term:
                  type:
                    - string
                    - 'null'
                  description: 'Atribuição: termo de busca. Envie `null` para limpar.'
                  minLength: 1
                  maxLength: 255
                utm_content:
                  type:
                    - string
                    - 'null'
                  description: 'Atribuição: variação do anúncio. Envie `null` para limpar.'
                  minLength: 1
                  maxLength: 255
                document:
                  type:
                    - string
                    - 'null'
                  description: >-
                    CPF ou CNPJ, com ou sem pontuação. Sem `document_type`, o
                    tipo é inferido pelo tamanho. Envie `null` para limpar.
                  example: 123.456.789-01
                document_type:
                  type:
                    - string
                    - 'null'
                  enum:
                    - cpf
                    - cnpj
                  description: >-
                    Tipo do documento. Opcional — inferido pelo tamanho de
                    `document` quando omitido.
                cep:
                  type:
                    - string
                    - 'null'
                  description: CEP do endereço. Envie `null` para limpar.
                  example: 01310-100
                address:
                  type:
                    - string
                    - 'null'
                  description: Logradouro. Envie `null` para limpar.
                  minLength: 1
                  maxLength: 200
                  example: Av. Paulista
                address_number:
                  type:
                    - string
                    - 'null'
                  description: Número. Envie `null` para limpar.
                  minLength: 1
                  maxLength: 30
                  example: '1000'
                address_complement:
                  type:
                    - string
                    - 'null'
                  description: Complemento. Envie `null` para limpar.
                  minLength: 1
                  maxLength: 120
                  example: Conjunto 51
                neighborhood:
                  type:
                    - string
                    - 'null'
                  description: Bairro. Envie `null` para limpar.
                  minLength: 1
                  maxLength: 200
                  example: Bela Vista
                city:
                  type:
                    - string
                    - 'null'
                  description: Cidade. Envie `null` para limpar.
                  minLength: 1
                  maxLength: 200
                  example: São Paulo
                state:
                  type:
                    - string
                    - 'null'
                  description: Estado (UF). Envie `null` para limpar.
                  minLength: 1
                  maxLength: 50
                  example: SP
                country:
                  type:
                    - string
                    - 'null'
                  description: País. Envie `null` para limpar.
                  example: BR
            examples:
              cadastro:
                summary: Completar cadastro (documento + endereço)
                value:
                  email: joao@empresa.com
                  document: 123.456.789-01
                  cep: 01310-100
                  address: Av. Paulista
                  address_number: '1000'
                  city: São Paulo
                  state: SP
                  country: BR
              limpar_campo:
                summary: Limpar um campo com null
                value:
                  notes: null
      responses:
        '200':
          description: Lead atualizado — cadastro completo após o update.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: >-
                      Id do lead no Superlead (`lead_...`). Estável — use nas
                      demais chamadas.
                    example: lead_0b5f8a3e-1a2b-3c4d-5e6f-7a8b9c0d1e2f
                  name:
                    type:
                      - string
                      - 'null'
                    description: Nome do lead.
                    example: João Silva
                  phone:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Telefone em E.164. `null` para leads sem telefone exposto
                      (username do WhatsApp).
                    example: '+5511999999999'
                  source:
                    type:
                      - string
                      - 'null'
                    description: Origem do lead exibida no painel.
                    example: Meta Ads
                  channel:
                    type:
                      - string
                      - 'null'
                    description: Canal de origem.
                    example: WhatsApp
                  entry_point:
                    type:
                      - string
                      - 'null'
                    description: Ponto de entrada da conversão.
                    example: ctwa
                  funnel_stage:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Nome da etapa atual do funil. Para mover, use `PUT
                      /v1/leads/{id}/stage`.
                    example: 1º Contato
                  document:
                    type:
                      - string
                      - 'null'
                    description: CPF ou CNPJ do lead.
                    example: 123.456.789-01
                  document_type:
                    type:
                      - string
                      - 'null'
                    description: Tipo do documento.
                    example: cpf
                    enum:
                      - cpf
                      - cnpj
                  cep:
                    type:
                      - string
                      - 'null'
                    description: CEP do endereço.
                    example: 01310-100
                  address:
                    type:
                      - string
                      - 'null'
                    description: Logradouro.
                    example: Av. Paulista
                  address_number:
                    type:
                      - string
                      - 'null'
                    description: Número.
                    example: '1000'
                  address_complement:
                    type:
                      - string
                      - 'null'
                    description: Complemento.
                    example: Conjunto 51
                  neighborhood:
                    type:
                      - string
                      - 'null'
                    description: Bairro.
                    example: Bela Vista
                  city:
                    type:
                      - string
                      - 'null'
                    description: Cidade.
                    example: São Paulo
                  state:
                    type:
                      - string
                      - 'null'
                    description: Estado (UF).
                    example: SP
                  country:
                    type:
                      - string
                      - 'null'
                    description: País.
                    example: BR
                  created_at:
                    type: string
                    format: date-time
                    description: Data de criação do lead (ISO 8601, UTC).
                    example: '2026-06-01T12:00:00.000Z'
              example:
                id: lead_0b5f8a3e-1a2b-3c4d-5e6f-7a8b9c0d1e2f
                name: João Silva
                phone: '+5511999999999'
                source: Meta Ads
                channel: WhatsApp
                entry_point: ctwa
                funnel_stage: 1º Contato
                document: 123.456.789-01
                document_type: cpf
                cep: 01310-100
                address: Av. Paulista
                address_number: '1000'
                address_complement: null
                neighborhood: Bela Vista
                city: São Paulo
                state: SP
                country: BR
                created_at: '2026-06-01T12:00:00.000Z'
        '400':
          description: >-
            `invalid_request` — o body ou os parâmetros da requisição são
            inválidos. O campo `details` aponta cada campo com problema.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_request
                  message: The request body is invalid.
                  request_id: req_01J9X7K2M3N4P5Q6R7S8T9V0W1
                  details:
                    - path: to
                      message: Required
        '401':
          description: >-
            `invalid_api_key` — chave de API ausente, malformada ou revogada.
            Envie `Authorization: Bearer sk_...`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_api_key
                  message: >-
                    Missing or invalid API key. Send it as 'Authorization:
                    Bearer sk_...'.
                  request_id: req_01J9X7K2M3N4P5Q6R7S8T9V0W1
        '404':
          description: '`lead_not_found` — nenhum lead com este id na sua empresa.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: lead_not_found
                  message: >-
                    No lead matches this recipient in your company. The API only
                    messages existing leads.
                  request_id: req_01J9X7K2M3N4P5Q6R7S8T9V0W1
      security:
        - apiKey: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                Código estável do erro (ex.: `lead_not_found`). Novos códigos
                podem surgir a qualquer momento — trate códigos desconhecidos
                pelo HTTP status.
              example: lead_not_found
            message:
              type: string
              description: >-
                Descrição legível do erro, em inglês. O texto pode mudar — não
                faça parsing dele; use `code`.
            request_id:
              type: string
              description: >-
                Id único desta requisição. Inclua ao reportar um problema ao
                suporte.
              example: req_01J9X7K2M3N4P5Q6R7S8T9V0W1
            upstream_code:
              type: number
              description: >-
                Código numérico original da Meta, presente quando o erro veio do
                WhatsApp (ex.: `131047` para fora da janela de 24h).
              example: 131047
            details:
              type: array
              description: >-
                Erros de validação campo a campo. Presente em respostas `400
                invalid_request`.
              items:
                type: object
                properties:
                  path:
                    type: string
                    description: 'Caminho do campo inválido no body (ex.: `text.body`).'
                  message:
                    type: string
                    description: O que está errado com o campo.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        Chave de API da sua empresa (`sk_...`). Crie no painel Superlead em
        **Integrações → API** e envie em toda chamada como `Authorization:
        Bearer sk_...`. Veja [Autenticação](/guias/autenticacao).

````