Skip to content

// auth and identity

Via API

Supabase Auth email verification with pingutil

Supabase Auth inserts a row into auth.users for every sign-up that passes basic validation, and free-tier projects attract scripted accounts. The Before User Created hook runs first; pointing it at an Edge Function that calls pingutil lets you return a 400 with your own message for disposable and randomized addresses.

Where it connects: Supabase Auth Hooks, Before User Created hook (HTTP, Edge Function)

What goes wrong without it

  • auth.users has thousands of rows from temp-mail domains and our RLS-protected tables fill with their junk.
  • Magic-link sign-ups mean every throwaway inbox becomes a real Supabase user.
  • We tried a domain blocklist in a Postgres trigger and it was stale within a month.

What you can do with Supabase Auth and pingutil

  • Reject throwaway sign-ups

    For verdict.is_spam, return { error: { http_code: 400, message } }. Supabase passes the message to the client and does not create the user.

  • Keep the blocklist fresh without maintaining it

    pingutil re-syncs its disposable list (about 9,900 domains) every Monday, so the hook does not depend on a list you have to update.

  • Allow work and personal addresses differently

    category tells you free, isp or company. Some B2B apps reject free webmail at sign-up; return the same error shape with a "use your work email" message.

Set it up

  1. 1

    Create an Edge Function (supabase functions new before-user-created) with the code below.

  2. 2

    In the dashboard, go to Authentication > Hooks, add a Before User Created hook of type HTTPS pointing to the function URL, and generate a secret.

  3. 3

    Set the secrets: supabase secrets set BEFORE_USER_CREATED_HOOK_SECRET=... PINGUTIL_KEY=pk_live_...

  4. 4

    Deploy with supabase functions deploy before-user-created --no-verify-jwt, since the hook authenticates with its own signature.

  5. 5

    Sign up with a disposable address and confirm the client receives your error message.

supabase/functions/before-user-created/index.ts
import { Webhook } from 'https://esm.sh/standardwebhooks@1.0.0';

const reject = (message: string) =>
  Response.json({ error: { http_code: 400, message } }, { status: 400 });

Deno.serve(async (req) => {
  const payload = await req.text();
  const secret = (Deno.env.get('BEFORE_USER_CREATED_HOOK_SECRET') ?? '').replace('v1,whsec_', '');

  let user: { email?: string };
  try {
    ({ user } = new Webhook(secret).verify(payload, Object.fromEntries(req.headers)) as { user: { email?: string } });
  } catch {
    return new Response('Invalid signature', { status: 400 });
  }
  if (!user.email) return Response.json({});

  try {
    const res = await fetch('https://pingutil.com/v1/lookup', {
      method: 'POST',
      headers: {
        authorization: 'Bearer ' + Deno.env.get('PINGUTIL_KEY'),
        'content-type': 'application/json',
      },
      body: JSON.stringify({ input: user.email, skip_enrichment: true }),
      signal: AbortSignal.timeout(2500), // HTTP hooks get 5 s in total
    });
    if (!res.ok) return Response.json({}); // fail open
    const data = await res.json();

    if (data.verdict.is_spam) return reject('Please sign up with a permanent email address.');
    return Response.json({});
  } catch {
    return Response.json({});
  }
});

What to do with each result

pingutil resultAction in Supabase Auth
verdict.is_spam: trueReturn 400 with error.message; Supabase does not insert the user
category: "free" (if you require work email)Return 400 with a "use your work email" message
verdict.low_trust: trueAllow; log the reason or write it to a profile table after sign-up
Timeout, 429 or 5xxReturn {} with 200 (fail open)

Limits to plan for

  • Supabase says HTTP hooks should complete in 5 seconds, including retries. A full mailbox check does not reliably fit, so the hook uses fast mode.
  • Fast mode does not catch dead mailboxes or typos. Supabase's confirmation email will still bounce for those unless you also call /v1/verify.
  • The fast check is heuristic. A brand-new disposable domain with a normal-looking local part can pass until it reaches the list.

Supabase Auth documentation

Supabase Auth is a trademark of its owner. This integration uses Supabase Auth's documented extension points; it is not an official Supabase Auth app.

Common questions

Can I write the hook in Postgres instead of an Edge Function?
Supabase supports Postgres hooks, but they get 2 seconds and cannot easily call an external HTTP API. An HTTP hook on an Edge Function is the simpler place to call pingutil.
Does the hook run for OAuth sign-ups?
Yes. Supabase's own examples read user.app_metadata.provider in this hook, so you can skip the check for providers you trust.

Stop bad addresses in Supabase Auth today

Sign in with your email, create an API key and paste it into the step above. Test on a few real addresses first: the live demo shows exactly what your Supabase Auth setup will receive.