Integrations · Email platforms
Validate your Brevo contacts
Check the addresses of your Brevo contacts and save each result on the contact, in four contact attributes, so a segment can leave out the addresses you should not mail. Three ways, use any of them: clean a list from your dashboard (nothing to install), run a sync script on your own computer, or deploy a small relay to your own Cloudflare account that checks each contact as it joins a list. None of them deletes, blocklists or unsubscribes anyone. The script and the relay are in email-validation-brevo.zip: brevo.mjs (the sync script), relay.mjs (the relay), webhook.json and the MIT licence.
Create a Brevo API key
In Brevo, open Settings → SMTP & API → API Keys & MCP and choose Generate API key. Brevo asks for a verification code, a name and an expiry; leave its MCP server option off. Under Access, choose Full, or Restricted with Contacts: All and Account: Read (Brevo has no smaller Contacts permission that lets us save results). Brevo shows the key once: copy it. Only the account owner, or a user with the permission to manage API keys, can open that page.
Clean a list from your dashboard
Connect your Brevo account once, pick a list and choose Clean. We check every contact's address and save the result on the contact. You install nothing. An account set to validate in the EU (the EU data residency setting) does not see the Brevo card: use the script or the relay below with --region eu instead.
- Connect your key. In your dashboard, open Integrations, find Brevo, paste the key and connect. We store the key encrypted and never show it again.
- Try it free first. In Brevo, make a test list with one contact whose address is
no_mailbox@sandbox.email-validation.org(a test address: free, and it receives no mail, so send it nothing; if one of your automations starts when a contact joins a list, keep this list out of it). Clean that list: the contact getsEV_STATUSinvalidandEV_ACTIONremove. Brevo does not show new attributes on a contact's page by default, so filter the list onEV_STATUSto see it. Then delete the test contact. - Clean a list. Pick your list and choose Clean. Before it starts, you see how many credits it can use at most: one per contact, fewer when some are blocklisted or unsubscribed.
The dashboard shows your first 1,000 lists, oldest first. It checks the whole list each time you clean it. New contacts are not checked automatically: clean the list again, or use the script or the relay below.
If Brevo already has an attribute with one of these names but another type, saving the results fails, after the list was checked. The results stay in Bulk lists in your dashboard. Brevo cannot change an attribute's type: delete that attribute in Brevo (its values go with it, so export them first if you need them), then choose Try again, and the clean creates it as text. You are not charged again.
What it writes
| Contact attribute | Value |
|---|---|
EV_STATUS | valid, invalid, catch_all, unknown or disposable (statuses) |
EV_REASON | why, for example no_mailbox |
EV_ACTION | send, send_with_caution, remove or retry_later |
EV_CHECKED_AT | when the check finished (ISO 8601, UTC) |
remove means: do not mail this contact. We take nobody off your list unless you ask the script to. To find those contacts, create a segment (CRM → Contacts → Segments) with the condition EV_ACTION is equal to remove. Some addresses that exist are still not safe to mail (spam traps, people who file complaints): they are valid with the action remove, so filter on the action, not the status. If your account does not have these attributes yet, the first clean or run creates them as text attributes (Brevo allows up to 200 attributes per account).
Only those four attributes change. Contacts blocklisted for email or unsubscribed from the list are left out: Brevo would not mail them anyway. We delete nothing, and no contact is created, blocklisted or unsubscribed.
Run it yourself: the sync script
Use the script to clean on a schedule of your own, or to take the contacts not to mail off the list in the same run. It needs Node 22.18 or later (nothing to install: it 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), and the Brevo API key above.
Download email-validation-brevo.zip, unzip it and
cd email-validation-brevo.Try it free first, on a test list as in the dashboard's step 2, with a new test contact in it (the script skips a contact that already has a result). A list's id is its ID in CRM → Contacts → Lists, a number:
export EV_API_KEY=… BREVO_API_KEY=… node brevo.mjs --list <the test list's id>The test contact gets
EV_STATUSinvalidandEV_ACTIONremove. Then delete the test contact.Count what it would check in your real list (nothing is paid or written):
node brevo.mjs --list <your list's id> --dry-runRun it:
node brevo.mjs --list <your list's id>
The script checks only contacts that have no result yet (and those whose last result was unknown); --revalidate checks them all again. Add --suppress to also take the contacts whose action is remove off this list: they stay in your account, with their attributes and their other lists, and nothing is blocklisted or deleted. Add --region eu to check and keep the list in the EU, with the same key. node brevo.mjs --setup only creates the four attributes.
The script does not ask before it spends: each distinct address uses one credit; unknown results, duplicates, malformed and test addresses are free. It prints contact ids, job ids and counts, never an address or a key.
Run it again
Run the same command again after any stop (no credits, a closed laptop, a Brevo 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 contact is written, the file is removed and the next run checks only contacts without a result, so you can run it on a schedule, for example daily with cron, with both keys set.
Brevo allows 10 contact requests a second on every plan (more with its advanced limits); the script sends 8 a second by default (--rate N, at most 60) and waits when Brevo says the limit is reached. The check itself runs on our side and is not slowed by Brevo.
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).
Check new contacts as they join
The relay is a Cloudflare Worker in your own account. With a Brevo webhook pointed at it, each contact added to a list is checked within seconds, and its attributes written. It needs an API key of ours with Validate addresses (on by default), a Brevo API key (Full, or Restricted with Contacts: All), and Brevo's blocking of unknown IP addresses deactivated for API keys (below), because a Worker has no fixed address. Create the four attributes first (a run of the script, node brevo.mjs --setup, or one clean from the dashboard): without them the relay checks nothing.
No terminal? Deploy it from the Cloudflare dashboard instead. Or deploy it from the unzipped folder:
npx wrangler deploy relay.mjs --name ev-brevo-relay --compatibility-date 2026-10-01
npx wrangler secret put EV_API_KEY --name ev-brevo-relay # our API key
npx wrangler secret put BREVO_API_KEY --name ev-brevo-relay # your Brevo API key
openssl rand -hex 32 # a new secret for the relay's address
npx wrangler secret put RELAY_SECRET --name ev-brevo-relay # paste that secretAdd --var BREVO_LIST_ID:<list id> to the deploy command so that only contacts added to that list are checked, and --var EV_REGION:eu to have addresses validated in the EU and their results stored there.
Then add the webhook in Brevo: click your account name at the bottom left → Integrations → Webhooks → Add webhook → Outbound webhook, and give it a name.
- URL: the relay's address followed by
/and yourRELAY_SECRET, for examplehttps://ev-brevo-relay.<your subdomain>.workers.dev/<secret>. Leave the authentication at No authentication: the secret is in the address, so keep the address secret. - Sending: choose Send one at a time. The relay ignores batched deliveries.
- Events: pick the category Marketing emails (Brevo keeps the contact events there). Every event of the category starts switched on: switch all of them off except the one for a contact added to a list.
- Activate webhook.
Or send webhook.json, with the relay's address and your RELAY_SECRET filled in, as the body of POST https://api.brevo.com/v3/webhooks with your Brevo key in the api-key header: it sets only that one event, and Brevo then sends the secret as a bearer token with every delivery.
Deploy the relay from the Cloudflare dashboard
- In the Cloudflare dashboard, open Workers & Pages → Create and choose Create Worker (the "Hello World" starter). Name it
ev-brevo-relayand select Deploy. - Select Edit code, delete the starter code, paste the whole of
relay.mjsfrom the box below (Copy takes all of it) and select Deploy. - In the Worker's Settings → Variables and Secrets, select Add for each value below, then Deploy:
- type Secret:
EV_API_KEY(our API key),BREVO_API_KEY(your Brevo API key) andRELAY_SECRET(32 or more random letters and digits, for example from your password manager's generator); - type Text, if you want them:
BREVO_LIST_ID= the one list to check, andEV_REGION=eu.
- type Secret:
- The relay's address, such as
https://ev-brevo-relay.<your-subdomain>.workers.dev/, is on the Worker's page. Then add the webhook as described above, with yourRELAY_SECRETas the address's path.
Or open relay.mjs as plain text in a new tab, select all of it and copy it from there.
Try the relay once
Right after you add the webhook, add one new test contact with the address no_mailbox@sandbox.email-validation.org (free) to a list that starts no automation: within seconds it has EV_STATUS invalid. Then delete the test contact. From then on, each contact added to a list is a paid check. Adding many contacts to a list at once can send one event for each: for a big import, use the script instead, and set the relay's BREVO_LIST_ID so that only the list you mean is checked. A contact that already has a result is not checked again.
Good to know
- The key. A Full key can do everything in your Brevo account, and Contacts: All includes deleting contacts; we only read your lists and contacts and write our four attributes (and, with
--suppress, remove contacts from the list you name). To end our access, disconnect Brevo in your dashboard and delete the key in Brevo (Settings → SMTP & API → API Keys & MCP). - An idle key stops working. Brevo deactivates a key that has made no successful call for 90 days, whatever expiry you chose (a clean counts as a call). If a clean then says Brevo refused the key, reactivate it in Brevo or connect a new one.
- Authorized IPs. If Brevo blocks unknown IP addresses for your API keys (Settings → Security → Authorized IPs), it refuses calls from addresses you have not authorized: from our servers and from the relay, which have no fixed address to authorize. Brevo can turn this on by itself after a key has been used from the same addresses for 30 days, so if a clean that used to work says Brevo refused the key, look there first. For the dashboard and the relay it has to be Deactivated for API keys, which takes that protection off all your API keys. To keep it, use the script from a machine with a fixed address. Before you authorize any address, read Brevo's warning on that page: authorizing one starts the blocking of every other address, for your API and SMTP sending too.