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

> Add contacts to a static contact list, or remove them with ?action=remove.

# Add or Remove Contacts in a List

Adds existing CRM contacts to a **static** contact list, or removes them when you set `?action=remove`. The list must be a static contact list (`clt_xxx`); dynamic lists (auto-populated by filter rules) and company lists are rejected.

<Warning>
  **Removal uses `POST ?action=remove`, not `DELETE`.** A `DELETE` request body is dropped by our stack, so `DELETE` on this path is not supported and returns `405 Method Not Allowed`.
</Warning>

<Note>
  Removing a contact from a list only affects list **membership** — it does not delete the contact from your CRM.
</Note>

## Add vs remove

| Action     | Request                                              | Result                                                                                                                    |
| ---------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **Add**    | `POST` with `{ "contactIds": [...] }`                | Contacts are added. Those already in the list are silently skipped (counted in `alreadyInList`).                          |
| **Remove** | `POST ?action=remove` with `{ "contactIds": [...] }` | Contacts are removed. Those not in the list are silently skipped (`removedCount` reflects associations actually removed). |

## Typical workflow

1. **Find or create a list** — use `GET /contacts/lists` to find an existing static list, or `POST /contacts/lists` to create one (`clt_xxx`).
2. **Find contacts** — use `GET /contacts` with `search`, `email`, or `listId` to get contact IDs (`ctc_xxx`).
3. **Add or remove** — call this endpoint with the contact IDs and list ID. Up to 1,000 contacts per request.


## OpenAPI

