Integrations · Email platforms

Validate your beehiiv subscribers

Check the addresses of a beehiiv publication's subscribers (beehiiv calls them subscriptions) and save each one's result in four custom fields, so a segment can show the addresses you should not mail. Two pieces, use either or both: a sync script you run on your own computer checks a publication's active subscriptions as one bulk list, and a small relay you deploy to your own Cloudflare account checks each new subscription as it is created. Neither one deletes or unsubscribes anyone. The script and the relay are in email-validation-beehiiv.zip: beehiiv.mjs (the sync script), relay.mjs (the relay), webhook.json and the MIT licence.

Create a beehiiv API key

In beehiiv, open Settings → Workspace Settings → API and select Create New API Key, give it a name and copy it: beehiiv shows it only once. Only a workspace Owner or Admin sees the API keys, and beehiiv first asks you to verify your account through Stripe Identity Verification. A key reaches every publication of the workspace; on paid plans you can limit it to some publications, so make sure it reaches the one you clean. It can read and change your subscriptions, so keep it secret.

beehiiv's plans: API keys work on every plan, the free one included; webhooks (the relay) need the Lite plan or above (or beehiiv's free trial); and sending a post to a segment needs a paid plan. On the free plan a segment on ev_action shows you the subscriptions to remove, and you unsubscribe them yourself in beehiiv.

What it writes

FieldValue
ev_statusvalid, invalid, catch_all, unknown or disposable (statuses)
ev_reasonwhy, for example accepted, no_mailbox, spamtrap
ev_actionsend, send_with_caution, remove or retry_later
ev_checked_atwhen the check ran, in UTC

beehiiv custom fields belong to one publication: if yours does not have these yet, the first run creates them there as text fields. Make a segment where ev_action is remove to find every subscription you should not mail, spam traps and complainers included: they are valid with the action remove, so trust ev_action, not ev_status. Each write holds only these four fields: no subscription is created, unsubscribed or deleted, its tier, status and address stay as they are, and no mail is sent. If you have a beehiiv automation that starts when a custom field changes, writing these fields can start it.

