Integrations · Sales outreach

Clean Instantly leads before you send

Check the leads of an Instantly campaign or lead list before you send, and write each lead's status into its custom variables, so your campaigns 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 or list, and never changes any other field. Download it: instantly.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 Instantly as a CSV file and upload it as a bulk list on our site instead; you then act on the results file yourself.
  • An API key of ours from the API keys page 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.
  • An Instantly plan with API access (Instantly includes it in its paid plans; its pricing does not list it for the free trial). An Instantly API key: in Instantly, Settings → Integrations → API Keys → Create API Key, with the scopes campaigns:read, lead_lists:read, leads:read and leads:update. If Instantly refuses the lead counts, use all:read with leads:update. The key never needs a delete scope.

Run it

export EV_API_KEY=…  INSTANTLY_API_KEY=…
node instantly.mjs --lists                     # your campaigns and lead lists, with their ids and lead counts
node instantly.mjs --campaign <id> --dry-run   # what it would check and the most it would cost; spends nothing
node instantly.mjs --campaign <id>             # asks, then checks and writes the statuses back
node instantly.mjs --list <id> --yes           # a lead list, 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 Instantly requests it sends a second (10 by default, at most 100: Instantly's limit is for your whole workspace).

What it writes

Lead variableValue
email_validation_statusvalid, invalid, catch_all, unknown or disposable (statuses)
email_validation_actionsend, send_with_caution, remove or retry_later
email_validation_checked_atwhen the results were written, in UTC
email_validation_address_hasha 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. Every other variable of the lead keeps its value: the script reads each lead again right before it writes and sends its variables back as they are, with these four on top. A lead whose address changed since the check is not written; the next run checks its new address.

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 or list's name, never an address or a key.

More on Instantly

Updated · Maintained by: Email Validation LLC

Need help? Contact support, or ask the help chat. Something wrong or missing on this page? Tell us