# Verify SavvyCal webhooks

Every SavvyCal webhook carries an `x-savvycal-signature` header, `sha256=` followed by an uppercase hex HMAC-SHA256 of the request body, keyed with that webhook's secret. Recomputing it shows the request came from SavvyCal and the body wasn't changed. No timestamp is signed, so it doesn't stop a replay, and SavvyCal's docs name no SDK helper for it.

Agent skill: `npx skills add hookdeck/webhook-skills --skill savvycal-webhooks` ([details](https://hookdeck.com/webhooks/savvycal/skill))

> Independent reference generated from hookdeck/webhook-registry (commit ff7f882, 20 Nov 2026). [SavvyCal's official docs](https://docs.savvycal.com/developers/webhooks#securing-webhooks).

[Overview](https://hookdeck.com/webhooks/savvycal) · [Webhook events (16)](https://hookdeck.com/webhooks/savvycal/events) · [MCP events](https://hookdeck.com/webhooks/savvycal/mcp-events) · [Verify signatures](https://hookdeck.com/webhooks/savvycal/verify) · [Production guide](https://hookdeck.com/webhooks/savvycal/guide-duplicates-ordering-retries-timeouts) · [Agent skill](https://hookdeck.com/webhooks/savvycal/skill)

## The facts

| Fact | Value | Source |
|---|---|---|
| Signature header | `x-savvycal-signature` Format: sha256=<uppercase hex> | [SavvyCal docs](https://docs.savvycal.com/developers/webhooks#securing-webhooks) |
| Scheme | `HMAC-SHA256` | [SavvyCal docs](https://docs.savvycal.com/developers/webhooks#securing-webhooks) |
| Signed material | `{raw body}` The request body exactly as sent, with no timestamp or webhook id. | [SavvyCal docs](https://docs.savvycal.com/developers/webhooks#securing-webhooks) |
| What to build | `Recompute the hex HMAC-SHA256 of the raw body, remove the sha256= prefix from the header and compare case-insensitively.` | [SavvyCal docs](https://docs.savvycal.com/developers/webhooks#securing-webhooks) |
| Key | `shared secret` | [SavvyCal docs](https://docs.savvycal.com/developers/webhooks#securing-webhooks) |

## SavvyCal webhook secret

One secret per webhook, copied from the webhook's row in your integration settings. Keep it in an environment variable, not in source code.

- Go to Settings > Integrations and click the lock icon (Copy signing secret) next to the webhook under Webhooks.
- Each webhook has its own secret. The REST API returns it as `secret` on the webhook object.
- You can't edit a webhook's URL. The replacement webhook you create for a new URL gets a new secret.
- To rotate, choose Regenerate secret from the webhook's menu. Every request from then on uses the new secret, including retries of payloads that already failed, and you can't undo it.

Source: [SavvyCal docs](https://docs.savvycal.com/webhooks#signing-secret)

## Code

### Express

From [webhook-skills: skills/savvycal-webhooks/examples/express/src/index.js](https://github.com/hookdeck/webhook-skills/blob/556a89753e3e66e85d2a3ce50558e95b96c08571/skills/savvycal-webhooks/examples/express/src/index.js)

```javascript
// Generated with: savvycal-webhooks skill
// https://github.com/hookdeck/webhook-skills
require('dotenv').config({ quiet: true });
const express = require('express');
const crypto = require('crypto');

const app = express();

const WEBHOOK_SECRET = process.env.SAVVYCAL_WEBHOOK_SECRET;

/**
 * Verify a SavvyCal webhook signature.
 *
 * SavvyCal sends an `x-savvycal-signature` header containing the HMAC-SHA256 of
 * the raw request body, keyed with the webhook's secret. The value is
 * `sha256=<UPPERCASE hex>`, and most HMAC libraries output lowercase, so strip
 * the prefix if present and compare the hex case-insensitively.
 *
 * @param {Buffer|string} rawBody - the raw, unparsed request body
 * @param {string} header - the x-savvycal-signature header value
 * @param {string} secret - the webhook secret
 * @returns {boolean}
 */
function verifySavvyCalSignature(rawBody, header, secret) {
  if (!header || !secret) return false;

  const received = header.trim().replace(/^sha256=/i, '').toLowerCase();
  if (!/^[0-9a-f]{64}$/.test(received)) return false;

  const expected = crypto.createHmac('sha256', secret).update(rawBody).digest('hex');

  // Timing-safe comparison (both are 32 bytes once decoded)
  return crypto.timingSafeEqual(Buffer.from(received, 'hex'), Buffer.from(expected, 'hex'));
}

// SavvyCal webhook endpoint - raw body for any content type so verification
// always runs against the exact bytes that were signed
app.post('/webhooks/savvycal', express.raw({ type: '*/*' }), (req, res) => {
  const header = req.headers['x-savvycal-signature'];

  if (!header) {
    return res.status(400).send('Missing x-savvycal-signature header');
  }

  if (!Buffer.isBuffer(req.body) || !verifySavvyCalSignature(req.body, header, WEBHOOK_SECRET)) {
    console.error('Webhook signature verification failed');
    return res.status(400).send('Invalid signature');
  }

  // Signature is valid - safe to parse the event
  let event;
  try {
    event = JSON.parse(req.body.toString('utf8'));
  } catch {
    return res.status(400).send('Invalid JSON');
  }

  switch (event.type) {
    case 'event.created':
      console.log('Event scheduled:', event.id);
      // Your code: Create CRM record, send confirmation, provision resources, etc.
      break;

    case 'event.rescheduled':
      console.log('Event rescheduled:', event.id);
      // Your code: Update calendar holds, notify attendees, sync to CRM, etc.
      break;

    case 'event.canceled':
      console.log('Event canceled:', event.id);
      // Your code: Free up availability, trigger win-back flow, update CRM, etc.
      break;

    case 'event.changed':
      console.log('Event changed:', event.id);
      // Your code: Diff the change details and sync downstream systems
      break;

    case 'event.checkout.completed':
      console.log('Checkout completed:', event.id);
      // Your code: Mark the booking as paid, issue receipts, etc.
      break;

    default:
      console.log(`Unhandled event type: ${event.type}`);
  }

  // Return 2xx quickly to acknowledge receipt
  res.json({ received: true });
});

// Health check endpoint
app.get('/health', (req, res) => {
  res.json({ status: 'ok' });
});

// Export app and helper for testing
module.exports = app;
module.exports.verifySavvyCalSignature = verifySavvyCalSignature;

// Start server only when run directly (not when imported for testing)
if (require.main === module) {
  const PORT = process.env.PORT || 3000;
  app.listen(PORT, () => {
    console.log(`Server running on http://localhost:${PORT}`);
    console.log(`Webhook endpoint: POST http://localhost:${PORT}/webhooks/savvycal`);
  });
}
```

### Next.js

From [webhook-skills: skills/savvycal-webhooks/examples/nextjs/app/webhooks/savvycal/route.ts](https://github.com/hookdeck/webhook-skills/blob/556a89753e3e66e85d2a3ce50558e95b96c08571/skills/savvycal-webhooks/examples/nextjs/app/webhooks/savvycal/route.ts)

```typescript
// Generated with: savvycal-webhooks skill
// https://github.com/hookdeck/webhook-skills
import { NextRequest, NextResponse } from 'next/server';
import { verifySavvyCalSignature } from '../../../lib/savvycal';

export async function POST(request: NextRequest) {
  // Read the raw body for signature verification - do not parse JSON first
  const rawBody = await request.text();
  const header = request.headers.get('x-savvycal-signature');

  if (!header) {
    return NextResponse.json(
      { error: 'Missing x-savvycal-signature header' },
      { status: 400 }
    );
  }

  if (!verifySavvyCalSignature(rawBody, header, process.env.SAVVYCAL_WEBHOOK_SECRET)) {
    console.error('Webhook signature verification failed');
    return NextResponse.json({ error: 'Invalid signature' }, { status: 400 });
  }

  // Signature is valid - safe to parse the event
  let event: { type?: string; id?: string };
  try {
    event = JSON.parse(rawBody);
  } catch {
    return NextResponse.json({ error: 'Invalid JSON' }, { status: 400 });
  }

  switch (event.type) {
    case 'event.created':
      console.log('Event scheduled:', event.id);
      // Your code: Create CRM record, send confirmation, provision resources, etc.
      break;

    case 'event.rescheduled':
      console.log('Event rescheduled:', event.id);
      // Your code: Update calendar holds, notify attendees, sync to CRM, etc.
      break;

    case 'event.canceled':
      console.log('Event canceled:', event.id);
      // Your code: Free up availability, trigger win-back flow, update CRM, etc.
      break;

    case 'event.changed':
      console.log('Event changed:', event.id);
      // Your code: Diff the change details and sync downstream systems
      break;

    case 'event.checkout.completed':
      console.log('Checkout completed:', event.id);
      // Your code: Mark the booking as paid, issue receipts, etc.
      break;

    default:
      console.log(`Unhandled event type: ${event.type}`);
  }

  // Return 2xx quickly to acknowledge receipt
  return NextResponse.json({ received: true });
}
```

### FastAPI

From [webhook-skills: skills/savvycal-webhooks/examples/fastapi/main.py](https://github.com/hookdeck/webhook-skills/blob/556a89753e3e66e85d2a3ce50558e95b96c08571/skills/savvycal-webhooks/examples/fastapi/main.py)

```python
# Generated with: savvycal-webhooks skill
# https://github.com/hookdeck/webhook-skills
import hashlib
import hmac
import json
import os
import re

from dotenv import load_dotenv
from fastapi import FastAPI, HTTPException, Request

load_dotenv()

app = FastAPI()

WEBHOOK_SECRET = os.environ.get("SAVVYCAL_WEBHOOK_SECRET", "")

_HEX_SHA256 = re.compile(r"^[0-9a-f]{64}$")
_PREFIX = re.compile(r"^sha256=", re.IGNORECASE)


def verify_savvycal_signature(
    raw_body: bytes, header: str | None, secret: str
) -> bool:
    """Verify a SavvyCal webhook signature.

    SavvyCal sends an ``x-savvycal-signature`` header containing the HMAC-SHA256
    of the raw request body, keyed with the webhook's secret. The value is
    ``sha256=<UPPERCASE hex>``, and most HMAC libraries output lowercase, so strip
    the prefix if present and compare the hex case-insensitively.
    """
    if not header or not secret:
        return False

    received = _PREFIX.sub("", header.strip()).lower()
    if not _HEX_SHA256.match(received):
        return False

    expected = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()

    # Timing-safe comparison
    return hmac.compare_digest(expected.encode(), received.encode())


@app.post("/webhooks/savvycal")
async def savvycal_webhook(request: Request):
    # Get the raw body for signature verification - do not parse JSON first
    raw_body = await request.body()
    header = request.headers.get("x-savvycal-signature")

    if not header:
        raise HTTPException(
            status_code=400, detail="Missing x-savvycal-signature header"
        )

    if not verify_savvycal_signature(raw_body, header, WEBHOOK_SECRET):
        raise HTTPException(status_code=400, detail="Invalid signature")

    # Signature is valid - safe to parse the event
    try:
        event = json.loads(raw_body)
    except json.JSONDecodeError:
        raise HTTPException(status_code=400, detail="Invalid JSON")

    event_type = event.get("type")
    event_id = event.get("id")

    if event_type == "event.created":
        print(f"Event scheduled: {event_id}")
        # Your code: Create CRM record, send confirmation, provision resources, etc.

    elif event_type == "event.rescheduled":
        print(f"Event rescheduled: {event_id}")
        # Your code: Update calendar holds, notify attendees, sync to CRM, etc.

    elif event_type == "event.canceled":
        print(f"Event canceled: {event_id}")
        # Your code: Free up availability, trigger win-back flow, update CRM, etc.

    elif event_type == "event.changed":
        print(f"Event changed: {event_id}")
        # Your code: Diff the change details and sync downstream systems

    elif event_type == "event.checkout.completed":
        print(f"Checkout completed: {event_id}")
        # Your code: Mark the booking as paid, issue receipts, etc.

    else:
        print(f"Unhandled event type: {event_type}")

    # Return 2xx quickly to acknowledge receipt
    return {"received": True}


@app.get("/health")
async def health():
    return {"status": "ok"}


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app, host="0.0.0.0", port=8000)
```

Or install the SavvyCal webhooks skill: `npx skills add hookdeck/webhook-skills --skill savvycal-webhooks`

## Common failures

- **Body parsed before verification.** The signature covers the raw request body. Verify the bytes as received, then parse the JSON.
- **Case or prefix mismatch.** The header is `sha256=` plus uppercase hex, and most HMAC libraries output lowercase. Remove the prefix and compare the hex case-insensitively.
- **Wrong webhook's secret.** Each webhook has its own secret. Changing a URL means creating a new webhook, which gets a new secret, so check you're using the one for this webhook.
- **Secret regenerated.** Every request after a regeneration is signed with the new secret, including retries of payloads that had already failed, and there's no grace period for the old one.

From [Hookdeck's SavvyCal guide](https://hookdeck.com/webhooks/savvycal/guide-duplicates-ordering-retries-timeouts).

---

Not affiliated with SavvyCal. Facts are compiled from public sources and linked inline. [View as JSON](https://hookdeck.com/webhooks/savvycal.json) · [Report a correction](https://hookdeck.com/contact)
