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

# Edits lead information

> Updates the lead information associated with a chat. Allows modifying ticket status,
agent assignment, kanban position, tags, and other custom fields.

Changes are immediately available in queries and in webhook/SSE events.
to keep the application in sync.




## OpenAPI

````yaml /openapi-en.json post /chat/editLead
openapi: 3.1.0
info:
  title: WppFy -  WhatsApp API
  version: 1.0.0
  description: >
    API for managing WhatsApp instances and communications.


    ## Important Recommendation: WhatsApp Business

    **It is HIGHLY RECOMMENDED to use WhatsApp Business accounts** instead of
    regular WhatsApp for integration; regular WhatsApp may present
    inconsistencies, disconnections, limitations, and instability when used with
    our API.


    ## Authentication

    - Regular endpoints require a 'token' header with the instance token


    ## Instance States

    Instances can be in the following states:

    - `disconnected`: Disconnected from WhatsApp

    - `connecting`: Connection in progress

    - `connected`: Successfully connected and authenticated
servers:
  - url: https://api.wppfy.com
security:
  - token: []
tags:
  - name: Instance
    description: |
      Operations related to an instance's lifecycle, such as connecting,
      disconnecting, and checking status.
  - name: Proxy
    description: >
      WppFy uses an internal proxy by default.

      You can keep this default, configure your own proxy via `proxy_url`, or
      use your Android phone as a proxy by installing the app from
      https://github.com/WppFy/silver_proxy_apk (direct APK:
      https://github.com/WppFy/silver_proxy_apk/raw/refs/heads/main/silver_proxy.apk).

      If nothing is sent, we keep using the internal proxy. IPs are Brazilian;
      for international clients, consider a proxy in the client's region.
  - name: Profile
    description: |
      Operations related to the WhatsApp instance profile, such as changing
      the profile name and picture.
  - name: Business
    description: |
      ⚠️ **EXPERIMENTAL** - Endpoints not yet fully tested.

      Operations related to the WhatsApp Business business profile.
      Allows querying and updating business profile data such as description,
      address, email, categories, and managing the product catalog.

      **Requirements:**
      - The currently connected account must be a **WhatsApp Business** account
      - Personal WhatsApp accounts do not have a business profile

      **Note:** These endpoints may not work as expected.
      Report any problems found.
  - name: Calls
    description: |
      Operations related to WhatsApp calls.
      Allows making and rejecting calls programmatically.
  - name: Send Message
    description: >
      Endpoints for sending WhatsApp messages with different content types.


      ## Common Optional Fields


      All message sending endpoints support the following optional fields:


      - **`delay`** *(integer)*: Delay in milliseconds before sending
        - During the delay, "Typing..." or "Recording audio..." will appear depending on the type
        - Example: `5000` (5 seconds)

      - **`readchat`** *(boolean)*: Mark chat as read after sending
        - Removes the unread message counter from the chat
        - Example: `true`

      - **`readmessages`** *(boolean)*: Mark last received messages as read
        - Marks the last 10 **received** messages (not sent by you) as read
        - Useful to confirm reading pending messages before replying
        - Different from `readchat` which only removes the unread counter
        - Example: `true`

      - **`replyid`** *(string)*: ID of the message to reply to
        - Creates a reply linked to the original message
        - Support varies by message type
        - Example: `"3A12345678901234567890123456789012"`

      - **`mentions`** *(string)*: Numbers to mention (only for group sending)
        - Specific numbers: `"5511999999999,5511888888888"`
        - Mention all: `"all"`

      - **`forward`** *(boolean)*: Marks the message as forwarded in WhatsApp
        - Adds the "Forwarded" indicator to the message
        - Example: `true`

      - **`track_source`** *(string)*: Message tracking source
        - Identifies the system or source sending the message
        - Useful for integrations (e.g., "chatwoot", "crm", "chatbot")
        - Example: `"chatwoot"`

      - **`track_id`** *(string)*: ID for message tracking
        - Free identifier to track the message in external systems
        - Allows correlating messages between different platforms
        - **Note**: The system accepts duplicate values - there is no uniqueness validation
        - Use the same ID in multiple messages if it makes sense for your integration
        - Example: `"msg_123456789"`

      ### Sending to Groups

      - **`number`** *(string)*: To send a message to a group, use the group ID
      ending with `@g.us`
        - Example: `"120363012345678901@g.us"`
        - **How to get the Group ID:**
          - Use the `chatid` from the webhook received when someone sends a message in the group
          - Use the `GET /group/list` endpoint to list all groups and their IDs

      ## Available Placeholders


      All message sending endpoints support dynamic placeholders for automatic
      personalization:


      ### Name Fields

      - **`{{name}}`**: Consolidated chat name, using the first available
      option:
        1. Lead name (`lead_name`)
        2. Lead full name (`lead_fullName`)
        3. WhatsApp contact name (`wa_contactName`)
        4. WhatsApp profile name (`wa_name`)

      - **`{{first_name}}`**: First valid word of the consolidated name (minimum
      2 characters)


      ### WhatsApp Fields

      - **`{{wa_name}}`**: WhatsApp profile name

      - **`{{wa_contactName}}`**: Contact name as saved in WhatsApp


      ### Lead Fields

      - **`{{lead_name}}`**: Lead name

      - **`{{lead_fullName}}`**: Lead full name

      - **`{{lead_personalid}}`**: Personal ID (SSN, CPF, CNPJ, etc)

      - **`{{lead_email}}`**: Lead email

      - **`{{lead_status}}`**: Current lead status

      - **`{{lead_notes}}`**: Lead notes

      - **`{{lead_assignedAttendant_id}}`**: ID of the assigned attendant


      ### Custom Fields

      Fields added via custom fields are accessible using `{{lead_field01}}` to
      `{{lead_field20}}` or use `{{fieldname}}` defined in
      `/instance/updateFieldsMap`.


      ### Usage Example

      ```

      Hello {{name}}! I saw you work at {{company}}.

      Is your email {{lead_email}} correct?

      ```


      **💡 Tip**: Use `/chat/find` to fetch chat data and see available fields
      before sending messages with placeholders.
  - name: Async Message
    description: >
      Operational controls for the internal asynchronous send queue used when a
      send endpoint receives `async=true`.


      This section is used to:

      - check the current state of the async queue

      - configure the delay between messages sent with `async=true`

      - clear pending backlog and cancel messages not yet completed


      Scope:

      - covers only the internal queue of async direct messages

      - does not change messages already sent successfully
  - name: Message Actions and Search
  - name: Chats
  - name: Contacts
  - name: Blocklist
  - name: Labels
  - name: Groups and Communities
  - name: Newsletters and Channels
    description: >
      Operations for reading and following WhatsApp channels (newsletters).


      Main use cases:

      - list posts already published in a channel

      - edit recent posts in a channel

      - delete recent posts in a channel

      - check post views and reactions

      - integrate channels without needing to persist messages locally


      Notes:

      - `/newsletter/messages` returns the post content

      - `/newsletter/messages/edit` edits the content of recent posts

      - `/newsletter/messages/delete` deletes recent posts

      - views (`viewsCount`) and reactions (`reactionCounts`) come in each post
      of `/newsletter/messages`, not via webhook event

      - `/newsletter/updates` is deprecated: WhatsApp does not respond and the
      API returns 504

      - newsletters use their own routes and must not use `/message/edit` or
      `/message/delete`
  - name: Quick Replies
    description: >
      Management of quick replies to streamline service.


      **⚠️ Important**: This feature is only useful if you use a custom
      frontend/interface

      to register and use the replies. The API only stores the replies, 

      but does not apply them automatically.


      ### How it works:

      - **Create**: Register pre-defined responses with titles and content

      - **List**: Retrieve all registered responses to display in your interface

      - **Use**: Your frontend system can use these responses to speed up typing


      ### Use cases:

      - Custom web service interfaces

      - Mobile apps with reply suggestions

      - CRM systems with message templates

      - Productivity tools for attendants


      **Not a chatbot**: For automatic responses, use Chatbot features.
  - name: CRM
    description: >
      Complete customer relationship management system integrated with the API.


      **💾 Internal Storage**: All lead data is saved directly in the API,

      eliminating the need for external databases. Your application can focus
      only

      on the interface and business logic.


      ### Available Features:

      - **📋 20+ customizable fields**: Name, phone, email, company, notes, etc.

      - **🏷️ Label System**: Organize and categorize your contacts

      - **🔍 Advanced Search**: Filter by any field or label

      - **📊 Complete History**: All interactions are registered automatically


      ### 🎯 Placeholders in messages:

      Use dynamic variables in messages for automatic personalization:


      ```

      Hello {{name}}! I saw you work at {{company}}.

      Is your email {{email}} correct?

      Notes: {{notes}}

      ```


      ### Typical Flow:

      1. **Capture**: Leads arrive via WhatsApp or forms

      2. **Enrichment**: Add data using `/chat/editLead`

      3. **Segmentation**: Organize with labels

      4. **Communication**: Send personalized messages with placeholders

      5. **Follow-up**: History is saved automatically


      **Ideal for**: Sales, marketing, support, lead qualification
  - name: Chatwoot Integration
    description: >
      **🚧 BETA INTEGRATION - Chatwoot integration system for unified service**


      **⚠️ WARNING**: This integration is in BETA phase. Use at your own risk.
      We recommend testing in a non-production environment before use in
      production.


      This category contains resources to configure and manage integration with
      Chatwoot, an open-source customer service platform. The integration allows
      centralizing WhatsApp conversations in Chatwoot.


      ### Available Features:

      - 🔧 **Complete Configuration**: Configure URL, tokens, and Chatwoot
      credentials

      - 📬 **Bidirectional Sync**: New messages between WhatsApp and Chatwoot
      are synced automatically

      - 📱 **Contact Management**: Automatic sync of names and phones

      - 🔄 **LID→PN Update**: Automatic migration from Local ID to Phone Number

      - 🏷️ **Smart Names**: Name system with tilde (~) for automatic update

      - 🚫 **Group Separation**: Option to ignore groups in sync

      - 👤 **Message Signature**: Agent identification in sent messages

      - 🔗 **Automatic Webhook**: URL generated automatically to configure in
      Chatwoot


      ### 🏷️ Smart Name System:

      - **Names with tilde (~)**: Updated automatically when contact modifies
      name in WhatsApp

      - **Specific names**: For fixed name, remove tilde (~) from name in
      Chatwoot

      - **Example**: "~John Doe" = automatic, "John Doe" = fixed

      - **LID→PN Migration**: No conversation duplication during transition

      - **Native responses**: Appear directly in Chatwoot without external
      markings


      ### ⚠️ Known Limitations:

      - **History sync**: Not implemented - only new messages are synced


      ### Use Cases:

      - Centralized service in Chatwoot

      - Support teams with multiple agents

      - CRM integration via Chatwoot

      - Communication channel centralization

      - Automatic contact and name management


      **Ideal for**: Companies with service teams, call centers, technical
      support (in test environment)


      **Requires**: Configured Chatwoot instance, API tokens, and test
      environment


      **🚧 Remember**: BETA integration - features may change without prior
      notice
  - name: Server-Sent Events (SSE)
