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

# Lemlist Lead Operations: Inputs, Cost & CLI Example

> Exporting leads from a Lemlist campaign with state filtering. Includes inputs, outputs, pricing notes, Deepline CLI examples, and GTM automation guidance.

## Run in Enrichment Spreadsheet

<Info>
  Use this function as a column step in `deepline enrich`.
</Info>

```bash theme={null}
deepline enrich --input leads.csv --output leads.enriched.csv --with 'result=lemlist_export_campaign_leads:{"campaign_id":"{{campaign_id}}"}' --json
```

<Tip>
  Map payload values to spreadsheet columns with `{{column_name}}` placeholders.
</Tip>

## Input Schema

| Name                  | Type                                                                                                                                                                                                       | Required | Default | Description                     |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- | ------------------------------- |
| `payload.campaign_id` | `string`                                                                                                                                                                                                   | Yes      |         | Campaign ID                     |
| `payload.state`       | `"all" \| "contacted" \| "interested" \| "notInterested" \| "emailsBounced" \| "paused" \| "emailsSent" \| "emailsOpened" \| "emailsClicked" \| "emailsReplied" \| "emailsUnsubscribed" \| "emailsFailed"` | No       |         | Lead state filter. Default: all |

### Allowed values

| Field           | Allowed values                                                                                                                                                                     |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `payload.state` | `all`, `contacted`, `interested`, `notInterested`, `emailsBounced`, `paused`, `emailsSent`, `emailsOpened`, `emailsClicked`, `emailsReplied`, `emailsUnsubscribed`, `emailsFailed` |

<details>
  <summary>Show raw input schema</summary>

  ### Input JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "description": "Export leads from a Lemlist campaign.",
    "properties": {
      "campaign_id": {
        "type": "string",
        "description": "Campaign ID",
        "minLength": 1
      },
      "state": {
        "type": "string",
        "description": "Lead state filter. Default: all",
        "enum": [
          "all",
          "contacted",
          "interested",
          "notInterested",
          "emailsBounced",
          "paused",
          "emailsSent",
          "emailsOpened",
          "emailsClicked",
          "emailsReplied",
          "emailsUnsubscribed",
          "emailsFailed"
        ]
      }
    },
    "required": [
      "campaign_id"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output Schema

| Name            | Type     | Required | Default | Description |
| --------------- | -------- | -------- | ------- | ----------- |
| `result.status` | `string` | Yes      |         |             |
| `result.result` | `array`  | Yes      |         |             |

<details>
  <summary>Show raw output schema</summary>

  ### Output JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "status": {
        "type": "string"
      },
      "result": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "_id": {
              "type": "string"
            },
            "firstName": {
              "type": "string"
            },
            "lastName": {
              "type": "string"
            },
            "linkedinUrl": {
              "type": "string"
            },
            "jobTitle": {
              "type": "string"
            },
            "companyName": {
              "type": "string"
            },
            "companyDomain": {
              "type": "string"
            },
            "state": {
              "type": "string"
            },
            "stateSystem": {
              "type": "string"
            }
          },
          "required": [
            "_id",
            "firstName",
            "lastName",
            "linkedinUrl",
            "jobTitle",
            "companyName",
            "companyDomain",
            "state",
            "stateSystem"
          ],
          "additionalProperties": true
        }
      }
    },
    "required": [
      "status",
      "result"
    ],
    "additionalProperties": true
  }
  ```
</details>

## Advanced: Direct CLI

<Info>
  Use direct execution for single payload debugging.
</Info>

```bash theme={null}
deepline tools execute lemlist_export_campaign_leads --payload '{
  "campaign_id": "string"
}' --json
```

### CLI flags

| Flag                        | Description                                         |
| --------------------------- | --------------------------------------------------- |
| `--json`                    | Print machine-readable output.                      |
| `--wait`                    | Wait for terminal provider status when supported.   |
| `--debug`                   | Enable wait mode with additional status/log output. |
| `--wait-timeout SECONDS`    | Max seconds to wait in wait mode.                   |
| `--poll-interval SECONDS`   | Polling interval in seconds during wait mode.       |
| `--timeout SECONDS`         | Request timeout in seconds.                         |
| `--connect-timeout SECONDS` | Connection timeout in seconds.                      |

## Provider API Context

<details>
  <summary>Show provider reference (optional)</summary>

  ````md theme={null}
  > 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

  &lt;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 &lt;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 &lt;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 &lt;encoded-value>'
    ```
  &lt;/CodeGroup>

  &lt;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.
  &lt;/Tip>

  ## 05. Get Campaign Export Status

  Source: https://developer.lemlist.com/api-reference/endpoints/campaigns/get-campaign-export-status.md
  ````
</details>

## Cost

* Pricing model: `fixed` (per call).
* Estimated Deepline credits: `0` per pricing unit.
* Provider-native pricing may still exist outside Deepline credit billing.
* Billing mode: `no_bill`.
