# Clean lemlist Leads Before You Send

URL: https://email-validation.org/docs/guides/lemlist/
Updated: 2026-11-27

> Documentation index: https://email-validation.org/llms.txt

Check the leads of a lemlist campaign before you send, and write each lead's status into its custom variables, so
you can leave out the leads you should not mail. The script reads the leads, checks them as one bulk list, tells you
what it will cost and asks before it spends anything. It never deletes a lead, never removes one from a campaign,
never pauses or unsubscribes one, and never changes any other field. Download it:
[lemlist.mjs](https://email-validation.org/downloads/lemlist/lemlist.mjs), one file.

## What you need

- **A computer with Node 22.18 or later.** The script has no browser-only option. Nothing to install: it has no
  dependencies. With only a browser, export the leads from lemlist as a CSV file and upload it as a
  [bulk list](https://email-validation.org/docs/bulk/) on our site instead; you then act on the results file yourself.
- An API key of ours from the [API keys page](https://email-validation.org/app/api-keys/) with the permission **Bulk lists** (off by default:
  turn it on when you create the key). With **Read balance and usage** too, the script shows your balance before it
  asks.
- A lemlist API key: in lemlist, Settings → Integrations → Generate a new API key. The key acts as the user who made
  it; for leads without a contact, that user needs lemlist's "Create contacts" permission (see below).

## Run it

```bash
export EV_API_KEY=…  LEMLIST_API_KEY=…
node lemlist.mjs --lists                     # your campaigns, with their ids and lead counts
node lemlist.mjs --campaign <id> --dry-run   # what it would check and the most it would cost; spends nothing
node lemlist.mjs --campaign <id>             # asks, then checks and writes the statuses back
node lemlist.mjs --campaign <id> --yes       # without asking (for a scheduled run)
```

Before it spends, the script shows the leads it will check, the distinct addresses, the most credits it will use
(one per distinct address; `unknown` results, duplicates and malformed addresses are free) and your balance, and asks
you to confirm. With `--yes` it goes on without asking; without a terminal and without `--yes` it stops before
spending.

It checks the leads that have an address and no status yet (or the status `unknown`), and skips bounced and
unsubscribed leads. `--revalidate` also checks leads that already have a status; `--all-leads` also checks bounced
and unsubscribed ones. `--region eu` checks and keeps the list in the EU. `--rate N` sets how many lemlist requests
it sends a second (5 by default, at most 10: lemlist allows 20 every 2 seconds for each API key).

## What it writes

| Lead variable | Value |
|---|---|
| `email_validation_status` | `valid`, `invalid`, `catch_all`, `unknown` or `disposable` ([statuses](https://email-validation.org/docs/statuses/)) |
| `email_validation_action` | `send`, `send_with_caution`, `remove` or `retry_later` |
| `email_validation_checked_at` | when the results were written, in UTC |
| `email_validation_address_hash` | a hash of the checked address (the first 32 hex digits of its SHA-256, trimmed and lower-cased), never the address: when it no longer matches the lead's address, the values are for an older address and the next run checks the new one |

Leave out the leads whose `email_validation_action` is `remove`: that includes spam traps and complainers, which are
`valid` with the action `remove`. A new check replaces the old values. The script writes only these four variables,
so every other variable of the lead keeps its value. A lead whose address changed since the check is not written; the
next run checks its new address.

On a lead with no linked contact, lemlist itself creates the lead's contact (and may link it to a company) from the
lead's details when a variable is written; nothing is deleted or overwritten. If the key's user may not create
contacts, lemlist refuses those leads: the script counts them, writes the others, and stops after ten such refusals in
a row so you can give the user the permission and run it again.

## Run it again

Run the same command again after any stop (no credits, a closed laptop, the bulk list still running): it resumes the
same bulk list and never pays twice (within the 30 days a list is kept). Leads already written are skipped. When every lead is written, the next run
checks only leads without a status for their address now (or with `unknown`), such as new ones and leads whose
address changed, so you can run it on a schedule with
`--yes`. Run it from the same folder each time (or pass the same `--state FILE`): the file it keeps there holds
the bulk list it is working on.

Exit codes: `0` done, `1` a write failed or the run stopped (run it again), `2` wrong arguments, `75` the bulk list
was still running when the script stopped waiting (run it again later).

The script prints counts, ids and the campaign's name, never an address or a key.

## More on lemlist

- [lemlist integration](https://email-validation.org/integrations/lemlist/)
