Integrations · Forms

Validate your Demio registrants

Check the email address of the people who register for your Demio webinars. One file on your own server, in two pieces: your own registration form checks the address first and registers the person with Demio only when it is not one you stop, and a sweep reads a session's registrants and tells your code which addresses are bad. If our API is slow or down, the registration goes ahead as usual.

It is one TypeScript file with no dependencies, under the MIT licence (the text is at the top of the file). Download it: email-validation-demio.ts. It runs on any server with fetch and Web Crypto: Next.js, Remix, Hono, Express, Bun, Deno, Cloudflare Workers, Node 22 or later. Node 22.18 and later run a .ts file as it is; older Node through a TypeScript build step or npx tsx.

How it works, and its limits

Demio's registration page runs no code of yours, and Demio's API has no webhooks and no call that removes a registrant. So nothing can stop a registration made on Demio's own page. What the file does:

  • Your own registration form (createDemioRegistration): it checks the address with one call to our API, and registers the person with Demio's Register call (PUT /event/register) only when the address is not one you stop (by default invalid only). On this path a bad address never becomes a registrant.
  • Registrations on Demio's page (createDemioSweep): run it on a schedule of yours. It reads a session's registrants with Demio's Event Date participants call, checks each address once and hands each answer to your onResult function. It only reports: nothing in Demio changes, and you act on it yourself (Demio's dashboard, your email tool, your CRM). Demio's reference says this call returns everyone registered for the session, so a sweep before the webinar sees the people who have registered so far.
  • The check alone (checkRegistrationEmail), for your own code.

Each answer is kept for 30 days per event and address, so your form and the sweep share it: a person your form checked is not checked again by the sweep, and an address registering twice for one event is checked once. Only a definite answer is kept: a timeout or an unknown is checked again next time.

What you need

  • An API key from the API keys page with the permission Validate addresses, and a daily credit cap. Put it in your server's environment as EV_API_KEY.
  • Demio's API key and secret: in Demio, Account Settings → API (only the account's Owner sees it). Put them in your server's environment as DEMIO_API_KEY and DEMIO_API_SECRET. They go only to Demio's API, in its two headers Api-Key and Api-Secret.
  • The event id and session id (id and date_id) of the webinar, from Demio's GET /events call.

Demio's free trial (14 days) includes the API, with up to 100 API calls a day; paid plans have up to 5,000 a day, and every account up to 180 a minute (Demio's help article "API Limitations"). The daily count is shared with Zapier and every other tool that uses your Demio key, and resets at 00:00 UTC. Each registration through your form is one Demio call, and each sweep one.

Set it up

  1. Copy email-validation-demio.ts into your server code, for example to lib/.

  2. Your registration form. In the Next.js App Router, app/api/register/route.ts:

    import { createDemioRegistration } from '@/lib/email-validation-demio';
    
    const register = createDemioRegistration({
      apiKey: process.env.EV_API_KEY,
      demio: { apiKey: process.env.DEMIO_API_KEY, apiSecret: process.env.DEMIO_API_SECRET },
    });
    
    export async function POST(request: Request) {
      const form = await request.formData();
      const result = await register({
        eventId: process.env.DEMIO_EVENT_ID ?? '',
        name: String(form.get('name') ?? ''),
        email: String(form.get('email') ?? ''),
      });
      if (result.outcome === 'stopped') {
        return Response.json({ error: 'Please check your email address.', didYouMean: result.decision.didYouMean }, { status: 422 });
      }
      if (result.outcome === 'registered') return Response.json({ joinLink: result.joinLink });
      if (result.outcome === 'unconfirmed') {
        // The person may be registered: look in Demio before anyone tries again.
        return Response.json({ message: 'Thanks! Watch your inbox for the confirmation.' }, { status: 202 });
      }
      return Response.json({ error: 'Registration did not go through. Please try again later.' }, { status: 502 });
    }

    Without dateId, Demio registers the person for the event's next session.

  3. The sweep, for example on a Cloudflare Workers Cron Trigger, hourly for the sessions of the coming days:

    import { createDemioSweep } from './email-validation-demio.ts';
    
    export default {
      async scheduled(_controller, env) {
        const sweep = createDemioSweep({
          apiKey: env.EV_API_KEY,
          demio: { apiKey: env.DEMIO_API_KEY, apiSecret: env.DEMIO_API_SECRET },
          store: kvStore(env.EV_DEMIO_KV), // your get/set over Workers KV
          onResult: async (r) => {
            if (r.outcome === 'stopped') await notifyTeam(r); // your code: Slack, email, CRM
          },
        });
        const summary = await sweep({ eventId: env.DEMIO_EVENT_ID, dateId: env.DEMIO_DATE_ID });
        // the summary holds counts only: safe to log
      },
    };

    On serverless hosts or several instances, pass a store (Workers KV, Redis, a table: get(key) and set(key, value, ttlSeconds)), so kept answers last across runs.

  4. Test it. To see the stopped path, call checkRegistrationEmail('no_mailbox@sandbox.email-validation.org', options) from your server: it is free and always answers invalid. Then register once through your form with an address of yours that receives mail (outcome: 'registered'). Never register a test or sandbox address with Demio, on its page or through your form: Demio emails every registrant a confirmation at once and reminders later, and mail to an address that cannot receive it hurts your sender.

