Integrations · Forms
Validate emails in Formstack forms
Check the email address in your Formstack forms. It comes in two pieces; use either or both: a snippet you paste into 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 submission a few seconds after it arrives and writes the result into a field of the form. Download them: email-validation-formstack.zip holds formstack-guard.html (the snippet), relay.mjs (the relay) and the MIT licence.
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 origins, every address the form is shown on: the origin your published form opens at (its address up to the first
/after the host name) and any site you embed the form in; 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 Formstack Personal Access Token (Formstack Admin → Personal Access Tokens → Generate token) of a user who can read and edit the form's submissions; and a Cloudflare account to run the relay in.
- In the form, a Short Answer field for the result, labelled for example
Email validation status. The relay writes into it; anything a respondent types there is overwritten.
Stop a bad address at Submit
- Unzip the download and open
formstack-guard.htmlin a text editor. Fill in its four settings:formId: the form's id, the number in the form builder's address;emailFieldId: the Email field's id, the number in the form builder's address while the field is selected;browserKey: your browser key;api: leave it, or sethttps://api-eu.email-validation.orgto have the addresses validated in the EU.
- In the form builder, drag an Embed Code field onto the form and paste the whole file into it (in plain text view). Formstack also takes custom JavaScript in a theme's header or footer; on a form with a payment field, Formstack asks for a business justification before it publishes custom JavaScript.
- Publish the form and test it: enter
no_mailbox@sandbox.email-validation.organd press Submit. The form shows "This address cannot receive email. Please check it." and 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 Formstack's documented form API: it checks the address when the respondent leaves the Email field, and a submit listener calls event.preventDefault() when the result is one you stop (stop: invalid and disposable by default; catch_all too if you add it). If the check is still running when the respondent presses Submit, the form waits for it, 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.
Write the result into each submission
The relay is a Cloudflare Worker in your own account. From the unzipped folder:
npx wrangler deploy relay.mjs --name ev-formstack-relay --compatibility-date 2026-10-01
npx wrangler secret put EV_API_KEY --name ev-formstack-relay # our API key, with Validate addresses
npx wrangler secret put FORMSTACK_TOKEN --name ev-formstack-relay # the Formstack Personal Access Token
openssl rand -hex 32 # a new secret for the relay's address
npx wrangler secret put RELAY_TOKEN --name ev-formstack-relay # paste that secretNo 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):
| Setting | What it does |
|---|---|
STATUS_FIELD_ID | The id of the Short Answer field the relay writes the result into. Without it the relay only logs |
EMAIL_FIELDS | Comma-separated ids of the Email fields to check (default: every Email field, at most 5) |
EV_REGION | eu to have addresses validated in the EU and their results stored there (default us) |
FORWARD_URL | An https URL of yours that receives each submission's results as JSON |
FORWARD_SECRET | Signs the forward: header X-EV-Signature: sha256=<base64 HMAC-SHA256 of the body> |
INCLUDE_EMAIL | true to put the address in the forward (default: ids and results only) |
EVENTS | A KV namespace binding (recommended): each checked submission is remembered by every relay instance |
Then, in the form's Settings → Emails & Actions → Advance Settings → Add Webhook, enter the URL https://ev-formstack-relay.<your subdomain>.workers.dev/<RELAY_TOKEN>/<form id> (either content type). On a form that sends the respondent no email (test addresses receive no mail, and the bounce hurts your sender), submit once with no_mailbox@sandbox.email-validation.org (with the snippet on the form, 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 submission 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.
Who can call the relay
Formstack's webhook can carry an HMAC signature, but its documentation does not say how it is made, so the relay does not rely on it: the secret part of the relay's address is what keeps others out, so keep it like a key. Anything sent to another address gets 401. The relay trusts only the form and submission ids in a delivery: it reads the submission from Formstack with your token, checks it belongs to the form in its address, and checks the addresses Formstack holds. It answers Formstack at once and does the rest a moment later. A submission is checked once (a second delivery of it costs nothing), and one made more than about a day ago is not checked at all.
It writes only the status field (PUT /submissions/{id} with that one field) and never deletes a submission. It never writes into an Email field or any other field that is not text, so a swapped id cannot replace an address. When our API runs no check (a rate limit, no credits, the daily cap) or Formstack cannot be read, nothing is written and a later delivery of the same submission is checked. A form with encryption cannot be read without its password, which the relay does not hold: it checks nothing there.
Try it on a test form first
Formstack's documentation does not say whether event.preventDefault() still stops the form when the submit listener has waited for the check (the snippet then calls it after the check answers), whether an edit through its API keeps the other answers of a submission (the relay sends only the status field), or whether such an edit sends the form's notification emails again. Nor does it say that a webhook's UniqueID is the submission's id, which the relay reads back (if it is not, every delivery is logged not_found and nothing is checked or written). Try both pieces on a test form with the sandbox address above before you rely on them. Neither has run against a real Formstack account yet.
The relay logs one line per submission with ids and results, never an address; the snippet writes nothing to the browser console except a warning when its settings cannot work.