Integrations · Data and spreadsheets

Validate the emails in a Notion database

Check the email addresses in a Notion database (a contact list, a lead list, a sign-up table) and keep each verdict next to its row, in five properties your views and filters can use. A script you run on your own computer checks the rows as one bulk list and writes the properties back. It only writes those five properties: it never creates, deletes, trashes or archives a row, and every other property stays as it is. Download it: email-validation-notion.zip holds notion.mjs (the 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 Notion internal connection and its API token. Make it once.
  • A database with a property of the type Email, shared with that connection.

Make your Notion connection

  1. Open Notion's developer portal as a workspace owner (on Business and Enterprise, an owner can let members do this too). On the Developer connections tab, select New connection, give it a name, choose API token as the authentication method and select Create connection.
  2. Give it the capabilities Read content and Update content. It needs nothing else: no comments, and No user information is enough.
  3. Copy its API token from the connection's Configuration tab. Keep it secret: it opens every page you share with the connection.
  4. Share the database with it: open the database, then ••• → Connections (under More in some views) → Add connections, and pick your connection. Until you do, Notion answers as if the database did not exist, and the script says so.

Try it free first

Make a test database with an Email property and one row whose email is no_mailbox@sandbox.email-validation.org, and share it with your connection. Test addresses cost nothing, and that domain receives no mail, so send it nothing. Then:

cd email-validation-notion                                  # the unzipped folder
export EV_API_KEY=…  NOTION_TOKEN=…
node notion.mjs --database "<the test database's link>"

It should exit 0, and the row gets EV Status invalid and EV Action remove. Use a test database, not your real one: on a real database every row without a verdict is checked, one credit each. Then delete the test database.

Run it

node notion.mjs --database "<the database's link>" --dry-run   # what it would check; spends nothing, writes nothing
node notion.mjs --database "<the database's link>"             # checks and writes the five properties

--database takes the database's link (Share → Copy link, or the address bar) or its id. The first run adds the five properties the database lacks (node notion.mjs --setup --database … adds only them, and needs no EV_API_KEY). The script does not ask before it spends: run it with --dry-run first to see how many rows it would check. Each distinct address uses one credit; unknown results, duplicates and malformed addresses are free.

OptionWhat it does
--data-source IDA database can hold several data sources: pick one (the script lists them when there are several)
--email-property NAMEThe Email property to read, when the database has more than one
--prefix TEXTPut before our five property names instead of EV
--region euCheck and keep the list in the EU, with the same key
--revalidateAlso check rows that already have a verdict for their address
--rate NNotion requests a minute (150 by default, at most 600)

What it writes

PropertyTypeValue
EV StatusSelectvalid, invalid, catch_all, unknown or disposable (statuses)
EV ReasonTextwhy, for example accepted, no_mailbox, spamtrap
EV ActionSelectsend, send_with_caution, remove or retry_later
EV Checked AtDatewhen the check that wrote this verdict ran, in UTC
EV Address HashTextwhich address the verdict is for (a hash of it, never the address)

Filter a view on EV Action is remove to find the addresses you should not mail: spam traps and complainers are valid with the action remove, so trust EV Action, not EV Status. A row whose address has not changed is not checked again, except an unknown verdict, which the next run checks again for free. Rows in the trash or archived are left alone.

If one of our five names already exists with another type, or as a select with options of your own, the script stops before anything is checked: rename your property, or use --prefix. If Notion does not let the connection change the database's properties, the script stops and names exactly what to add by hand; a select you make by hand needs all the options listed above.

How long it takes

Notion allows a connection 180 requests a minute on most plans and 600 on Business and Enterprise. The script sends 150 a minute by default, which leaves room for your other tools, and waits whenever Notion asks it to. Each written row takes about one request, so writing back 10,000 rows takes about 68 minutes at the default pace (about 17 minutes at --rate 600 on Business and Enterprise). The check itself runs on our side and is not slowed by Notion.

Run it again

Run the same command again after any stop (no credits, a closed laptop, 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 token. When every row is written, the file is removed and the next run checks only rows without a verdict for their address (new rows, changed addresses, unknown), so you can run it daily or weekly with cron.

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 row ids, job ids and counts, never an address or a token.

More on Notion

Updated · Maintained by: Email Validation LLC

Need help? Contact support, or ask the help chat. Something wrong or missing on this page? Tell us