# Validate Emails of Stripe Customers: Setup Guide

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

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

Check the email addresses of the customers in your Stripe account and keep each verdict in the customer's metadata.
You see it on the customer in the Stripe Dashboard, can find customers by it with Stripe's search (for example
`metadata['ev_action']:'remove'`) and can use it in your own code. Two pieces do the work, and you can use either or
both:

- **A relay for every new or changed customer.** A Stripe webhook calls a small relay you deploy to your own
  Cloudflare account; it checks the customer's address and writes the metadata within seconds.
- **A sync script for the customers you already have.** It checks every customer without a verdict as one
  [bulk list](https://email-validation.org/docs/bulk/) and writes the metadata back.

**It never touches money.** It never creates, deletes or changes a customer's details, and never touches a payment,
subscription, charge, invoice, refund or payout. It writes nothing but its five metadata keys, with a restricted key,
and never deletes a metadata key. A flagged address is a hint to look (a typo is common and harmless), not a verdict on
the customer.

**It cannot stop a sign-up or a payment.** Stripe sends its webhooks after the fact, so the relay hears of a customer
only once Stripe has created or changed it; a check that is slow or fails changes nothing.

**Status: set up from this page.** There is no Stripe App Marketplace listing: you run the relay in your own Cloudflare
account and the script on your computer, with your own Stripe key. It has not yet been tried on a real Stripe account,
so try it in a Stripe sandbox first.

Download it: [email-validation-stripe.zip](https://email-validation.org/downloads/stripe/email-validation-stripe.zip) holds the relay as one
Cloudflare Worker module (`relay.mjs`), the sync script as one Node module (`stripe.mjs`) 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). The sync
  script also needs **Bulk lists**, which is off by default: turn it on when you create the key.
- A Stripe account. Start in a **sandbox** (the Dashboard's account picker → **Sandboxes**): it moves no money
  ([Stripe's sandboxes](https://docs.stripe.com/sandboxes)).
- A Stripe **restricted key** (`rk_test_…` in a sandbox, `rk_live_…` in live mode): on the
  [API keys](https://dashboard.stripe.com/apikeys) page, **Create restricted key**, start from zero permissions, set
  **Customers** to **Write** and leave every other resource at **None**. Write includes read. Stripe asks for a
  two-factor check and shows the key once
  ([Stripe's restricted keys](https://docs.stripe.com/keys/restricted-api-keys)). The relay and the script refuse a
  secret key (`sk_…`), which can do everything in the account.
- For the relay: a Cloudflare account and Cloudflare's `wrangler` command (`npx wrangler`, on a computer with Node).
- For the script: a computer with Node 22.18 or later.

Stripe sets permissions per resource, not per field: **Customers: Write** lets a key create, update and delete
customers. The relay and the script check every Stripe request against a list before it is sent (the customer list,
one customer by id, and a write of the five metadata keys to one customer by id) and refuse anything else, and with
every other resource at **None** the key cannot reach payments, subscriptions, invoices, refunds or payouts. Keep it a
secret all the same.

Our key goes only to our API, the Stripe key only to `https://api.stripe.com`. Neither piece prints, logs or answers
an address or a key.

## The metadata

| Metadata key | Value |
| --- | --- |
| `ev_status` | the address's [status](https://email-validation.org/docs/statuses/): `valid`, `invalid`, `catch_all`, `unknown` or `disposable` |
| `ev_reason` | why, such as `accepted` or `no_mailbox` |
| `ev_action` | what to do: `send`, `send_with_caution`, `remove` or `retry_later` |
| `ev_checked_at` | when the check ran (ISO 8601, UTC) |
| `ev_email_sha256` | the SHA-256 (hex) of the address that was checked, trimmed and lower-cased |

Find the addresses you should not mail with `ev_action`: spam traps and complainers are `ev_status` `valid` with
`ev_action` `remove`. `ev_email_sha256` tells whether the verdict belongs to the address the customer has today: when a
customer's address changes, the old verdict no longer matches and the address is checked again. Metadata is not
visible to your customers unless you show it ([Stripe's metadata](https://docs.stripe.com/metadata)). A customer whose
metadata already holds 46 or more keys of its own has no room for the five: it is skipped (and counted), never checked.

## Set it up

### Check the customers you have

From the unzipped folder, with your sandbox's restricted key first:

```bash
cd email-validation-stripe
export EV_API_KEY=…  STRIPE_API_KEY=…
node stripe.mjs --dry-run    # exports the customers and counts what it would check
node stripe.mjs              # checks and writes the metadata
```

In Windows PowerShell (5.1 or 7):

```powershell
cd email-validation-stripe
$env:EV_API_KEY = "…"; $env:STRIPE_API_KEY = "…"
node stripe.mjs --dry-run    # exports the customers and counts what it would check
node stripe.mjs              # checks and writes the metadata
```

`--dry-run` uploads, checks and writes nothing. The script reads every customer, skips those without an address and
those that already hold a verdict other than `unknown` for their current address (add `--revalidate` to check them
again), checks the rest as one bulk list, and writes each customer whose address is still the one it checked. It prints
customer ids, job ids and counts, never addresses.

If a run stops for any reason (no credits, a closed laptop, a Stripe outage), run the same command again. It keeps the
bulk job's id in a state file in the current folder (`.ev-stripe-test.json` or `.ev-stripe-live.json`: ids only, no
addresses or keys) and resumes that job instead of uploading a new one, so the same customers are not paid for twice.
Exit code `75` means the list was still running when the script stopped waiting: run it again later. Run it daily or
weekly to catch anything the relay missed; each run checks only customers without a verdict for their current address.

### Check every new customer

1. **Deploy the relay** from the unzipped folder and store its keys:

   ```bash
   cd email-validation-stripe
   npx wrangler deploy relay.mjs --name ev-stripe-relay --compatibility-date 2026-10-01
   npx wrangler secret put EV_API_KEY --name ev-stripe-relay       # our API key
   npx wrangler secret put STRIPE_API_KEY --name ev-stripe-relay   # the restricted key (rk_test_… first)
   ```

   `wrangler deploy` prints the Worker's address, such as `https://ev-stripe-relay.<your subdomain>.workers.dev`.
   For the EU, add `--var EV_REGION:eu` to the deploy command, and to every redeploy (a deploy replaces the settings
   made with `--var`; secrets stay).
2. **Create the webhook.** In the Stripe Dashboard (in the sandbox), open the
   [Webhooks](https://dashboard.stripe.com/webhooks) tab in Workbench → **Create an event destination** → **Your
   account**, the payload **Snapshot** with an API version (your account's default is fine), the events
   **customer.created**, **customer.updated** and **checkout.session.completed**, then **Webhook endpoint** and the
   relay's address ([Stripe's webhooks guide](https://docs.stripe.com/webhooks)).
3. **Copy its signing secret** (`whsec_…`, **Reveal secret** on the endpoint) into the relay:

   ```bash
   npx wrangler secret put STRIPE_WEBHOOK_SECRET --name ev-stripe-relay
   ```

4. **Live mode** has its own keys and endpoints: once the sandbox works, deploy a second relay (for example
   `ev-stripe-relay-live`) with an `rk_live_…` key and the live endpoint's secret. A relay acts only on events of its
   key's mode.

A relay missing a setting, or holding a key that is not a restricted key, answers `500`. Workbench → Webhooks → the
endpoint → **Event deliveries** shows each answer.

## How it works

1. **The signature first.** Stripe signs each delivery with `Stripe-Signature`: a time `t` and one `v1` SHA-256
   signature of `<t>.<raw body>` per active signing secret (two while you roll the secret). The relay accepts only a
   delivery with a matching `v1`, compared in constant time, and a `t` within 5 minutes of now, the tolerance of
   Stripe's own libraries. Anything else is answered `400` and starts nothing.
2. **Which events start a check.** `customer.created`; `customer.updated` only when the address changed (Stripe's
   `previous_attributes` names `email`), so the relay's own metadata write never starts another check; and
   `checkout.session.completed` for the session's existing customer. A guest checkout has no customer and is skipped;
   create the session with `customer_creation` set to `always` to have one. Events of connected accounts are ignored.
3. **The customer as Stripe holds it now.** Stripe may deliver events out of order and more than once, so the relay
   reads the customer by id and skips one whose metadata already holds a verdict (other than `unknown`) for that same
   address. That verdict is in Stripe, so every relay instance sees it.
4. **The check and the write.** The relay checks the address and writes the five keys, with an idempotency key, so a
   write Stripe gets twice is applied once. Each relay instance also holds a customer it is working on, or whose check
   may have been charged without a verdict written, so another delivery about the same customer and address reaching
   that instance checks nothing. That hold is in one instance's memory: a Worker instance can restart at any time, and
   two deliveries that reach two instances at once can both be checked.
5. **Answered quickly.** Stripe resends a delivery that gets no `2xx` for up to three days in live mode (three times
   over a few hours in a sandbox). The relay keeps each delivery to about 12 seconds and answers `200` once a check may
   have run, so Stripe does not send it again and pay for it twice. It answers `503` when our API ran no check (a rate
   limit) and `422` when our API or Stripe refused the key, so Stripe sends the delivery again later, uncharged.

A customer the relay could not write has no verdict, so the next sync run checks it, **and that second check is paid
again**. For an import of many customers, run the sync script rather than relying on the relay.

## Try it free first

First on your computer: run `node stripe.mjs --dry-run` with your sandbox's restricted key. It reads the sandbox's
customers and prints what it would check, and uploads, checks and writes nothing.

Then in the sandbox, with the relay set up: on the Dashboard's **Customers** page add one customer whose email is
`no_mailbox@sandbox.email-validation.org`, with no payment, invoice or subscription. Within a few seconds its metadata holds
`ev_status` `invalid` and `ev_action` `remove`. Sandbox checks cost no credit. That domain receives no mail, so send
that customer no invoice or receipt: Stripe sends no automatic receipt for a sandbox payment
([Stripe's receipts](https://docs.stripe.com/receipts)), but one you send by hand goes out.

Then add one customer with your own email address: its metadata gets your address's verdict, such as `ev_status`
`valid` and `ev_action` `send`, which uses one credit unless the answer is `unknown`.

## Options

The sync script's options:

| Option | Default | What it does |
| --- | --- | --- |
| `--dry-run` | off | Export and count only: nothing is uploaded, checked or written. |
| `--revalidate` | off | Also check customers that already have a verdict for their address. |
| `--region eu` (or `EV_REGION=eu`) | `us` | Check the addresses in the EU and store the list there (same keys and credits). |
| `--rate N` | `10` | Stripe requests a second, at most 25. Stripe's limits are per account and shared with everything else that calls it. |
| `--wait-minutes N` | `240` | How long to wait for the bulk list before stopping (it keeps running; run again to resume). |
| `--state FILE` | `.ev-stripe-<mode>.json` | Where the bulk job's id is kept between runs; another file for a second Stripe account. |
| `--new-job` | off | Forget the saved job and upload again (refused while that job is still running). |

The relay's settings:

| Setting | Default | What it does |
| --- | --- | --- |
| `EV_API_KEY` | required (secret) | Our API key (Validate addresses). |
| `STRIPE_API_KEY` | required (secret) | The restricted key with Customers: Write. |
| `STRIPE_WEBHOOK_SECRET` | required (secret) | The webhook endpoint's signing secret. |
| `EV_REGION` | `us` | `eu` checks the address in the EU and stores its result there (same keys and credits). |

Settings marked secret go in with `npx wrangler secret put`; `EV_REGION` with `--var EV_REGION:eu` on every deploy.

## Credits and limits

Each check uses one credit; `unknown` results and sandbox addresses are free, and so are duplicates within one bulk
list. A customer that already holds a verdict for its current address is not checked again by either piece. Checking
an address again later (with `--revalidate`, or after the relay could not write its verdict) is a new check, and paid.

Each relay delivery costs one Stripe read and, after a check, one write. The sync script reads one page of 100
customers per request, and the same again before it writes. Stripe allots read requests by an account's transactions,
so on a large account with few transactions a frequent schedule can use that allotment up; weekly is the safer choice
there ([Stripe's rate limits](https://docs.stripe.com/rate-limits)).

It fails open: a timeout, a network error, a rate limit or any error answer leaves the customer as it is.

[What each status means](https://email-validation.org/docs/statuses/).

## More on Stripe

- [Stripe email validation integration](https://email-validation.org/integrations/stripe/)
