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

> Exports leads from a campaign with flexible filtering and format options.

# Export Campaign Leads

The export returns leads in CSV or JSON format based on their state.

## Filtering by state

Use the `state` parameter to filter leads by their current status. You can:

* Export all leads: `state=all`
* Filter by specific states: `state=emailsOpened,emailsReplied`
* Use multiple states: `state=interested,warmed`

### Global states

These group multiple lead states into a single category:

| State                | Description                                                                  |
| -------------------- | ---------------------------------------------------------------------------- |
| `imported`           | Leads imported without processing (not scanned, no steps sent, not reviewed) |
| `scanned`            | Leads scanned by LinkedIn or email verification                              |
| `skipped`            | Leads skipped during review                                                  |
| `reviewed`           | Leads that were reviewed                                                     |
| `contacted`          | Leads that were contacted (at least one step executed, no response yet)      |
| `hooked`             | Leads that opened an email or LinkedIn message                               |
| `attracted`          | Leads that clicked in an email or accepted a LinkedIn invite                 |
| `warmed`             | Leads that replied to an email or LinkedIn message                           |
| `interested`         | Leads marked as interested                                                   |
| `notInterested`      | Leads marked as not interested                                               |
| `emailsBounced`      | Leads where at least one step bounced or failed                              |
| `emailsUnsubscribed` | Leads that unsubscribed                                                      |
| `meetingBooked`      | Leads that booked a meeting                                                  |
| `paused`             | Leads that were paused                                                       |

### Detailed states

For more granular filtering:

| State                    | Description                               |
| ------------------------ | ----------------------------------------- |
| `emailsSent`             | Email was sent                            |
| `emailsOpened`           | Lead opened an email                      |
| `emailsClicked`          | Lead clicked on an email                  |
| `emailsReplied`          | Lead replied to an email                  |
| `emailsInterested`       | Lead marked as success via email          |
| `emailsNotInterested`    | Lead marked as not a success via email    |
| `emailsFailed`           | Error sending email                       |
| `linkedinVisitDone`      | LinkedIn profile was visited              |
| `linkedinInviteDone`     | LinkedIn invitation was sent              |
| `linkedinInviteAccepted` | LinkedIn invitation was accepted          |
| `linkedinSent`           | LinkedIn message was sent                 |
| `linkedinOpened`         | LinkedIn message was opened               |
| `linkedinReplied`        | Lead replied on LinkedIn                  |
| `linkedinInterested`     | Lead marked as success via LinkedIn       |
| `linkedinNotInterested`  | Lead marked as not a success via LinkedIn |

## Output format

Use the `format` parameter to choose between:

* **`csv`** (default): Returns a CSV file suitable for Excel, Google Sheets, etc.
* **`json`**: Returns structured JSON data for programmatic processing

## Examples

<CodeGroup>
  ```bash Export all leads as CSV theme={"theme":"dracula"}
  curl --request GET \
    --url 'https://api.lemlist.com/api/campaigns/cam_123/export/leads?state=all' \
   --header 'Authorization: Basic <encoded-value>'
  ```

  ```bash Export interested leads as JSON theme={"theme":"dracula"}
  curl --request GET \
    --url 'https://api.lemlist.com/api/campaigns/cam_123/export/leads?state=interested&format=json' \
   --header 'Authorization: Basic <encoded-value>'
  ```

  ```bash Export multiple states theme={"theme":"dracula"}
  curl --request GET \
    --url 'https://api.lemlist.com/api/campaigns/cam_123/export/leads?state=emailsOpened,emailsReplied,interested' \
    --header 'Authorization: Basic <encoded-value>'
  ```
</CodeGroup>

<Tip>
  Use global states like `hooked` or `warmed` to quickly segment leads by engagement level, or use detailed states for precise filtering based on specific actions.
</Tip>


## OpenAPI