paths:
  /chat/editLead:
    post:
      tags:
        - CRM
      summary: Edits lead information
      description: >
        Updates the lead information associated with a chat. Allows modifying
        ticket status,

        agent assignment, kanban position, tags, and other custom fields.


        Changes are immediately available in queries and in webhook/SSE events.

        to keep the application in sync.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - id
              properties:
                id:
                  type: string
                  description: |
                    Chat identifier. Can be:
                    - wa_chatid (e.g.: "5511999999999@s.whatsapp.net")
                    - wa_fastid (e.g.: "5511888888888:5511999999999")
                  example: 5511999999999@s.whatsapp.net
                chatbot_disableUntil:
                  type: integer
                  format: int64
                  description: >-
                    Pauses automation (AI, triggers, and flows) in this
                    conversation until this time, in milliseconds. `-1` pauses
                    until someone turns it back on; `0` turns it back on.
                  example: -1
                chatbot_agentResetMemoryAt:
                  type: integer
                  format: int64
                  description: >-
                    Resets the AI memory in the conversation: the agent starts
                    reading only messages from this time (ms) onward. `-1` is
                    now (server time); `0` undoes it. A time in the future
                    counts as now.
                  example: -1
                lead_isTicketOpen:
                  type: boolean
                  description: |
                    Status of the ticket associated with the lead.
                    - true: Ticket is open/in service
                    - false: Ticket is closed/resolved
                  example: true
                lead_assignedAttendant_id:
                  type: string
                  description: |
                    ID of the attendant assigned to the lead.
                    Use an empty string ("") to remove the assignment.
                  example: att_123456
                lead_kanbanOrder:
                  type: integer
                  format: int64
                  description: |
                    Card position on the kanban board.
                    Higher values appear first.
                  example: 1000
                lead_tags:
                  type: array
                  items:
                    type: string
                  description: |
                    List of tags associated with the lead.
                    Non-existent tags are created automatically.
                    Tags with `kanban=true` represent the card's column.
                    Send an empty array ([]) to remove all tags.
                  example:
                    - vip
                    - suporte
                    - prioridade-alta
                lead_name:
                  type: string
                  description: Lead's main name
                  example: John Doe
                lead_fullName:
                  type: string
                  description: Lead's full name
                  example: John Smith Doe
                lead_email:
                  type: string
                  format: email
                  description: Lead email
                  example: joao@exemplo.com
                lead_personalid:
                  type: string
                  description: |
                    Identification document (CPF/CNPJ)
                    Numbers only or formatted
                  example: 123.456.789-00
                lead_status:
                  type: string
                  description: Free-form lead status in the sales funnel
                  example: qualificado
                lead_notes:
                  type: string
                  description: Notes about the lead
                  example: Customer interested in premium plan
                lead_field01:
                  type: string
                  description: Custom field 1
                lead_field02:
                  type: string
                  description: Custom field 2
                lead_field03:
                  type: string
                  description: Custom field 3
                lead_field04:
                  type: string
                  description: Custom field 4
                lead_field05:
                  type: string
                  description: Custom field 5
                lead_field06:
                  type: string
                  description: Custom field 6
                lead_field07:
                  type: string
                  description: Custom field 7
                lead_field08:
                  type: string
                  description: Custom field 8
                lead_field09:
                  type: string
                  description: Custom field 9
                lead_field10:
                  type: string
                  description: Custom field 10
                lead_field11:
                  type: string
                  description: Custom field 11
                lead_field12:
                  type: string
                  description: Custom field 12
                lead_field13:
                  type: string
                  description: Custom field 13
                lead_field14:
                  type: string
                  description: Custom field 14
                lead_field15:
                  type: string
                  description: Custom field 15
                lead_field16:
                  type: string
                  description: Custom field 16
                lead_field17:
                  type: string
                  description: Custom field 17
                lead_field18:
                  type: string
                  description: Custom field 18
                lead_field19:
                  type: string
                  description: Custom field 19
                lead_field20:
                  type: string
                  description: Custom field 20
      responses:
        '200':
          description: >-
            Updated lead. Includes the lead and chatbot fields of the
            conversation, not the whole `Chat` (no `lead_awaitingReply`, for
            example).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Chat'
              example:
                wa_fastid: '5511888888888:5511999999999'
                wa_chatid: 5511999999999@s.whatsapp.net
                lead_name: João Silva
                lead_status: qualificado
                lead_tags:
                  - vip
                  - suporte
                lead_isTicketOpen: true
                lead_assignedAttendant_id: att_123456
        '400':
          description: Invalid payload
        '404':
          description: Chat not found
        '500':
          description: Internal server error
