Integrations · Email platforms
Validate your Zoho Campaigns contacts
Check the active contacts of a Zoho Campaigns mailing list and set aside the addresses that cannot receive mail. A script you run on your own computer reads the list, checks each address once (up to 50 one by one, more as one bulk list) and adds each definite invalid to a private list of its own, "Flagged by email-validation.org", so you can leave it out of your campaigns. It flags; it never deletes a contact, never takes one off a list and never subscribes anyone again. Download it: email-validation-zoho-campaigns.zip holds zoho-campaigns.mjs (the script) and the MIT licence.
We found no documented way for Zoho Campaigns to run a check before its sign-up forms save a contact, and its list webhooks are not signed, so there is no relay: run the script on a schedule, and each run checks only the addresses it has not checked yet.
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 contacts.
- A Zoho Campaigns account. Its Free plan includes the Developer API the script uses; nothing is installed in Zoho Campaigns.
- A Zoho Self Client, its client id and client secret, and a refresh token (below), all from the data centre your Zoho account is on.
Your Zoho refresh token
- Open the Zoho API Console of your data centre:
api-console.zoho.com, or the same name on your data centre's domain (for exampleapi-console.zoho.eu). Choose Get started, then Self Client → Create now, and confirm. Copy the Client ID and Client Secret from its Client Secret tab. - In its Generate Code tab, enter the scopes
ZohoCampaigns.contact.READ,ZohoCampaigns.contact.CREATE-UPDATE, pick how long the code lasts (3 minutes by default) and a description, and choose Create (if asked, pick Zoho Campaigns and create again). - Within that time, exchange the code for a refresh token at your data centre's Zoho Accounts (the host for each data centre is in the table below):
export ZOHO_CLIENT_ID=… ZOHO_CLIENT_SECRET=…
curl -s -X POST https://accounts.zoho.com/oauth/v2/token \
-d grant_type=authorization_code -d "client_id=$ZOHO_CLIENT_ID" \
-d "client_secret=$ZOHO_CLIENT_SECRET" -d code=THE_CODEIn Windows PowerShell (5.1 or 7):
$env:ZOHO_CLIENT_ID = "…"; $env:ZOHO_CLIENT_SECRET = "…"
Invoke-RestMethod -Method Post -Uri 'https://accounts.zoho.com/oauth/v2/token' -Body @{
grant_type = 'authorization_code'; client_id = $env:ZOHO_CLIENT_ID
client_secret = $env:ZOHO_CLIENT_SECRET; code = 'THE_CODE' }Copy refresh_token from the answer: Zoho says it does not expire. The client secret and the refresh token give access to your Zoho Campaigns contacts: keep them in your scheduler's secrets or a password manager, never in a file you share.
ZOHO_CAMPAIGNS_DC | Zoho Campaigns | Zoho Accounts |
|---|---|---|
us (the default) | campaigns.zoho.com | accounts.zoho.com |
eu | campaigns.zoho.eu | accounts.zoho.eu |
in | campaigns.zoho.in | accounts.zoho.in |
au | campaigns.zoho.com.au | accounts.zoho.com.au |
jp | campaigns.zoho.jp | accounts.zoho.jp |
cn | campaigns.zoho.com.cn | accounts.zoho.com.cn |
ca | campaigns.zohocloud.ca | accounts.zohocloud.ca |
The script calls only those two hosts of the data centre you name. Then find the key of the list to check: in Zoho Campaigns, the list's Setup page shows its list key.
Try it free first
The script has not yet run against a real Zoho Campaigns account: it is built from Zoho Campaigns' API docs and tested against a Zoho Campaigns in memory. So try it on a test list first, never on your real one. In Zoho Campaigns, make a new mailing list and add, by hand, a few contacts whose addresses are on our sandbox domain, for example no_mailbox@sandbox.email-validation.org and accepted@sandbox.email-validation.org. Sandbox checks are free, and that domain receives no mail: never send a campaign to that list, and do not let Zoho send those contacts a confirmation mail. Then, from the unzipped folder:
cd email-validation-zoho-campaigns # the unzipped folder
export ZOHO_CLIENT_ID=… ZOHO_CLIENT_SECRET=… ZOHO_REFRESH_TOKEN=…
export ZOHO_CAMPAIGNS_DC=us ZOHO_CAMPAIGNS_LIST_KEY=… EV_API_KEY=…
node zoho-campaigns.mjs --dry-run # reads and counts only: checks, creates and writes nothing
node zoho-campaigns.mjs # checks and flags each definite invalidIn Windows PowerShell (5.1 or 7):
cd email-validation-zoho-campaigns # the unzipped folder
$env:ZOHO_CLIENT_ID = "…"; $env:ZOHO_CLIENT_SECRET = "…"; $env:ZOHO_REFRESH_TOKEN = "…"
$env:ZOHO_CAMPAIGNS_DC = "us"; $env:ZOHO_CAMPAIGNS_LIST_KEY = "…"; $env:EV_API_KEY = "…"
node zoho-campaigns.mjs --dry-run # reads and counts only: checks, creates and writes nothing
node zoho-campaigns.mjs # checks and flags each definite invalidCompare "Contacts read" with the list's active count in Zoho Campaigns: if they differ, stop and tell us. After the run, the list "Flagged by email-validation.org" holds the no_mailbox contact alone. Run it once more: it reports to check: 0. Then delete the test list and the list "Flagged by email-validation.org" (the first run on your real list makes it again).
Run it
node zoho-campaigns.mjs --dry-run # how many contacts would be checked; free
node zoho-campaigns.mjs # checks and flags- Only active contacts of the list are read (unsubscribed and bounced ones are not). An address that already has a result is skipped (an
unknownresult is checked again), so a daily run checks only new addresses.--revalidatechecks them all again. - Up to 50 addresses are checked one by one; more go out as one bulk list.
- A definite
invalidjoins the list "Flagged by email-validation.org". The first one creates it as a private list (no sign-up form). The script uses an existing list of that name only when Zoho says it is private: a list with a public sign-up form sends a confirmation mail to each address added, and a mail to an invalid address bounces.ZOHO_CAMPAIGNS_FLAG_LISTnames another list, ornonefor no list. - Every other status changes nothing in Zoho Campaigns. An address the script added once is never added again, so a contact you take off our list stays off. A contact whose later check is not
invalidstays on our list until you take it off. ZOHO_CAMPAIGNS_UNSUBSCRIBE_INVALID=truealso unsubscribes a definiteinvalidfrom the list it was read from (never any other status). Zoho's docs do not say whether that sends the contact a mail, so leave it off until you have tried it on a test list with your own address; an answer that says a mail went out stops the run.- Choose both settings before the first run: they apply to the results a run writes, not to contacts already checked.
--region eu: checked in the EU, with the same key.
In Zoho Campaigns, leave the list "Flagged by email-validation.org" out of your campaigns, or exclude its contacts. Spam traps and complainers are valid with a warning reason (see what each status means), so they are not flagged.
The script does not ask before it spends: each check uses one credit (unknown results, malformed and sandbox addresses are free). A value that is not an address (a link, a mailto:) is never sent. It prints address hashes, job ids and counts, never an address, a token or a key.
Run it again
If a run stops (no credits, a Zoho outage or rate limit, a closed laptop, the bulk list still running), 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). A result it paid for and could not write is written by the next run without a new check.
It keeps two files in the folder you run it from, named by the data centre and a short hash of the list key (never a token): the state file .ev-zoho-campaigns-<dc>-<hash>.json and the results file .ev-zoho-campaigns-<dc>-<hash>.results.jsonl, one line per address checked, holding its hash, our status and reason and the check time, never the address. Keep the results file: without it every address is checked again (one credit each). For a scheduled run (cron starts in another folder), give ZOHO_CAMPAIGNS_RESULTS_FILE an absolute path and --state FILE too, so every run finds the same files. Never run two lists that share a results file at the same time.
Zoho Campaigns allows each API about 500 calls in 5 minutes and locks it for 30 minutes past that, so the script makes one call a second, and waits when Zoho asks it to. A run costs one call per 100 contacts read and one or two per contact flagged. Run it when your other Zoho Campaigns tools are quiet, and do not start many runs at once with one refresh token. ZOHO_CAMPAIGNS_TIMEOUT_MS sets how long one Zoho call may take (1 to 60000 ms; default 30000).
Exit codes: 0 done; 1 a write failed or the run stopped (run it again: nothing is paid twice); 2 wrong options or a missing setting; 75 the bulk list was still being checked when the script stopped waiting (run it again later to collect it).
When something stops it
Nothing in Zoho Campaigns waits for the script: a run that stops leaves every contact it has not reached as it was. It stops, rather than paying for checks it cannot use, when our API refuses the key, has no credits or hits the key's daily cap; when Zoho refuses the refresh token, or the token's user lacks a privilege on the list; when the list key names no list; when a Zoho outage outlasts its retries; when two lists carry our list's name, or ours is not private; and when Zoho's answer to a write does not say it was done. Zoho's error messages can quote what was sent, so the script reports only their code.
End the access
Revoke the refresh token at your data centre's Zoho Accounts, as Zoho's guide to revoking tokens shows: that also revokes every access token made from it. Delete our key on the API keys page, and the script's folder with its state and results files. The list "Flagged by email-validation.org" stays in Zoho Campaigns until you delete it.