What your form gets

outcomeWhat happenedWhat to do
registeredDemio answered 201 with a join link (joinLink)Show the link to the person; never log it
stoppedOur check stopped the address; Demio was not calledAsk for another address (decision.didYouMean may suggest one)
failedDemio refused, or the name was missing; nothing was registerederror says which
unconfirmedNo answer from Demio in time, a 5xx, or another answer than a 201 with a join linkThe person may be registered: look in Demio before you try again

The sweep calls onResult once per registrant and address with a definite answer: { eventId, dateId, email, name, participantStatus, outcome, decision, fromMemory }, with outcome stopped or allowed. The address is in it because Demio's report has no registrant id and you need it to act: keep it out of shared logs. The sweep returns a summary of counts: { outcome, error, participants, checked, reported, stopped, known, unchecked, skipped, left, reportFailed }.

Options

OptionDefaultWhat it does
apiKeyrequiredOur API key. Missing: nothing is checked, and your form registers people unchecked.
demiorequired{ apiKey, apiSecret }: Demio's key and secret, both required
regionuseu validates addresses in the EU and stores their results there, with the same key
stop['invalid']Statuses that stop a registrant, from invalid, disposable, catch_all
timeoutMs6000How long to wait for our answer before the address stays unchecked (whole milliseconds, 1 to 60000)
storenoneShares kept answers across instances and runs
budgetMs60000Sweep only: the most one sweep may take, from its start (whole milliseconds, 1 to 600000)
maxChecks200Sweep only: the most addresses one sweep pays to check (1 to 10000)
onResultnoneSweep only: called once per registrant and address with a definite answer

When something fails

Everything fails open: if our API is slow, out of reach or out of credits, your form registers the person unchecked and decision.error says why. A refused key, no credits or the key's daily cap pause the checks of that key for 5 minutes; a sweep that meets one ends early (its outcome is ended_early) and the next sweep goes on where it left off. A sweep also ends early when it reaches budgetMs or maxChecks.

Demio's errors come back as error: demio_key_refused (the key or secret refused, or an inactive account), demio_rate_limited (Demio's per-minute rate or daily allowance reached), demio_call_refused (another refusal, such as a wrong event id), demio_call_failed (no answer within 10 seconds, or a 5xx) and demio_unexpected_answer. Nothing is retried behind your back on your form; choose how often to sweep with Demio's daily allowance in mind.

What it costs

Each checked address uses one credit. unknown results, malformed addresses and test addresses are free. An answer kept from your form or an earlier sweep is not paid again.

Privacy

The file writes no log line and puts no key, secret or address in an error. To our API it sends only the address, in the body of a request, never in a URL. To Demio it sends only what your form gives for a registration, and the session id in the participants call. A sweep's summary holds counts only; onResult gets the address of your own registrant so that you can act on it.

More on Demio

Updated · Maintained by: Email Validation LLC

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