Integrations · CRM
Validate your Freshsales contacts
Check the primary email address of the contacts in your Freshsales account (Freshworks CRM, Freshsales Suite included) and keep each verdict in five contact custom fields, so views and workflows can leave out the contacts you should not mail. Two pieces, use either or both:
- For the contacts you already have: a script reads a contact view, checks every contact without a verdict as one bulk list and writes the fields back.
- For every new or changed contact: a workflow's Trigger webhook action calls a small relay you deploy, which checks the address and writes the fields within seconds.
It writes only these fields (and, if you choose, a tag). It never changes a contact's subscription status or any other marketing setting: what you stop mailing stays your choice. It never deletes, forgets, merges or creates a contact, never changes an address, a name or an owner, and never removes a tag. A check that is slow or fails changes nothing. This guide is for Freshsales, the CRM; Freshdesk, the help desk, has its own guide.
Download it: email-validation-freshworks.zip holds freshworks.mjs (the script), relay.mjs (the relay), webhook.json (the Trigger webhook's settings) and the MIT licence.
What you need
- A Freshsales account on the Growth plan or above: Freshsales has no custom fields on the Free plan, and workflows on a record action start at Growth.
- An API key of ours from the API keys page with Validate addresses (on by default), and for the script also Bulk lists (off by default: turn it on when you create the key).
- Your Freshsales API key and host. In Freshsales, click the Profile icon > Settings > the API SETTINGS tab, enable the captcha, then copy the key from "Your API key". Your host is your account's address,
<alias>.myfreshworks.com(or<alias>.freshworks.com). Each user has a key of their own: use one of a user who may read and edit contacts. The key can delete contacts (this code never does): keep it secret. "Reset Key" on that tab replaces it and disconnects every tool that used the old one. - For the script, a computer with Node 22.18 or later (nothing to install). For the relay, a Cloudflare account.
The fields
| Contact custom field | Value |
|---|---|
ev_status | valid, invalid, catch_all, unknown or disposable (statuses) |
ev_reason | why, such as accepted, no_mailbox or spamtrap |
ev_action | send, send_with_caution, remove or retry_later |
ev_checked_at | when the check ran, in UTC |
ev_address_hash | which address the verdict is for (a hash of it, never the address) |
Build your views and workflows on ev_action remove: that includes spam traps and complainers, which are valid with the action remove. A contact whose address changes is checked again at its new address.
Freshsales documents no API call that creates a contact field, so create the five once yourself: Admin Settings > Leads, Contacts & Accounts > the Contact module, add a field of the type Text field five times, labelled exactly ev_status, ev_reason, ev_action, ev_checked_at and ev_address_hash. Then check them (this needs no key of ours):
cd email-validation-freshworks # the unzipped folder
export FRESHSALES_API_KEY=… FRESHSALES_DOMAIN=<alias>.myfreshworks.com
node freshworks.mjs --setupIn Windows PowerShell (5.1 or 7):
cd email-validation-freshworks # the unzipped folder
$env:FRESHSALES_API_KEY = "…"; $env:FRESHSALES_DOMAIN = "<alias>.myfreshworks.com"
node freshworks.mjs --setupIt says which fields are still missing, or "The ev_ contact fields are there."
Try it free first
A run checks every contact of its view that has no verdict, one credit each, so try it on a test contact first, never on your real contacts. Create a contact whose address is no_mailbox@sandbox.email-validation.org and a contact view that lists only that contact (Contacts > Add new view, a filter that matches only that contact, Save view as). Sandbox checks are free, and that domain receives no mail, so send it nothing.
export EV_API_KEY=…
node freshworks.mjs --dry-run --view 0 # lists up to 20 of your views with their ids; checks nothing
node freshworks.mjs --view <the test view's id>In Windows PowerShell (5.1 or 7):
$env:EV_API_KEY = "…"
node freshworks.mjs --dry-run --view 0 # lists up to 20 of your views with their ids; checks nothing
node freshworks.mjs --view <the test view's id>The test contact gets ev_status invalid and ev_action remove. Then delete the test contact and its view.
The contacts you already have: the script
export EV_API_KEY=… FRESHSALES_API_KEY=… FRESHSALES_DOMAIN=<alias>.myfreshworks.com
node freshworks.mjs --dry-run # counts what it would check; uploads, checks and writes nothing
node freshworks.mjs # checks and writes the five fields
node freshworks.mjs --tag invalid,disposable # also adds the tags ev-invalid and ev-disposableIn Windows PowerShell (5.1 or 7):
$env:EV_API_KEY = "…"; $env:FRESHSALES_API_KEY = "…"; $env:FRESHSALES_DOMAIN = "<alias>.myfreshworks.com"
node freshworks.mjs --dry-run # counts what it would check; uploads, checks and writes nothing
node freshworks.mjs # checks and writes the five fields
node freshworks.mjs --tag 'invalid,disposable' # also adds the tags ev-invalid and ev-disposableIt reads the view named "All Contacts", or the one you name with --view ID, and checks each contact with a primary address and no verdict for that address yet (or the verdict unknown). Each checked address uses one credit; unknown results, duplicates and malformed addresses are free. --revalidate also checks contacts that already have a verdict. --region eu validates and keeps the list in the EU.
--tag STATUSES adds our tag for those statuses (ev-invalid, ev-disposable, …); tags are only added, never removed, so a contact checked again with another result keeps its old tag. Build on the ev_status field, or tag only final statuses such as invalid,disposable. Off by default; the relay takes the same choice as --var EV_TAG_STATUSES:….
Before each write the script reads the contact again and writes it only when its address is still the one checked; every other custom field goes back exactly as it was read. It reads its first write back and stops if anything but our fields changed.
Freshsales allows 1,000 API requests an hour on the Growth plan (2,000 on Pro, 5,000 on Enterprise), shared with your other tools. The script uses at most 500 an hour by default (--rate N, at most 5,000), and writing a verdict back takes two requests per contact: about 250 contacts an hour, so a large account is written over several runs, each continuing where the last one stopped.
Run it again
If a run stops for any reason (your email-validation.org credits ran out, a closed laptop, Freshsales' hourly limit, the bulk list still running), run the same command again from the same folder: it picks up the same bulk list and never pays twice (within the 30 days a list is kept), even with a new Freshsales API key. Contacts already written are skipped. After that, each run checks only contacts with no verdict for their address (new contacts, changed addresses, unknown), so you can run it daily or weekly to catch anything the relay did not write.
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 and ids, never an address or a key.
Check new contacts: the relay
Deploy the relay to your Cloudflare account from the unzipped folder:
npx wrangler deploy relay.mjs --name ev-freshsales-relay --compatibility-date 2026-10-01
npx wrangler secret put EV_API_KEY --name ev-freshsales-relay # our API key
npx wrangler secret put FRESHSALES_API_KEY --name ev-freshsales-relay # your Freshsales API key
npx wrangler secret put FRESHSALES_DOMAIN --name ev-freshsales-relay # <alias>.myfreshworks.com
openssl rand -hex 24 # a new secret for the workflow
npx wrangler secret put FRESHSALES_RELAY_SECRET --name ev-freshsales-relay # paste that secretOn Windows, where openssl is usually missing, make the secret with Node instead (npx needs Node anyway): node -e "console.log(require('crypto').randomBytes(24).toString('hex'))", or use your password manager's generator (24 to 128 letters, digits, _ or -).
Add --var EV_REGION:eu to the deploy command to have addresses validated in the EU and their results stored there.
Then, in Freshsales: Admin settings > Teams & Territories > Workflows. Create a workflow on Contacts based on a record action, When the record is created (or When the record is created or updated, to check a changed address too), with the action Trigger webhook set like this (webhook.json holds the same settings):
| Setting | Value |
|---|---|
| Request type | POST |
| Callback URL | your relay's address, which wrangler deploy prints |
| Authentication | none (the relay reads the custom header below) |
| Custom headers | X-EV-Relay-Secret: <FRESHSALES_RELAY_SECRET> |
| Encoding | JSON |
| Content | Advanced: {"contact_id": "{{contact.id}}"} |
The relay acts only on the exact secret, takes only the contact's id and reads the contact itself. The test button sends the sample id 12345: the relay answers 200 at once (a success), then finds no contact 12345 and does nothing. Its own write can start "created or updated" again: it then sees the verdict for that address and checks nothing.
Freshsales waits 6 seconds for an answer, so on Cloudflare the relay answers at once and does the check right after. A delivery that fails is sent again by Freshsales for an hour, then for two days.
Create a contact whose address is no_mailbox@sandbox.email-validation.org: within a few seconds it gets ev_status invalid and ev_action remove, free. Then delete the test contact. From then on every new contact, and (with "created or updated") every contact whose address changes, is checked: one credit each (an unknown result is free). A check that gets no answer may have been charged, so the relay does not send it again within the hour; the next script run checks that contact. A checked contact uses three of your account's Freshsales API requests (up to five on a relay instance's first deliveries, which also read the field list and read their first write back), and with "created or updated" the echo of its own write one more read.