Run it yourself: the sync script

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 beehiiv API key above. --publications lists the publications the key reaches, with their ids (pub_…) and active counts. Segments cannot be picked (beehiiv's API cannot read a large segment whole): clean the publication the segment belongs to.

cd email-validation-beehiiv                                # the unzipped folder
export EV_API_KEY=…  BEEHIIV_API_KEY=…
node beehiiv.mjs --publications                            # lists the publications: id, active count, name
node beehiiv.mjs --publication <publication id> --dry-run  # counts what it would check; spends and writes nothing
node beehiiv.mjs --publication <publication id>            # checks and writes the four fields

Try it free first, on a publication you use only for testing. Give it one subscription with the address no_mailbox@sandbox.email-validation.org (a test address: free, and it receives no mail, so send it nothing). Add it with beehiiv's create call, not through a sign-up form: with these two settings it is active at once and beehiiv sends it no confirmation or welcome email.

curl -X POST "https://api.beehiiv.com/v2/publications/<test publication id>/subscriptions" \
  -H "Authorization: Bearer $BEEHIIV_API_KEY" -H "Content-Type: application/json" \
  -d '{"email": "no_mailbox@sandbox.email-validation.org", "send_welcome_email": false, "double_opt_override": "off"}'

Run the script on that publication: the subscription gets ev_status invalid and ev_action remove. If the run finds nothing to check, beehiiv has not made the subscription active (the script checks only active ones): look at its status in beehiiv. Then delete the test subscription in beehiiv, and run it on your real publication, --dry-run first.

  • Only active subscriptions are checked (the ones beehiiv mails), and only those without a result (or with unknown); --revalidate checks them all again.
  • --region eu checks and keeps the list in the EU, with the same key. node beehiiv.mjs --setup --publication <publication id> only creates the four fields.

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 subscription 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 beehiiv outage or rate limit, 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 subscription is written, the file is removed and the next run checks only subscriptions without a result, so you can run it on a schedule, for example daily with cron, with both keys set.

beehiiv's request limit depends on your plan: 30 a minute on Free, 180 on Lite, 500 on Pro and 800 on Enterprise, per API key. The script starts at 25 a minute, then uses 80 % of the limit beehiiv reports (at most --rate N), leaving the rest for your other apps on the same key, and waits when beehiiv says none is left. Each written subscription takes two or three requests: on Lite, writing back 10,000 subscriptions takes about 2 hours 20 minutes to 3 hours 30 minutes. The check itself runs on our side and is not slowed by beehiiv.

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 subscriptions as they join

The relay is a Cloudflare Worker in your own account, and beehiiv's webhooks need the Lite plan or above (or its free trial). One relay serves one publication. It needs an API key of ours with Validate addresses (on by default) and your beehiiv API key. Create the four fields first (a run of the script or node beehiiv.mjs --setup --publication <publication id>): 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-beehiiv-relay --compatibility-date 2026-10-01 \
  --var BEEHIIV_PUBLICATION_ID:<publication id>
npx wrangler secret put EV_API_KEY --name ev-beehiiv-relay        # our API key
npx wrangler secret put BEEHIIV_API_KEY --name ev-beehiiv-relay   # your beehiiv API key

Add --var EV_REGION:eu to the deploy command to have addresses validated in the EU and their results stored there.

Then add the webhook in beehiiv: pick the relay's publication at the top of Settings, open Webhooks and create an endpoint with the relay's address and the one event type subscription.created (webhook.json holds the same, as the body of beehiiv's POST /v2/publications/<publication id>/webhooks). beehiiv shows the webhook's signing secret (whsec_…) on the endpoint's details page there. Put it into the relay:

npx wrangler secret put BEEHIIV_WEBHOOK_SECRET --name ev-beehiiv-relay   # the webhook's signing secret, whsec_…

Keep the webhook on that one event. To check a subscription when it is confirmed rather than when it is created, add --var BEEHIIV_EVENT:subscription.confirmed to the deploy command and use the event subscription.confirmed instead.

Deploy the relay from the Cloudflare dashboard

  1. In the Cloudflare dashboard, open Workers & Pages → Create and choose Create Worker (the "Hello World" starter). Name it ev-beehiiv-relay and select Deploy.
  2. Select Edit code, delete the starter code, paste the whole of relay.mjs from the box below (Copy takes all of it) and select Deploy.
  3. In the Worker's Settings → Variables and Secrets, select Add for each value below, then Deploy:
    • type Text: BEEHIIV_PUBLICATION_ID = the publication's id (pub_…) and, if you want them, BEEHIIV_EVENT = subscription.confirmed and EV_REGION = eu;
    • type Secret: EV_API_KEY (our API key), BEEHIIV_API_KEY (your beehiiv API key) and, once you have created the webhook as above, BEEHIIV_WEBHOOK_SECRET (its signing secret).
  4. The relay's address, such as https://ev-beehiiv-relay.<your-subdomain>.workers.dev/, is on the Worker's page: use it as the webhook's URL.

Or open relay.mjs as plain text in a new tab, select all of it and copy it from there.

Who can call the relay

beehiiv signs every delivery (through Svix) with the webhook's secret, and the relay acts only on deliveries signed with it in the last 5 minutes. A subscription that already has a result is not checked again, so a delivery beehiiv sends again costs nothing. beehiiv's docs do not say whether an import sends an event for each imported subscription: after an import, run the sync.

Try it once on the relay's publication: add a test subscription with the address no_mailbox@sandbox.email-validation.org using the curl command above with that publication's id, so beehiiv sends it no confirmation or welcome email, and keep it out of your posts and automations (the test address receives no mail). Within a few seconds it should have ev_status invalid and ev_action remove. Then delete it. From then on every new subscription is a paid check, one credit each.

Good to know

  • Ending the access. Delete the webhook in beehiiv (Settings → Webhooks) and the relay's Worker, and delete the API key in beehiiv (Settings → Workspace Settings → API).
  • Free checks. Results with the status unknown are free, and so are malformed addresses, duplicates and test addresses.

More on beehiiv

Updated · Maintained by: Email Validation LLC

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