# Validate Keap Contacts: Setup Guide

URL: https://email-validation.org/docs/guides/keap/
Updated: 2026-12-05

> Documentation index: https://email-validation.org/llms.txt

Check the primary email address of the contacts in your Keap account (formerly Infusionsoft) and keep each verdict in
five contact custom fields, so saved searches and campaigns can leave out the contacts you should not mail. Two
pieces, use either or both:

- **For the contacts you already have**: a script checks every contact without a verdict as one bulk list and writes
  the fields back.
- **For every new or changed contact**: a small relay you deploy receives Keap's REST hooks `contact.add` and
  `contact.edit`, checks the address and writes the fields within seconds.

It writes only these fields (and, if you choose, a tag and an opt-out from marketing email). It never deletes a
contact, a tag or anything else, never creates or merges contacts, and never changes an address, a name or any other
field. A check that is slow or fails changes nothing.

Download it: [email-validation-keap.zip](https://email-validation.org/downloads/keap/email-validation-keap.zip) holds `keap.mjs` (the script),
`relay.mjs` (the relay) and the MIT licence.

## What you need

- An API key of ours from the [API keys page](https://email-validation.org/app/api-keys/) with **Validate addresses** (on by default), and for the
  script also **Bulk lists** (off by default: turn it on when you create the key).
- A Keap key: a **Personal Access Token** (any user can make one; it acts with that user's permissions) or a **Service
  Account Key** (admins only; admin access to all your data). In Keap: Settings > API Settings (in Keap Classic: the
  Profile menu > API Settings), then add a new key with a name you will recognize. Keap shows the full key only once:
  copy it then. It must be able to read and edit contacts and create custom fields and tags, and for the relay manage
  REST hooks. It can do everything its user can, deleting contacts included (this code never does): keep it secret.
- 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](https://email-validation.org/docs/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 saved searches and campaigns 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.

Create the five fields first (this checks nothing and needs no key of ours). They are Text contact fields with exactly
those names:

```bash
cd email-validation-keap              # the unzipped folder
export KEAP_API_KEY=…
node keap.mjs --setup
```

In Windows PowerShell (5.1 or 7):

```powershell
cd email-validation-keap              # the unzipped folder
$env:KEAP_API_KEY = "…"
node keap.mjs --setup
```

If the relay should tag contacts, create those tags at the same time: `node keap.mjs --setup --tag invalid,disposable`
(in PowerShell, `--tag 'invalid,disposable'`). The relay creates nothing itself.

## Check new contacts: the relay

Deploy the relay to your Cloudflare account from the unzipped folder:

```bash
npx wrangler deploy relay.mjs --name ev-keap-relay --compatibility-date 2026-10-01
npx wrangler secret put EV_API_KEY --name ev-keap-relay          # our API key
npx wrangler secret put KEAP_API_KEY --name ev-keap-relay        # your Keap key
openssl rand -hex 32                                             # a new secret for the hook's address
npx wrangler secret put KEAP_RELAY_SECRET --name ev-keap-relay   # paste that secret
```

On Windows, where `openssl` is usually missing, make the secret with Node instead (`npx` needs Node anyway):
`node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"`, or use your password manager's generator
(16 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 subscribe the relay to Keap's hooks, with the address `wrangler deploy` printed and your secret:

```bash
node keap.mjs --hook "https://ev-keap-relay.<your subdomain>.workers.dev/?key=<KEAP_RELAY_SECRET>"
```

This creates the REST hooks `contact.add` and `contact.edit` in your Keap account. Keap verifies each one by calling
the relay, which answers only with the right secret; the command prints each hook's status (it should say
`Verified`), never the address.

Keap signs no hook delivery, so the secret travels in the hook's address: keep that address as secret as the key, and
keep the Worker's request logs off (Workers Logs, Logpush, Tail Workers), since they could record it. The relay acts
only on the exact secret, takes nothing from a delivery but contact ids, and reads each contact itself with your Keap
key. Its own write fires `contact.edit` again: it then sees the verdict for that address and checks nothing.

## Try it free first

Right after subscribing, create a contact whose address is `no_mailbox@sandbox.email-validation.org` (pause any of your
own campaigns that would mail a new contact first). Within a few seconds it gets `ev_status` `invalid` and `ev_action`
`remove`. Sandbox checks are free, and that domain receives no mail, so send it nothing. Then delete the test contact.

From then on, every new contact, and 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. For a large import, run the script rather than relying on the relay:
the relay leaves what it cannot finish within Keap's 30-second answer time for the script.

If you use only the script, do not try it on your real contacts: every contact without a verdict is checked, and that
is paid.

## The contacts you already have: the script

```bash
export EV_API_KEY=…  KEAP_API_KEY=…
node keap.mjs --dry-run                     # counts what it would check; creates, uploads and writes nothing
node keap.mjs                               # checks and writes the five fields
node keap.mjs --tag invalid,disposable      # also adds the tags ev-invalid and ev-disposable
```

In Windows PowerShell (5.1 or 7):

```powershell
$env:EV_API_KEY = "…"; $env:KEAP_API_KEY = "…"
node keap.mjs --dry-run                     # counts what it would check; creates, uploads and writes nothing
node keap.mjs                               # checks and writes the five fields
node keap.mjs --tag 'invalid,disposable'    # also adds the tags ev-invalid and ev-disposable
```

It 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.

`--opt-out STATUSES` opts those addresses out of marketing email in Keap, only for `invalid`, `catch_all` or
`disposable`. Keap keeps one marketing status per address: an opt-out stops Keap's marketing email to that address for
every contact that has it, and this integration never opts an address back in, so plan as if only the person can make
it marketable again by opting in themselves. Only an address that is marketable when it is read is opted out.

Both are off by default; the relay takes the same choices as `--var EV_TAG_STATUSES:…` and
`--var EV_OPT_OUT_STATUSES:…` on its deploy command.

Before each write the script reads the contact again and writes it only when its address is still the one checked.
Keap replaces a contact's whole custom field list on a write, so the script sends every other custom field back as it
just read it. It reads its first write back and stops if anything but our fields changed.

Keap allows a Personal Access Token or Service Account Key 10 requests a second, 240 a minute and 30,000 a day (the day
starts at 00:00 UTC). The script uses 120 a minute by default (`--rate N`, at most 240). Writing back takes two
requests per contact, so it writes fewer than 15,000 contacts a day (fewer than 10,000 with the relay on the same Keap
key); a larger account takes several days, each run 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, Keap's daily 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 Keap 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.

## More on Keap

- [Keap email validation integration](https://email-validation.org/integrations/keap/)
