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

> Links a campaign to a filter of your connected CRM and imports its records as leads, now and as the filter picks up new ones.

# Import Leads from CRM

<Note>
  Only a campaign that is not linked to a CRM filter yet can be linked. To change or unlink a campaign's CRM filter, use the lemlist app.
</Note>

Get the filter ID from [Get CRM Filters](/api-reference/endpoints/crm/get-crm-filters).


## OpenAPI

````yaml post /campaigns/{campaignId}/leads/import
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: []
tags:
  - name: Enrichment Providers
    description: >-
      The data providers lemlist can call to find an email or a phone.


      Internal providers are paid with lemlist credits and always available.
      External providers run on your own account: connect one by saving its API
      key, and it becomes available to your waterfalls. `GET
      /enrichments/providers` is the catalog of provider ids accepted by the
      waterfall endpoints.
  - name: Enrichment Waterfalls
    description: >-
      Control which data providers lemlist calls when enriching a contact, and
      in which order.


      A waterfall is an ordered list of providers for one enrichment `type`
      (`email` or `phone`). Providers are tried one after the other until one
      returns a result.


      Every team has exactly one default waterfall per type (`isDefault: true`).
      While its `editor` is `lemlist` it follows the lemlist behaviour:
      providers you connected with your own API key are tried first, then
      internal providers in a random order. Once a team member edits its
      provider list, `editor` becomes that user's id and the list is followed as
      is; resetting it hands it back to `lemlist`.


      Custom waterfalls (`isDefault: false`) carry `conditions` on the contact
      being enriched, keyed by contact property; every key present must match.
      When a contact is enriched, lemlist runs a single waterfall: the custom
      waterfall of the requested type whose conditions match the contact, or the
      default waterfall when none does. If several match, the one with the most
      condition keys wins, then the most recently updated. Only that waterfall
      runs; when it finds nothing, the enrichment ends without falling back to
      another one.
paths:
  /campaigns/{campaignId}/leads/import:
    parameters:
      - name: campaignId
        in: path
        required: true
        description: The unique identifier of the campaign
        example: cam_A1B2C3D4E5F6G7H8I9
        schema:
          type: string
    post:
      tags:
        - Leads
      summary: Import Leads from CRM
      description: >-
        Links a campaign to a filter of your connected CRM and imports its
        records as leads.


        **Recurring:** the campaign stays linked to the filter, and the records
        the filter picks up later are imported automatically.


        **New link only:** the campaign must not be linked to a CRM filter yet.
        Changing or unlinking a campaign's CRM filter is done in the lemlist
        app.


        The filter is checked in your CRM before anything is saved. The import
        runs in the background: leads appear over the next minutes, not in the
        response.


        **Credits:** the enrichments requested in `enrichFeature` run on every
        imported lead, now and later, and are charged to the user of the API
        key.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                filterId:
                  oneOf:
                    - type: string
                    - type: number
                  description: >-
                    Filter ID returned by [Get CRM
                    Filters](/api-reference/endpoints/crm/get-crm-filters)
                filterType:
                  type: string
                  enum:
                    - lead
                    - contact
                    - report
                  description: >-
                    Salesforce only: `lead` or `contact` list views, or
                    `report`. Ignored by HubSpot and Pipedrive. Defaults to
                    `lead` when your Salesforce connection allows Leads,
                    `contact` otherwise.
                userId:
                  type: string
                  description: >-
                    Salesforce only, for a list view scoped to its owner ("My
                    leads", "My contacts"…): the team member the view is read
                    as. They must have their own Salesforce account connected in
                    lemlist. Leave it out in every other case (reports, views
                    not scoped to an owner); it is ignored for HubSpot and
                    Pipedrive, where your team's CRM connection is used.
                deduplicate:
                  oneOf:
                    - type: boolean
                    - type: string
                      enum:
                        - 'off'
                        - all
                        - activeOnly
                  description: >-
                    `all` (or `true`) skips contacts already in another
                    campaign, `activeOnly` skips only contacts still active in
                    another campaign, `off` (or `false`, the default) imports
                    everyone.
                enrichFeature:
                  oneOf:
                    - type: array
                      items:
                        type: string
                        enum:
                          - find_email
                          - find_phone
                          - verify
                          - linkedin_enrichment
                    - type: string
                  description: >-
                    Enrichments to run on every imported lead, as an array or a
                    `|`-separated string (e.g. `find_email|verify`). Consumes
                    credits for each lead.
              required:
                - filterId
            example:
              filterId: '16'
              deduplicate: all
              enrichFeature:
                - find_email
      responses:
        '200':
          description: >-
            The campaign is linked to the filter; the import runs in the
            background.
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
              example:
                ok: true
        '400':
          description: >-
            The request was refused; `error` explains why (e.g. `This campaign
            already imports from a CRM filter: ...`, `CRM filter not found:
            ...`, `CRM not connected: ...`, `User not in team`, `Bad params`,
            `Unsupported enrichment features`, `Upgrade your plan to use this
            feature`, or a credit refusal for the requested enrichments).
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: >-
                  This campaign already imports from a CRM filter: change or
                  unlink it in lemlist
        '401':
          description: The authentication you supplied is incorrect
          content:
            text/plain:
              example: The authentication you supplied is incorrect
        '404':
          description: Campaign not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: Campaign not found
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````

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