Integrations · Forms

Validate your Cal.com bookings

Find out when someone books a meeting with you on Cal.com with an email address that cannot receive mail. A small webhook receiver on your own server checks each new booking's address and tells your code the result: send it to Slack, your CRM or a review queue. If you switch it on, it can also cancel the booking, or decline it while it waits for your confirmation. If the API is slow or down, the booking stays as it is.

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-calcom.ts. It runs on any server with fetch and Web Crypto: Next.js, Remix, Hono, Express, Bun, Deno, Cloudflare Workers, Node 22 or later.

How it works, and its limits

Cal.com has no hook that runs before it creates a booking, and its webhooks cannot stop one. So the check runs right after the booking, when Cal.com has already sent its confirmation emails:

  1. Cal.com sends the Booking Created or Booking Requested webhook to your server. The receiver verifies its signature (X-Cal-Signature-256, with the secret you set) and refuses a delivery more than five minutes old.
  2. It checks the address of the person who booked (the booking form's email answer) with one call to our API and hands the result to your onResult function. Guests are not checked.
  3. Only if you set onStop: 'cancel': when the result is a status you chose to stop (by default invalid only), it cancels the booking through Cal.com's API, or declines it while it waits for your confirmation. It does this a few seconds after answering Cal.com, so Cal.com has finished saving the booking first. Bookings with seats are never cancelled.

If you turn on Requires confirmation for an event type, new bookings wait for you, so a bad address can be declined before you confirm it.

There is also a server-side check for your own booking flow: if your server creates bookings through Cal.com's API, call checkBookingEmail first and a stopped address never gets a booking.

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, never in browser code.
  • A webhook secret: a long random string you choose (for example openssl rand -hex 32, or on Windows your password manager's generator), as CALCOM_WEBHOOK_SECRET. Cal.com signs each delivery with it.
  • Only for onStop: 'cancel', a Cal.com API key: in Cal.com, Settings → Developer → API keys → New. Cal.com shows the key once. Make it with the account that owns the event types, or one with access to their bookings (a team admin, for example), and put it in your server's environment as CALCOM_API_KEY.

Webhooks are on every Cal.com plan, Free included.

Set it up

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

  2. Add a route. In the Next.js App Router, app/api/webhooks/calcom/route.ts:

    import { createCalcomBookingHook } from '@/lib/email-validation-calcom';
    
    export const POST = createCalcomBookingHook({
      apiKey: process.env.EV_API_KEY,
      secret: process.env.CALCOM_WEBHOOK_SECRET,
      onResult: async (r) => {
        if (r.outcome === 'stopped') await notifyTeam(r); // your code: Slack, email, CRM
      },
      // opt-in: cancel (or decline) a booking whose address is invalid
      // onStop: 'cancel',
      // calcom: { apiKey: process.env.CALCOM_API_KEY },
      // waitUntil: after, // from 'next/server', so the delayed cancel keeps running
    });

    On Cloudflare Workers, pass the context so the delayed cancel keeps running: fetch: (request, env, ctx) => hook(request, ctx). In Express, read the raw body (the signature covers the exact bytes):

    import express from 'express';
    import { createCalcomWebhookHandler } from './email-validation-calcom.ts';
    
    const handle = createCalcomWebhookHandler({ /* the same options */ });
    app.post('/webhooks/calcom', express.raw({ type: '*/*' }), async (req, res) => {
      const result = await handle({ body: req.body, headers: req.headers });
      res.status(result.status).json(result.body);
    });
  3. In Cal.com, go to Settings → Developer → Webhooks → New. Enter your route's public HTTPS address as the subscriber URL, pick the triggers Booking Created and Booking Requested, set the secret to the value of CALCOM_WEBHOOK_SECRET and keep the default payload (no custom payload template).

  4. Test it. Cal.com's Ping test sends made-up data with no booking: the receiver answers it 200. Then book a meeting with an address of yours that receives mail and watch onResult (outcome: 'allowed'). Never book with a test address that cannot receive mail, a sandbox address included: nothing blocks the booking, so Cal.com's confirmation email to it would bounce and hurt your sender. To see the stopped path, call checkBookingEmail('no_mailbox@sandbox.email-validation.org', options) from your server: it is a test address, free, and always answers invalid. Or post a delivery you sign yourself with signCalcomWebhook.

Options

OptionDefaultWhat it does
apiKeyrequiredOur API key. Missing: nothing is checked.
secretrequiredThe webhook's secret. Missing: every delivery is refused.
calcomnone{ apiKey, origin?, apiVersion? }: Cal.com's API, needed for cancel; origin for a self-hosted Cal.com
regionuseu validates addresses in the EU and stores their results there (EU data residency)
stop['invalid']Statuses that stop a booking, from invalid, disposable, catch_all, unknown
onStopnonenone tells you; cancel cancels or declines the booking
actDelayMs5000With cancel: how long after the answer the booking is read and cancelled
reason"The email address given for this booking could not be verified."Sent with a cancellation or a decline
maxAgeS300The oldest delivery accepted, by its signed time, in seconds
timeoutMs6000How long to wait for our answer before the booking stays unchecked
waitUntilnoneWith cancel on serverless hosts: keeps the delayed cancel running after the answer
onResultnoneCalled once per checked booking, never with the address

When something fails

No key, a timeout, a network error, a rate limit, a refused key, no credits or any other error answer leaves the booking as it is, and onResult gets outcome: 'unchecked'. The receiver answers 400 to a delivery whose signature does not match or that is more than five minutes old; createCalcomBookingHook refuses a body over 256 KiB (with createCalcomWebhookHandler, your framework's body limit applies). If Cal.com's API fails or refuses a cancel, the booking stays and onResult is told why; a failed cancel is tried again if Cal.com sends the same delivery again. A booking whose address changed, or that is already cancelled, is left alone.

What it costs

Each check costs at most 1 credit, like any validation request. unknown results, errors, malformed addresses and test addresses are free. A repeated delivery of the same booking and address reaching one running server is answered from memory, without a second check. Credits come in one-time packs, from $0.15 per 1,000 with the 50,000,000-credit pack (smaller packs cost more per credit), and new accounts get 500 free credits (100 when you sign up with a free email provider such as Gmail, Outlook or Yahoo, another personal mailbox such as a paid one like Fastmail or one from your internet provider, or an address from a relay or alias service). Only a few accounts from one domain or one network receive them in a given period.

Privacy

The file sends only the booker's address, in the body of a POST to https://api.email-validation.org (or https://api-eu.email-validation.org). It never puts the address in a URL and sends it to no other host. Your API key goes only to our API, and the Cal.com key only to Cal.com. The file writes no log line, and what it passes to onResult holds the booking's uid and id, the event, the outcome, the action and our answer, never the address.

More on Cal.com

Updated · Maintained by: Email Validation LLC

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