components:
  schemas:
    Chat:
      type: object
      description: Represents a conversation/ticket in the system
      properties:
        id:
          type: string
          description: Unique conversation ID (r + 7 random bytes in hex)
        wa_fastid:
          type: string
          description: WhatsApp fast identifier
        wa_chatid:
          type: string
          description: Full chat ID on WhatsApp
        wa_chatlid:
          type: string
          description: Chat LID on WhatsApp (when available)
        wa_archived:
          type: boolean
          description: Indicates whether the chat is archived
          default: false
        wa_contactName:
          type: string
          description: >
            Name saved in the phone's address book for this number (empty: not
            saved). The conversation is created with it (by LID, via the linked
            number) and it changes when the contact is saved or deleted on the
            phone.
          default: ''
        wa_name:
          type: string
          description: >
            Name set by the user in the WhatsApp profile ("push name").

            Comes from the contact's profile and may not be available depending
            on the context or data source.
          default: ''
        name:
          type: string
          description: >
            Name resolved by the system as a fallback.

            It usually consolidates the best value available among internal
            data, the name coming from WhatsApp and the name saved in contacts.

            Therefore, it is more likely to be filled in.
          default: ''
        image:
          type: string
          description: Chat image URL
          default: ''
        imagePreview:
          type: string
          description: Image thumbnail URL
          default: ''
        parent_community:
          type: object
          description: Parent community of the chat when it represents a subgroup
          properties:
            jid:
              type: string
              format: jid
            name:
              type: string
            image_url:
              type: string
            image_preview_url:
              type: string
            default_subgroup_jid:
              type: string
              format: jid
        wa_ephemeralExpiration:
          type: integer
          format: int64
          description: Expiration time for ephemeral messages
          default: 0
        wa_isBlocked:
          type: boolean
          description: Indicates whether the contact is blocked
          default: false
        wa_isGroup:
          type: boolean
          description: Indicates whether it is a group
          default: false
        wa_isGroup_admin:
          type: boolean
          description: Indicates whether the user is a group admin
          default: false
        wa_isGroup_announce:
          type: boolean
          description: Indicates whether it is an announcement-only group
          default: false
        wa_isGroup_community:
          type: boolean
          description: Indicates whether it is a community
          default: false
        wa_isGroup_member:
          type: boolean
          description: Indicates whether is a group member
          default: false
        wa_isPinned:
          type: boolean
          description: Indicates whether the chat is pinned
          default: false
        wa_label:
          type: array
          description: Chat labels
          items:
            type: string
        wa_notes:
          type: string
          description: Internal chat notes synced via app state
          default: ''
        wa_lastMessageTextVote:
          type: string
          description: Text/vote of the last message
          default: ''
        wa_lastMessageType:
          type: string
          description: Type of the last message
          default: ''
        wa_lastMsgTimestamp:
          type: integer
          format: int64
          description: Timestamp of the last message
          default: 0
        wa_lastMessageSender:
          type: string
          description: Sender of the last message
          default: ''
        lead_awaitingReply:
          type: boolean
          readOnly: true
          description: >-
            `true` when the contact is awaiting a reply: the last message is
            theirs and no one has resolved the conversation (`POST
            /lead/resolve`). The contact's message turns it on; ours (you, the
            AI, a flow, or an integration) turns it off. In conversations
            predating this field, the api decides based on the sender (the
            instance's number or LID). Only in conversations with people: absent
            in groups and channels, which are not included in either filter, and
            when the conversation has no known last message (only the date).
            Filterable in `/chat/find`.
        wa_muteEndTime:
          type: integer
          format: int64
          description: Timestamp of the end of muting
          default: 0
        owner:
          type: string
          description: Instance owner
          default: ''
        wa_unreadCount:
          type: integer
          format: int64
          description: Unread message counter
          default: 0
        phone:
          type: string
          description: Phone number
          default: ''
        common_groups:
          type: string
          description: 'Groups in common separated by commas, format: (group_name)group_id'
          default: ''
          example: Family Group(120363123456789012@g.us),Work(987654321098765432@g.us)
        lead_name:
          type: string
          description: Lead name
          default: ''
        lead_fullName:
          type: string
          description: Lead's full name
          default: ''
        lead_email:
          type: string
          description: Lead email
          default: ''
        lead_personalid:
          type: string
          description: Identification document
          default: ''
        lead_status:
          type: string
          description: Free-form lead status
          default: ''
        lead_tags:
          type: array
          description: |
            Lead tags. Tags configured with `kanban=true` also determine the
            columns in which the card appears in the Kanban.
          items:
            type: string
        lead_notes:
          type: string
          description: Notes about the lead
          default: ''
        lead_isTicketOpen:
          type: boolean
          description: Indicates whether there is an open ticket
          default: false
        lead_assignedAttendant_id:
          type: string
          description: ID of the responsible attendant
          default: ''
        lead_kanbanOrder:
          type: integer
          format: int64
          description: Order in the kanban
          default: 0
        lead_field01:
          type: string
          default: ''
        lead_field02:
          type: string
          default: ''
        lead_field03:
          type: string
          default: ''
        lead_field04:
          type: string
          default: ''
        lead_field05:
          type: string
          default: ''
        lead_field06:
          type: string
          default: ''
        lead_field07:
          type: string
          default: ''
        lead_field08:
          type: string
          default: ''
        lead_field09:
          type: string
          default: ''
        lead_field10:
          type: string
          default: ''
        lead_field11:
          type: string
          default: ''
        lead_field12:
          type: string
          default: ''
        lead_field13:
          type: string
          default: ''
        lead_field14:
          type: string
          default: ''
        lead_field15:
          type: string
          default: ''
        lead_field16:
          type: string
          default: ''
        lead_field17:
          type: string
          default: ''
        lead_field18:
          type: string
          default: ''
        lead_field19:
          type: string
          default: ''
        lead_field20:
          type: string
          default: ''
        chatbot_agentResetMemoryAt:
          type: integer
          format: int64
          description: >-
            AI memory start (ms): the agent only reads the conversation messages
            from this point on. 0: no cutoff (the agent's window applies). Set
            via `/chat/editLead`.
          default: 0
        chatbot_lastTrigger_id:
          type: string
          description: ID of the last executed trigger
          default: ''
        chatbot_lastTriggerAt:
          type: integer
          format: int64
          description: Timestamp of the last trigger
          default: 0
        chatbot_disableUntil:
          type: integer
          format: int64
          description: >-
            Automation (AI, triggers, and flows) paused in this conversation
            until this time, in milliseconds. `-1`: until someone turns it back
            on; `0`: on.
          default: 0
        chatbot_summary:
          type: string
          description: >-
            Reason for the pause made by the automation: human request (AI or
            flow; paused until someone turns it back on) or AI reply limit
            (1-hour pause). Empty when there is no pause or after it ends.
            Turning it back on (`chatbot_disableUntil: 0` in `/chat/editLead`)
            or resolving (`POST /lead/resolve`) clears it.
          default: ''
  securitySchemes:
    token:
      name: token
      type: apiKey
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.