Integrations · Forms

Validate emails in Cognito Forms

Check the email address in your Cognito Forms forms. It comes in two pieces; use either or both: a snippet you paste into the page that embeds the form stops it before it is sent when the address cannot receive mail or is a throwaway inbox, and a small relay you deploy to your own Cloudflare account checks each new entry a few seconds after it arrives and writes the result into a field of the entry. Download them: email-validation-cognito-forms.zip holds cognito-forms-guard.html (the snippet), relay.mjs (the relay) and the MIT licence. (For Amazon Cognito user pools, see the Amazon Cognito guide instead.)

What you need

  • For the snippet, a browser key: on the API keys page, Create key and pick On a public web page. It can only validate addresses. Give it, as allowed origin, the site the form is embedded in (its address up to the first / after the host name), and a daily credit cap a little above your busiest day. The key sits in the page, so anyone can read it: what it protects and what it does not is on the form guard page. With any other key the snippet checks nothing.
  • For the relay: an API key of ours with Validate addresses (give it a daily credit cap too); a Cognito Forms API key (your organization's Settings → Integrations → + New API Key, made by an owner or administrator) with Entry scope Read/Write and, under Can Access, only this form; and a Cloudflare account to run the relay in. Cognito Forms' API and its JSON webhooks are on its Pro, Team, Business and Enterprise plans (its pricing page lists each plan).
  • In the form, a Textbox field for the result, named for example EmailValidationStatus. The relay writes into it; anything a respondent types there is overwritten.

Stop a bad address at Submit

  1. Unzip the download and open cognito-forms-guard.html in a text editor. Fill in its settings:
    • emailField: the Email field's JSON name, as the form builder's Developer Mode shows it (Email unless you renamed it; a field inside a section is Section.Email);
    • browserKey: your browser key;
    • api: leave it, or set https://api-eu.email-validation.org to have the addresses validated in the EU.
  2. On the page of your site that embeds the form (hover over the form's name, Publish Form, Publish Code: Seamless or Iframe), paste the whole file below the embed code.
  3. Test it: enter no_mailbox@sandbox.email-validation.org and press Submit. The page shows "This address cannot receive email. Please check it." and the form stays. Test addresses cost nothing; they receive no mail, so do not let a test address through on a form that emails the respondent.

The snippet uses only Cognito Forms' documented client-side events: a beforeSubmit handler checks the address and calls event.preventDefault() when the result is one you stop (stop: invalid and disposable by default; catch_all too if you add it). Cognito Forms waits for the check, at most 3 seconds. A slow or failed check, valid and unknown never stop the form, and after a refused key or no credits the snippet sends nothing more from that page. Change the messages in messages. A form opened from its own Cognito Forms link has no page of yours to hold the snippet: there, use the relay.

Write the result into each entry

The relay is a Cloudflare Worker in your own account. From the unzipped folder:

npx wrangler deploy relay.mjs --name ev-cognito-forms-relay --compatibility-date 2026-10-01
npx wrangler secret put EV_API_KEY --name ev-cognito-forms-relay        # our API key, with Validate addresses
npx wrangler secret put COGNITO_API_KEY --name ev-cognito-forms-relay   # the Cognito Forms API key
openssl rand -hex 32                                                   # a new secret for the relay's address
npx wrangler secret put RELAY_TOKEN --name ev-cognito-forms-relay       # paste that secret

No terminal? In the Cloudflare dashboard, create a Worker, paste the whole of relay.mjs into its code editor and deploy, then add the values below under its Settings → Variables and Secrets (the keys and the token as type Secret). For a random RELAY_TOKEN without a terminal, use your password manager's generator: 32 or more letters and digits.

RELAY_TOKEN must be at least 32 letters, digits, - or _. Settings, each added to the deploy command as --var NAME:value (or as a dashboard variable), except EVENTS, a KV namespace you bind under the Worker's Bindings (a text variable of that name is ignored):

SettingWhat it does
STATUS_FIELDThe JSON name of the Textbox field the relay writes the result into. Without it the relay only logs
EMAIL_FIELDSComma-separated JSON names (or Section.Field) of the fields to check (default: every field whose name holds email, at most 5)
EV_REGIONeu to have addresses validated in the EU and their results stored there (default us)
FORWARD_URLAn https URL of yours that receives each entry's results as JSON
FORWARD_SECRETSigns the forward: header X-EV-Signature: sha256=<base64 HMAC-SHA256 of the body>
INCLUDE_EMAILtrue to put the address in the forward (default: ids and results only)
EVENTSA KV namespace binding (recommended): each checked entry is remembered by every relay instance

Then, in the form builder's Settings, check Post JSON Data to a Website and set the Submit Entry Endpoint to https://ev-cognito-forms-relay.<your subdomain>.workers.dev/<RELAY_TOKEN>/<form id>. Leave the Update Entry Endpoint off the relay: the relay's own write is an update. The <form id> is the number at the end of the form's Iframe embed address (and the Seamless code's data-form; Cognito Forms' examples use the same number for both, though its docs do not call it the API's form id). If every entry is logged not_found, check it with the API's Get Forms call (a key with Form scope Read). On a form that sends the respondent no email, submit once with no_mailbox@sandbox.email-validation.org (with the snippet on the page, it stops that address: test the relay before you add the snippet, or on a copy of the form). A few seconds later the status field of that entry shows invalid (no_mailbox), checked 2026-12-02T09:30:00Z, with the time of the check.

The field gets one of our five statuses, the reason and the time. With more than one email field, it gets the first one's result (choose which with EMAIL_FIELDS); every result is in the relay's log line and the forward. The webhook, the relay's read and its write each count against your organization's monthly Cognito Forms integration requests.

Who can call the relay

Cognito Forms' webhook carries no signature, so the secret part of the relay's address is what keeps others out: keep it like a key. Anything sent to another address gets 401. The relay trusts only the entry id in a delivery: it reads the entry from Cognito Forms with your API key (Cognito Forms refuses an entry of another form) and checks the addresses Cognito Forms holds. It answers at once and does the rest a moment later. An entry is checked once (with EVENTS bound, a second delivery of it costs nothing on any relay instance), and one submitted more than about a day ago, or never submitted, is not checked at all. While the relay answers with an error (a wrong setting or address), Cognito Forms sends each entry again, up to 15 times over 72 hours, and each try counts as a request.

It writes only the status field (PATCH with that one field) and never deletes an entry. It never writes into a field that holds anything but text or holds an address (so an Email field named there by mistake keeps the respondent's address), and never checks the status field as an address. When our API runs no check (a rate limit, no credits, the daily cap) or Cognito Forms cannot be read, nothing is written and that entry stays unchecked: the relay has already answered, so Cognito Forms does not send it again.

Try it on a test form first

Cognito Forms' documentation shows the webhook's body only as an example, so the relay takes the entry's Id (or id) from it; if that is not the id its API takes, every delivery is logged not_found and nothing is checked or written. Nor does it say whether an edit through its API runs a workflow step or sends the form's notification emails again (the relay sends only the status field). Try both pieces on a test form with the sandbox address above before you rely on them. Neither has run against a real Cognito Forms account yet.

The relay logs one line per entry with ids and results, never an address; the snippet writes nothing to the browser console except a warning when its settings cannot work.

More on Cognito Forms

Updated · Maintained by: Email Validation LLC

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