Integrations · CRM
Validate your Insightly contacts
Check the email addresses of your Insightly contacts (or leads) and write each result into four custom fields, so a filtered list can leave out the addresses you should not mail. A script you run on your own computer reads every record, checks the addresses (up to 50 one by one, more as one bulk list) and writes the results back. It never deletes, merges or changes a record's address. Download it: email-validation-insightly.zip holds insightly.mjs (the script) and the MIT license.
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 records.
- Your Insightly API key and API URL: in Insightly, User Settings, in the API section; the API URL (like
https://api.na1.insightly.com) is shown right under the key. The key acts as your user, so that user needs to see and edit every contact. - The four custom fields below, made once in Insightly (its API cannot create fields): see Set up the fields.
Set up the fields
In Insightly, go to System Settings → Objects and Fields → Contacts → Object Fields → New Field, choose the type Text and make four fields. Give each exactly one of these names as its Field Label and keep the Field Name Insightly fills in from it:
| 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 |
The script finds them by that name in any case, with or without the __c ending Insightly may add. To check leads, make the same four fields under Leads. A run that finds one missing, one that is not an editable Text field, or two of the same name stops before anything is checked and says which. Spam traps and complainers are valid with a warning reason: see what each status means.
Try it free first
Every definite result uses one credit (unknown results, malformed and test addresses are free), so try it on an Insightly account that holds only test contacts (Insightly offers a 14-day trial), never on your real ones. Make the four fields, give one test contact the address no_mailbox@sandbox.email-validation.org (sandbox checks are free; that domain receives no mail, so send it nothing), then:
cd email-validation-insightly # the unzipped folder
export INSIGHTLY_API_KEY=… INSIGHTLY_API_URL=https://api.na1.insightly.com EV_API_KEY=…
node insightly.mjs --dry-run # checks nothing, writes nothing: only counts
node insightly.mjs # checks and writesIn Windows PowerShell (5.1 or 7):
cd email-validation-insightly # the unzipped folder
$env:INSIGHTLY_API_KEY = "…"; $env:INSIGHTLY_API_URL = "https://api.na1.insightly.com"; $env:EV_API_KEY = "…"
node insightly.mjs --dry-run # checks nothing, writes nothing: only counts
node insightly.mjs # checks and writesUse the API URL Insightly shows you, not the example. The contact'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 contact.
Run it
node insightly.mjs --dry-run # how many contacts would be checked; free
node insightly.mjs # checks and writesUp to 50 addresses are checked one by one; more go out as one bulk list. A contact is checked by its email address (a lead by its email), and one 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 resumes the same bulk list and never pays twice (within the 30 days a list is kept). The state file (.ev-insightly-<subdomain>.json, named by your Insightly account) lives in that folder. It prints ids and counts, never an address or a key.
Insightly allows 10 requests a second for each account and a daily number set by your plan, shared with everything else that uses your account's API. The script sends 2 requests a second by default. A run sends one request for every 500 records it reads and two for every record it writes; on a large account, a run stopped by the daily limit resumes where it stopped on the next day.
Options:
INSIGHTLY_OBJECT=leads: check leads instead of contacts (the four fields must exist on leads).--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: Insightly requests a second, 1 to 5.--state FILE: a state file of your own choosing.INSIGHTLY_TIMEOUT_MS: how long one Insightly request may take, in milliseconds (1 to 60000; default 30000).
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
Each result is written by record id, and only while the record, read again just before, still holds the address that was checked. The write holds only the record's id and the four fields, and it is sent with the version Insightly gave on that read: if someone changed the record in between, Insightly refuses the write and nothing is overwritten. The contact's names, addresses, tags and other fields stay as they are. 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.
A contact filter on ev_status is invalid or disposable finds the contacts to leave out of your mailings.
End the access
Delete our key on the API keys page and remove the Insightly key from the environment you set it in: the script keeps no copy of either. The four fields stay on your contacts until you delete them in Insightly.