Integrations · Sales outreach
Validate your HeyReach leads
Check the email addresses of the leads in a HeyReach lead list and write each result into four lead custom fields, so you can leave out the addresses you should not mail. A script you run on your own computer reads the list, checks the addresses as one bulk list and writes the results back. It never deletes a lead, removes one from a list or campaign, or changes an address. Download it: email-validation-heyreach.zip holds heyreach.mjs (the script) and the MIT licence.
What you need
- A computer with Node 22.18 or later. Nothing to install: the script has no dependencies.
- An API key of ours from the API keys page with Validate addresses, and the permission Bulk lists (off by default: turn it on when you create the key) for more than 50 leads.
- A HeyReach API key: in HeyReach, Integrations → HeyReach API → Get API key (New API key if you have none yet). HeyReach lists its API on its Growth plan and above. The key works for the whole workspace.
- The id of the lead list to check: the number in the list's address in HeyReach. One run checks one list; a company list is refused.
Try it free first
Each distinct address uses one credit (unknown results, duplicates and malformed addresses are free), so try it on a lead list that holds only test leads, never on your real ones. Give one test lead the email address no_mailbox@sandbox.email-validation.org (sandbox checks are free; that domain receives no mail, so send it nothing), then:
cd email-validation-heyreach # the unzipped folder
export HEYREACH_API_KEY=… HEYREACH_LIST_ID=12345 EV_API_KEY=…
node heyreach.mjs --dry-run # checks nothing, writes nothing: only counts
node heyreach.mjs # checks and writesThe lead's ev_status field says invalid and ev_reason says no_mailbox. Run it once more: it reports nothing to check, because every result was written. Then delete the test list.
Run it
node heyreach.mjs --dry-run # how many leads would be checked; free
node heyreach.mjs # checks and writesUp to 50 addresses are checked one by one; more go out as one bulk list. A lead is checked by the email address the lead list shows for it; a lead with no address (many LinkedIn leads have none) is skipped and costs nothing. A lead whose address already has a result is skipped (an unknown result is checked again), so a daily run checks only new and changed addresses. If a run stops, run the same command again from the same folder: it reads the list again, resumes the same bulk list and never pays twice (within the 30 days a list is kept). The state file (.ev-heyreach-list-<list id>.json) lives in that folder, named by the lead list. It prints ids and counts, never an address, a profile link or a key.
Settings, in the environment:
HEYREACH_TAG(optional): a tag a lead gets when its address isinvalid, for examplebad-email. HeyReach creates the tag the first time. No other result gets it, and the script never removes a tag: a lead that is latervalidkeeps it until you remove it.HEYREACH_TIMEOUT_MS(optional): how long one HeyReach request may take, in milliseconds (default 30000, at most 60000).
Options:
--region eu: checked in the EU, lists and results kept there, with the same key.--revalidate: check again addresses that already have a result.--rate N: lead reads and writes a second (default 3, at most 4). HeyReach allows 300 API requests a minute, every request counting toward that one limit (other tools that use HeyReach's API may share it); the script sends at most 4 requests a second whatever--rateis, so run it when your other HeyReach tools are quiet. When HeyReach refuses for its limit, the script tries again three times (after 2, 4 and 8 seconds, or the wait HeyReach names, up to a minute), then stops. Run the same command again later: it resumes without paying twice.--state FILE: a state file of your own choosing.
Exit codes: 0 done; 1 a write failed or the run stopped (run it again: nothing is paid twice); 2 wrong options; 75 the bulk list was still being checked when the script stopped waiting (run it again later to collect it).
What it writes
Four lead custom fields, created by HeyReach the first time they are written:
| Field | Holds |
|---|---|
ev_status | valid, invalid, catch_all, unknown or disposable |
ev_reason | the reason, for example no_mailbox or accepted |
ev_checked_at | when it was checked |
ev_address_hash | a hash of the address the result belongs to, so a changed address is checked again |
Spam traps and complainers are valid with a warning reason: see what each status means. Each result is written only while the lead, looked up again just before, still holds the address that was checked. The write sends only these four fields: HeyReach updates them and keeps every other custom field of the lead. The first write of a run is read back, and the run stops before any other write if HeyReach did not keep it. A result that could not be written is kept in a file next to the state file and written by the next run without a new check.
The leads whose ev_status is invalid or disposable (or that carry your tag) are the ones to leave out of the email steps of your campaigns.
End the access
Delete the HeyReach API key in HeyReach (Integrations → HeyReach API) and our key on the API keys page. The four fields stay on your leads until you delete them in HeyReach.