````yaml get /campaigns/{campaignId}/export/leads
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:
  /campaigns/{campaignId}/export/leads:
    parameters:
      - name: campaignId
        in: path
        required: true
        description: The unique identifier of the campaign
        example: cam_A1B2C3D4E5F6G7H8I9
        schema:
          type: string
    get:
      tags:
        - Campaigns
      summary: Export Campaign Leads
      description: >-
        Export leads from a campaign with filtering options. Returns leads in
        CSV or JSON format based on their state (e.g., contacted, interested,
        replied, etc.).
      parameters:
        - name: state
          in: query
          required: false
          description: >-
            Filter to export only the specified lead's last states. Use 'all' to
            export all states. Can be a comma-separated list of states. **Global
            states**: imported, scanned, skipped, reviewed, contacted, hooked,
            attracted, warmed, interested, notInterested, emailsBounced,
            emailsUnsubscribed, failed, meetingBooked, paused. **Detailed
            states**: emailsSent, emailsOpened, emailsClicked, emailsReplied,
            emailsInterested, emailsNotInterested, emailsFailed,
            opportunitiesDone, aircallDone, aircallInterested,
            aircallNotInterested, apiDone, apiInterested, apiNotInterested,
            linkedinVisitDone, linkedinVisitFailed, linkedinInviteDone,
            linkedinInviteAccepted, linkedinInviteFailed, linkedinSent,
            linkedinOpened, linkedinReplied, linkedinInterested,
            linkedinNotInterested, linkedinSendFailed, manualInterested,
            manualNotInterested
          example: all
          schema:
            type: string
            enum:
              - all
              - imported
              - scanned
              - skipped
              - reviewed
              - contacted
              - hooked
              - attracted
              - warmed
              - interested
              - notInterested
              - emailsBounced
              - emailsUnsubscribed
              - failed
              - meetingBooked
              - paused
              - emailsSent
              - emailsOpened
              - emailsClicked
              - emailsReplied
              - emailsInterested
              - emailsNotInterested
              - emailsFailed
              - opportunitiesDone
              - aircallDone
              - aircallInterested
              - aircallNotInterested
              - apiDone
              - apiInterested
              - apiNotInterested
              - linkedinVisitDone
              - linkedinVisitFailed
              - linkedinInviteDone
              - linkedinInviteAccepted
              - linkedinInviteFailed
              - linkedinSent
              - linkedinOpened
              - linkedinReplied
              - linkedinInterested
              - linkedinNotInterested
              - linkedinSendFailed
              - manualInterested
              - manualNotInterested
            default: all
        - name: format
          in: query
          required: false
          description: 'Output format: ''json'' or ''csv''. Default is CSV.'
          example: json
          schema:
            type: string
            enum:
              - json
              - csv
      responses:
        '200':
          description: Leads exported successfully
          content:
            text/csv:
              example: >-
                emailStatus,email,firstName,lastName,picture,phone,linkedinUrl,timezone,companyName,companyDomain,icebreaker,Original
                event page,url
                extension,event_link_to_send,testFieldToDelete,naissance,lastState,status,_id

                ,jeremy@example.com,Jeremy,Smith,,,https://www.linkedin.com/in/jeremysmith,,example.com,,,https://www.example.com/event-registration,?name=Jeremy&email=jeremy@example.com,https://www.example.com/event-registration?name=Jeremy&email=jeremy@example.com,,,linkedinReplied,done,lea_s2cXajAHahdDKmDw8

                ,frankie@example.org,Frankie,Johnson,,,https://www.linkedin.com/in/frankiejohnson,,example.org,,,https://www.example.com/event-registration,?name=Frankie&email=frankie@example.org,https://www.example.com/event-registration?name=Frankie&email=frankie@example.org,,,linkedinReplied,done,lea_E8hdds5NryDRXpGJa

                ,louiza@example.io,Louiza,Brown,,,https://www.linkedin.com/in/louizabrown,,example.io,,,https://www.example.com/event-registration,?name=Louiza&email=louiza@example.io,https://www.example.com/event-registration?name=Louiza&email=louiza@example.io,,,emailsInterested,interested,lea_tLAI7Fr2gR5hVxAIc

                ,benjamin@example.co,Benjamin,Williams,,,https://www.linkedin.com/in/benjaminwilliams,,example.co,,,https://www.example.com/event-registration,?name=Benjamin&email=benjamin@example.co,https://www.example.com/event-registration?name=Benjamin&email=benjamin@example.co,,,emailsUnsubscribed,unsubscribed,lea_oznzWQKKZGXrBdqXb

                ,roxanne@example.net,Roxanne,Davis,,,https://www.linkedin.com/in/roxannedavis,,example.net,,,https://www.example.com/event-registration,?name=Roxanne&email=roxanne@example.net,https://www.example.com/event-registration?name=Roxanne&email=roxanne@example.net,,,emailsClicked,done,lea_M22nl3gUwvAiNl6Ks

                ,thomas@example.fr,Thomas,Miller,,,https://www.linkedin.com/in/thomasmiller,,example.fr,,,https://www.example.com/event-registration,?name=Thomas&email=thomas@example.fr,https://www.example.com/event-registration?name=Thomas&email=thomas@example.fr,,,emailsSent,done,lea_z3DydraGgNBnLdV7o
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    emailStatus:
                      type: string
                      enum:
                        - deliverable
                        - risky
                        - undeliverable
                    email:
                      type: string
                      format: email
                    firstName:
                      type: string
                    lastName:
                      type: string
                    picture:
                      type: string
                    phone:
                      type: string
                    linkedinUrl:
                      type: string
                    timezone:
                      type: string
                    companyName:
                      type: string
                    companyDomain:
                      type: string
                    icebreaker:
                      type: string
                    jobTitle:
                      type: string
                    lastState:
                      type: string
                    status:
                      type: string
                    _id:
                      type: string
        '400':
          description: Bad team
          content:
            text/plain:
              example: Bad team
        '401':
          description: Unauthorized
        '404':
          description: Campaign not found
          content:
            text/plain:
              example: Campaign not found
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````