Skip to content

Auth & backend

Verify signups in Auth0 with a pre-registration Action

Deny undeliverable and disposable emails in an Auth0 Pre User Registration Action with api.access.deny, flag risky IPs, and let signups through on API errors.

Updated 2026-11-26

This recipe adds a Pre User Registration Action to Auth0. It checks the email of every database signup before the user is created, denies addresses that cannot receive mail or belong to a disposable inbox service, and flags signups from high-risk networks in app_metadata. There is no native Qelka integration for Auth0: the Action is a few lines of JavaScript in your tenant.

Auth0 runs Actions in this trigger synchronously: the signup waits for the Action, and a call to api.access.deny stops it. That makes it the right place for a hard rule, as long as the Action never turns an API problem into a refusal.

What you need

  • An Auth0 tenant with a Database connection, and access to Actions (check your plan).
  • A Qelka API key. The key sits in Auth0's secret store, so create a restricted key limited to email and ip. A sk_test_ key returns simulated results and never spends credits: see Test mode.

Steps

1. Create the Action

In the Auth0 Dashboard, go to Actions, Library, and select Create Action, then Build from scratch. Name it Verify signup email, select the Pre User Registration trigger, and create it. Keep a Node.js runtime of 18 or later: it has fetch and AbortSignal.timeout built in, so the Action needs no dependency.

2. Add the secret

In the code editor, select the key icon in the left sidebar, then Add Secret. Name it QELKA_API_KEY and paste your key as the value. The code reads it from event.secrets. Never paste the key into the code itself.

3. The code

Replace the editor content with:

javascript
async function lookup(path, body, apiKey) {
  try {
    const response = await fetch(`https://api.qelka.com/v1${path}`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${apiKey}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(body),
      signal: AbortSignal.timeout(5000),
    })
    if (response.ok) return await response.json()
    const failure = await response.json().catch(() => null)
    console.log(`${path} check skipped: ${failure?.error?.type ?? response.status} request ${response.headers.get('X-Request-Id')}`)
  } catch (error) {
    console.log(`${path} check skipped: ${error.name}`)
  }
  return null
}

exports.onExecutePreUserRegistration = async (event, api) => {
  const apiKey = event.secrets.QELKA_API_KEY
  const ip = event.request.ip

  const [email, network] = await Promise.all([
    event.user.email ? lookup('/email', { email: event.user.email, mode: 'fast' }, apiKey) : null,
    ip ? lookup('/ip', { ip }, apiKey) : null,
  ])

  if (email?.status === 'undeliverable') {
    const hint = email.did_you_mean ? ` Did you mean ${email.did_you_mean}?` : ''
    api.access.deny(`email_${email.reason}`, `This email address cannot receive mail.${hint}`)
    return
  }

  if (email?.checks.disposable) {
    api.access.deny('email_disposable', 'Please sign up with a permanent email address.')
    return
  }

  api.user.setAppMetadata('email_status', email ? email.status : 'unchecked')
  if (network && (network.risk.level === 'high' || network.flags.tor)) {
    api.user.setAppMetadata('signup_review', true)
  }
}

The email and IP checks run in parallel, so the Action takes as long as the slower of the two. mode: 'fast' runs the syntax, DNS and list checks and skips the mailbox check, which waits on the recipient's mail server: in a trigger that holds the signup, a predictable answer matters more than the mailbox result. Fast mode still catches typos, dead domains and disposable inboxes. See the email reference and the IP reference.

lookup returns null on any failure, and every rule checks for a real answer before acting. A wrong key, an empty balance, a timeout or an outage therefore lets the person sign up with email_status: unchecked.

Auth0 documents that this trigger cannot add metadata to passwordless users. On a Passwordless connection, keep the two deny rules and remove the setAppMetadata lines.

4. Test it

Select the test icon in the editor sidebar and run the Action with the sample event. Change user.email in the event to try each branch with a test key:

  • disposable@example.com is denied with the reason email_disposable;
  • nomx@example.com is undeliverable with domain_no_mx and is denied;
  • any other address passes with email_status: unknown, because fast mode skips the mailbox check.

A test key also maps documentation IP ranges to fixed profiles: set request.ip to 198.51.100.200 to get a Tor exit with risk.level high, and see signup_review set.

5. Deploy and attach it

Select Deploy, which saves the code as a new Action version. Then open the Pre User Registration flow under Actions in the dashboard, drag Verify signup email into it, and select Apply. Until you apply the flow, the Action does not run on real signups.

6. What each answer does

Result Meaning Action
Email undeliverable Bad syntax, or a domain that does not exist or takes no mail Denied, with did_you_mean in the message when there is one
Email risky, reason disposable A disposable inbox service Denied with a request for a permanent address
Email risky, other reasons A catch-all domain or a full mailbox Accepted, email_status: risky
Email unknown In fast mode, smtp_not_checked: nothing wrong was found Accepted
No answer API unreachable, key or balance problem Accepted, email_status: unchecked, logged with the error type and request id
IP high risk or Tor Anonymizing or abusive network Accepted, signup_review: true

Never deny on unknown or on the IP alone: a VPN is an everyday privacy tool. Use signup_review to require an extra step later, such as a verified email before the account can do anything costly. Your Post Login Actions and your backend can read app_metadata from the user profile.

Some signups will want the softer path for disposable inboxes too: replace that deny with api.user.setAppMetadata('email_status', 'disposable') and limit those accounts in your app. Block disposable email signups helps you choose.

Social signups

Social connections do not run this trigger. To cover them, create a Post Login Action with the same lookup function and run it only when event.stats.logins_count is 1. Social providers usually verify the address themselves, so the disposable check is the useful part there; flag with api.user.setAppMetadata rather than deny if you prefer not to turn away a first login.

Handle errors and rate limits

Nothing is billed on errors. The Action never retries: a 429 or a 5xx answer ends as unchecked instead of holding the signup, which keeps it far inside Auth0's time limit. 401, 402 and 403 mean a wrong key, an empty balance or a key restricted to other endpoints: watch the Action's log lines for them, and query users whose app_metadata.email_status is unchecked to check them again later. A key allows 200 requests per 10 seconds, and a signup costs 1 credit for the email plus 1 for the IP. See Errors and Rate limits.

Frequently asked questions

Does the Pre User Registration trigger run for social logins?
No. Auth0 documents it for Database and Passwordless connections only, so a Google or GitHub signup skips it. For those, add a Post Login Action that runs the same check when event.stats.logins_count is 1, the user's first login, and flag or deny there.
What does the person see when the Action denies them?
The second argument of api.access.deny is the user message, which Auth0 says may be shown directly in end-user interfaces such as the signup page. The first argument is an internal reason that appears in your tenant logs. Keep the message short and fixable, such as a typo suggestion, and never pass the raw API answer to it.
How long can the Action take?
Auth0 states that each trigger execution must finish in 20 seconds or less, and recommends setting timeouts on outbound calls. Those are their limits and may change. The Action below uses fast mode and a 5-second timeout, so a slow answer ends as unchecked and the signup continues well before the limit.

More in Auth & backend

All integrations

Put this check in your product

Get an API key in under a minute. 100 free credits every month, no card required.

  • 100 free credits a month
  • No card
  • Test keys spend nothing
  • Cancel any time