````yaml post /contacts/lists/{listId}/entities
openapi: 3.0.0
info:
  title: lemlist API
  version: 1.0.0
  description: >-
    Welcome to the lemlist Developer Documentation.


    lemlist is very customizable and open. You'll find on this page all the API
    and integration you can do with lemlist.


    # Rate Limit


    lemlist's API rate limits requests in order to prevent abuse and overload of
    our services.  

    Rate limits are applied on all routes and per API key performing the
    request.  

    The rate limits are **20** requests per **2** seconds.  

    The response provides any information you may need about it:


    | Header | Description |

    | --- | --- |

    | Retry-After | The number of seconds in which you can retry |

    | X-RateLimit-Limit | The maximum requests in that time |

    | X-RateLimit-Remaining | The number of remaining requests you can make |

    | X-RateLimit-Reset | The date when the rate limit will reset |


    _Example of values for the rate limit headers_


    ``` json

    {
        "Retry-After": 2,
        "X-RateLimit-Limit": 20,
        "X-RateLimit-Remaining": 7,
        "X-RateLimit-Reset" : "Tue Feb 16 2021 09:02:42 GMT+0100 (Central European Standard Time)"
    }

     ```

    # Definitions


    ## Team


    A team is the entity of lemlist that can handle users and billing.


    ## Credits


    Credits are the coins a team uses to enrich emails, LinkedIn URLs, etc. via
    the enrich route. Each enrichment feature needs a certain amount of credits
    to run.


    ## User


    You use a user account to connect to lemlist and send messages via the
    connected emails or LinkedIn account.


    ## Campaign


    A campaign is the entity to automate outreach. A campaign has multiple
    sequences composed of steps.


    ## Lead


    A lead is a person that you try to contact via a campaign.


    ## Activity


    An activity is the history of all the steps.


    ## Unsubscribe


    An unsubscribe occurs when a person decides they don't want to receive
    emails from you anymore.


    # Authentication


    All API routes use the dedicated subdomain `api.lemlist.com`.


    lemlist uses API keys to allow access to the API. You can get your lemlist
    API key at our [integration
    page](https://app.lemlist.com/settings/integrations).


    You need to add the `Authorization` header using the `Basic` authentication
    type. `login:password` **where the login is always empty and the password is
    the API key**.


    ⚠️ **Don't forget to add the semicolon (**`:`**) before your API key in curl
    command.**


    > To authorize, use this code: 
      

    ``` shell

    curl https://api.lemlist.com/api/team \
      --user ":YourApiKey"

     ```

    **Make sure to replace** **`YourApiKey`** **with your API key.**


    # Give feedback


    If you want to report a bug, ask for data, or share with us a use case,
    please fill this [form](https://lemlist.typeform.com/to/mfVlkyGf). It will
    help us centralize your needs!
servers:
  - url: https://api.lemlist.com/api
security:
  - basicAuth: []
paths:
  /contacts/lists/{listId}/entities:
    parameters:
      - name: listId
        in: path
        required: true
        description: >-
          The unique identifier of the contact list (`clt_xxx` format). Must be
          a **static** contact list.
        example: clt_xxxxxxxxxxxxxxxxx
        schema:
          type: string
          pattern: ^clt_[a-zA-Z0-9]+$
    post:
      tags:
        - Contacts
      summary: Add or Remove Contacts in a List
      description: >-
        Adds existing CRM contacts to a static contact list, or removes them
        when `?action=remove` is set.


        - **Add** (default): send a `POST` with a `contactIds` body. Contacts
        already in the list are silently skipped (no duplicates) and reported in
        `alreadyInList`.

        - **Remove**: send a `POST` with `?action=remove` and a `contactIds`
        body. Contacts that are not in the list are silently skipped;
        `removedCount` reflects the associations actually removed. This only
        affects list membership, the contacts are not deleted from your CRM.


        The list must be a **static** contact list (`clt_xxx`). Dynamic lists
        (auto-populated by filter rules) and company lists are rejected.


        **Removal uses `POST ?action=remove` on purpose:** a `DELETE` request
        body is dropped by our stack, so `DELETE` on this path is **not
        supported** and returns `405 Method Not Allowed`.
      parameters:
        - name: action
          in: query
          required: false
          description: >-
            Omit to **add** the contacts to the list. Set to `remove` to
            **remove** them from the list.
          example: remove
          schema:
            type: string
            enum:
              - remove
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contactIds
              properties:
                contactIds:
                  type: array
                  items:
                    type: string
                    pattern: ^ctc_[a-zA-Z0-9]+$
                  minItems: 1
                  maxItems: 1000
                  description: >-
                    Array of contact IDs (`ctc_xxx` format) to add to or remove
                    from the list. Required, non-empty, maximum 1,000 per
                    request.
            example:
              contactIds:
                - ctc_xxxxxxxxxxxxxxxxx
                - ctc_yyyyyyyyyyyyyyyyy
      responses:
        '200':
          description: >-
            Contacts added to or removed from the list successfully. The
            response body depends on `action`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  addedCount:
                    type: integer
                    description: Number of contacts added to the list (add only).
                  alreadyInList:
                    type: integer
                    description: >-
                      Number of contacts that were already in the list and
                      therefore skipped (add only).
                  removedCount:
                    type: integer
                    description: >-
                      Number of list associations actually removed (remove
                      only). Contacts that were not in the list are not counted.
              examples:
                add:
                  summary: Add contacts (no action)
                  value:
                    message: Contacts added to list successfully
                    addedCount: 2
                    alreadyInList: 0
                remove:
                  summary: Remove contacts (action=remove)
                  value:
                    message: Contacts removed from list successfully
                    removedCount: 2
        '400':
          description: >-
            Possible errors: Bad team / Invalid listId format (expected clt_xxx)
            / contactIds is required and must be a non-empty array / Maximum
            1,000 contacts per request / All contactIds must be in ctc_xxx
            format / List is not a contact list / Cannot manually add contacts
            to a dynamic list / Cannot manually remove contacts from a dynamic
            list.
          content:
            text/plain:
              example: contactIds is required and must be a non-empty array
        '401':
          description: The authentication you supplied is incorrect
          content:
            text/plain:
              example: The authentication you supplied is incorrect
        '404':
          description: Contact list not found
          content:
            text/plain:
              example: Contact list not found
        '405':
          description: >-
            Method not allowed. `DELETE` on this path is not supported because
            the request body is dropped by our stack. Use `POST ?action=remove`
            to remove contacts.
          content:
            text/plain:
              example: Method not allowed
        '500':
          description: Internal error while updating the list
          content:
            text/plain:
              example: Failed to add contacts to list
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````