Integrations · Email platforms
Validate the people in Customer.io
Check the addresses of the people in a Customer.io segment and write each person's result into four attributes, so your segments and campaign filters can leave out the addresses you should not mail. A sync script you run on your own computer checks the segment as one bulk list and writes the results back, only to the people it read from the segment. It never unsubscribes, suppresses or deletes anyone. Download it: email-validation-customerio.zip holds customerio.mjs (the sync 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 the permission Bulk lists (off by default: turn it on when you create the key).
- A Customer.io private key: in Customer.io, Account Settings → API Credentials → Create API key, a private key for the workspace you clean. It starts with
sk_us_orsk_eu_, Customer.io shows it once, and it reaches all of Customer.io's APIs, so keep it secret. A legacy App API key you made before (Customer.io no longer creates them) cannot write: use a private key. - If the workspace has an IP address allowlist (under API Credentials), the computer that runs the script must be on it. If the workspace sends its data to destinations outside Customer.io, give the key an integration source, or Customer.io refuses its writes.
Segments, not lists
Customer.io groups people by segments, so you clean one segment: data-driven, manual or snapshot. To clean everyone you mail, make a data-driven segment that holds them all (for example "Email exists"). A data-driven segment that Customer.io is still building cannot be read yet: the sync stops before anything is paid for and asks you to run it again once the segment is finished.
Run the sync
cd email-validation-customerio # the unzipped folder
export EV_API_KEY=… CUSTOMERIO_API_KEY=…
node customerio.mjs --segments # every segment: id, kind, size, name
node customerio.mjs --setup # checks the key and its region; writes nothing
node customerio.mjs --segment <id> --dry-run # what it would check; spends nothing, writes nothing
node customerio.mjs --segment <id> # checks and writes the four attributesOnly people who are not unsubscribed are checked. People that already have a result (other than unknown) are skipped; --revalidate checks them again. A key of Customer.io's EU region (sk_eu_) uses Customer.io's EU hosts by itself; --region eu (or EV_REGION=eu) checks and keeps the list in our EU, with the same key of ours.
The sync does not ask before it spends: run it with --dry-run first to see how many people it would check. Each distinct address uses one credit; unknown results, duplicates and malformed addresses are free.
What it writes
| Attribute | Value |
|---|---|
ev_status | valid, invalid, catch_all, unknown or disposable (statuses) |
ev_reason | why, for example accepted, no_mailbox, spamtrap |
ev_action | send, send_with_caution, remove or retry_later |
ev_checked_at | when the check ran, in UTC, as text |
Customer.io creates an attribute the first time it is written, so there is nothing to set up. Each write sends only these four attributes and names the person by Customer.io's own person id, read from the segment just before, with Customer.io's update-only flag _update. Customer.io documents that flag, and that it drops a write for a person id that no longer exists, for its v1 identify call; its v2 batch reference, which the sync uses, does not say either way, so look at the result of the free try below before the first real run. Trust ev_action, not ev_status: spam traps and complainers are valid with the action remove. A data-driven segment "ev_action is equal to remove" holds every person you should not mail: leave it out of your campaigns and broadcasts.
Writing an attribute is a change to the person. It can move people into or out of your data-driven segments, and it can start a campaign triggered by segment membership or by an attribute change. Look at your campaign triggers before the first run.
New people
Customer.io's reporting webhooks report messages and subscription changes, not a person added to the workspace, so there is no relay that checks each new person as they arrive. Run the same command on a schedule instead, for example daily with cron: each run checks only the people without a result. A scheduled run does not see your shell's exports: give it both keys, and EV_REGION=eu (or --region eu) if you check in the EU, on every run, cron included.
Try it free first
Add one person by hand with the address no_mailbox@sandbox.email-validation.org and put them in a manual segment (in a test workspace, use that workspace's own private key), and make sure no campaign is triggered for them. Test addresses cost nothing, and that domain receives no mail, so send it nothing. Run node customerio.mjs --segment <the segment's id>: it should exit 0, and the person gets ev_status invalid and ev_action remove, with no other attribute added or changed (if the person shows an attribute named _update, stop and tell us). Then delete the person.
Run it again
Run the same command again after any stop (no credits, a closed laptop, an outage, the bulk list still running): it resumes the same bulk list and never pays twice (within the 30 days a list is kept). 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, never an address or a key. When every person is written, the file is removed and the next run checks only people without a result (or with unknown).
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 person ids, job ids and counts, never an address or a key.
Stop it and end its access
To stop, remove the scheduled run (your crontab line). Deleting the unzipped folder does not end access: to end it, delete the private key in Customer.io under Account Settings → API Credentials (a key a cron job still holds stops working only then), and delete our API key on the API keys page.