# Verify PropelAuth webhooks

PropelAuth tells you to verify every webhook, so you know it came from PropelAuth and not a malicious actor, and sends you to Svix, which delivers them, for how. By default `svix-signature` holds an HMAC-SHA256 of the message id, timestamp and raw body, keyed with your endpoint's `whsec_` secret. The official Svix libraries do the check for you.

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

> Independent reference generated from hookdeck/webhook-registry (commit ff7f882, 20 Nov 2026). [PropelAuth's official docs](https://docs.propelauth.com/integrations/webhooks).

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

## The facts

| Fact | Value | Source |
|---|---|---|
| Signature header | `svix-signature` Format: v1,<base64>, space-delimited when there are several | [PropelAuth docs](https://docs.propelauth.com/integrations/webhooks) |
| Scheme | `HMAC-SHA256` | [PropelAuth docs](https://docs.propelauth.com/integrations/webhooks) |
| Signed material | `{svix-id}.{svix-timestamp}.{raw body}` The two headers and the body as sent, joined with dots. PropelAuth sends readers to Svix for this scheme. | [PropelAuth docs](https://docs.propelauth.com/integrations/webhooks) |
| Send timestamp | `svix-timestamp` | [PropelAuth docs](https://docs.propelauth.com/integrations/webhooks) |
| What to build | `Use a Svix library, or recompute the HMAC over the message id, timestamp and raw body with the base64-decoded secret, then compare with each v1 entry.` | [PropelAuth docs](https://docs.propelauth.com/integrations/webhooks) |
| Key | `shared secret` | [PropelAuth docs](https://docs.propelauth.com/integrations/webhooks) |

## PropelAuth webhook secret

Svix signs with a secret that belongs to the endpoint, so take it from the endpoint you added under Integrations > Webhooks. PropelAuth's docs don't show this secret. Keep it in an environment variable, not in source code.

- Where: Svix says to get the secret from where you added the endpoint, which for PropelAuth is the Webhooks section of the Integrations page. PropelAuth's docs don't show the screen.
- Format: Svix secrets start with `whsec_`, and a hand-written verifier uses the base64-decoded part after the prefix as the key.
- Per endpoint: test and production have separate endpoints, so keep one secret per environment.
- Rotating: PropelAuth's docs don't cover rotating a webhook secret.

Source: [PropelAuth docs](https://docs.svix.com/receiving/verifying-payloads/how-manual)

## Code

### Express

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

```javascript
// Generated with: propelauth-webhooks skill
// https://github.com/hookdeck/webhook-skills

import { pathToFileURL } from 'node:url';
import dotenv from 'dotenv';
import express from 'express';
import { Webhook } from 'svix';

dotenv.config({ quiet: true });

export const app = express();
const PORT = process.env.PORT || 3000;

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

// IMPORTANT: express.raw() with type '*/*' keeps the exact bytes PropelAuth (Svix)
// signed, whatever content type the request arrives with.
app.post('/webhooks/propelauth', express.raw({ type: '*/*' }), (req, res) => {
  const secret = process.env.PROPELAUTH_WEBHOOK_SECRET;
  if (!secret || !secret.startsWith('whsec_')) {
    console.error('PROPELAUTH_WEBHOOK_SECRET is missing or not a whsec_ secret');
    return res.status(500).json({ error: 'Server configuration error' });
  }

  const svixId = req.headers['svix-id'];
  const svixTimestamp = req.headers['svix-timestamp'];
  const svixSignature = req.headers['svix-signature'];
  if (!svixId || !svixTimestamp || !svixSignature) {
    return res.status(400).json({ error: 'Missing required webhook headers' });
  }

  try {
    // Checks HMAC-SHA256 over `${svix-id}.${svix-timestamp}.${body}` against every
    // v1, signature and enforces the 5-minute timestamp window.
    new Webhook(secret).verify(req.body, {
      'svix-id': svixId,
      'svix-timestamp': svixTimestamp,
      'svix-signature': svixSignature,
    });
  } catch (err) {
    console.error('PropelAuth webhook verification failed:', err.message);
    const error = /timestamp/i.test(err.message) ? 'Timestamp too old' : 'Invalid signature';
    return res.status(400).json({ error });
  }

  let event;
  try {
    event = JSON.parse(req.body.toString('utf8'));
  } catch {
    return res.status(400).json({ error: 'Invalid JSON' });
  }

  // PropelAuth's docs say the payload includes the event type but don't name the
  // field; read `event_type`, falling back to `type`.
  const type = event?.event_type ?? event?.type ?? null;
  // svix-id is stable across retries: use it to deduplicate
  console.log(`Received PropelAuth webhook ${svixId}: ${type}`);

  switch (type) {
    case 'user.created':
      console.log('New user signed up:', event.user_id);
      break;
    case 'user.updated':
      // Only the ID is sent so out-of-order deliveries can't overwrite newer data
      console.log('User updated, fetch the latest from the API:', event.user_id);
      break;
    case 'user.deleted':
      console.log('User deleted:', event.user_id);
      break;
    case 'org.created':
      console.log('Organization created:', event.org_id);
      break;
    case 'user.added_to_org':
      console.log('User added to org:', event.user_id, event.org_id);
      break;
    default:
      console.log('Unhandled event type:', type);
  }

  res.status(200).json({ success: true, type });
});

// Start the server only when run directly (not when imported by tests)
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
  app.listen(PORT, () => {
    console.log(`PropelAuth webhook server running on http://localhost:${PORT}/webhooks/propelauth`);
  });
}
```

### Next.js

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

```typescript
// Generated with: propelauth-webhooks skill
// https://github.com/hookdeck/webhook-skills

import { NextResponse } from 'next/server';
import { Webhook } from 'svix';
import { parsePropelAuthEvent } from '../../../lib/propelauth';

export const dynamic = 'force-dynamic';

export async function POST(request: Request) {
  const secret = process.env.PROPELAUTH_WEBHOOK_SECRET;
  if (!secret || !secret.startsWith('whsec_')) {
    console.error('PROPELAUTH_WEBHOOK_SECRET is missing or not a whsec_ secret');
    return NextResponse.json({ error: 'Server configuration error' }, { status: 500 });
  }

  const svixId = request.headers.get('svix-id');
  const svixTimestamp = request.headers.get('svix-timestamp');
  const svixSignature = request.headers.get('svix-signature');
  if (!svixId || !svixTimestamp || !svixSignature) {
    return NextResponse.json({ error: 'Missing required webhook headers' }, { status: 400 });
  }

  // Read the RAW body: verification needs the exact bytes PropelAuth (Svix) signed
  const rawBody = await request.text();

  try {
    // Checks HMAC-SHA256 over `${svix-id}.${svix-timestamp}.${body}` against every
    // v1, signature and enforces the 5-minute timestamp window.
    new Webhook(secret).verify(rawBody, {
      'svix-id': svixId,
      'svix-timestamp': svixTimestamp,
      'svix-signature': svixSignature,
    });
  } catch (err) {
    const message = err instanceof Error ? err.message : String(err);
    console.error('PropelAuth webhook verification failed:', message);
    const error = /timestamp/i.test(message) ? 'Timestamp too old' : 'Invalid signature';
    return NextResponse.json({ error }, { status: 400 });
  }

  let body: unknown;
  try {
    body = JSON.parse(rawBody);
  } catch {
    return NextResponse.json({ error: 'Invalid JSON' }, { status: 400 });
  }

  const { type, data } = parsePropelAuthEvent(body);
  // svix-id is stable across retries: use it to deduplicate
  console.log(`Received PropelAuth webhook ${svixId}: ${type}`);

  switch (type) {
    case 'user.created':
      console.log('New user signed up:', data.user_id);
      break;
    case 'user.updated':
      // Only the ID is sent so out-of-order deliveries can't overwrite newer data
      console.log('User updated, fetch the latest from the API:', data.user_id);
      break;
    case 'user.deleted':
      console.log('User deleted:', data.user_id);
      break;
    case 'org.created':
      console.log('Organization created:', data.org_id);
      break;
    case 'user.added_to_org':
      console.log('User added to org:', data.user_id, data.org_id);
      break;
    default:
      console.log('Unhandled event type:', type);
  }

  return NextResponse.json({ success: true, type });
}
```

### FastAPI

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

```python
# Generated with: propelauth-webhooks skill
# https://github.com/hookdeck/webhook-skills

import json
import os
from typing import Any, Optional

from dotenv import load_dotenv
from fastapi import FastAPI, Header, HTTPException, Request
from svix.webhooks import Webhook, WebhookVerificationError

load_dotenv()

app = FastAPI(title="PropelAuth Webhook Handler")


def parse_propelauth_event(body: Any) -> tuple[Optional[str], dict]:
    """Return (type, data).

    PropelAuth's docs say each payload includes the event type but don't name the
    field; read `event_type`, falling back to `type`.
    """
    data = body if isinstance(body, dict) else {}
    event_type = data.get("event_type") or data.get("type")
    return (event_type if isinstance(event_type, str) else None), data


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


@app.post("/webhooks/propelauth")
async def propelauth_webhook(
    request: Request,
    svix_id: Optional[str] = Header(None),
    svix_timestamp: Optional[str] = Header(None),
    svix_signature: Optional[str] = Header(None),
):
    secret = os.environ.get("PROPELAUTH_WEBHOOK_SECRET")
    if not secret or not secret.startswith("whsec_"):
        print("PROPELAUTH_WEBHOOK_SECRET is missing or not a whsec_ secret")
        raise HTTPException(status_code=500, detail="Server configuration error")

    if not (svix_id and svix_timestamp and svix_signature):
        raise HTTPException(status_code=400, detail="Missing required webhook headers")

    # Verify the RAW body: the exact bytes PropelAuth (Svix) signed
    raw_body = await request.body()
    try:
        # Checks HMAC-SHA256 over "{svix-id}.{svix-timestamp}.{body}" against every
        # v1, signature and enforces the 5-minute timestamp window.
        Webhook(secret).verify(
            raw_body,
            {
                "svix-id": svix_id,
                "svix-timestamp": svix_timestamp,
                "svix-signature": svix_signature,
            },
        )
    except WebhookVerificationError as err:
        print(f"PropelAuth webhook verification failed: {err}")
        detail = "Timestamp too old" if "timestamp" in str(err).lower() else "Invalid signature"
        raise HTTPException(status_code=400, detail=detail)

    try:
        body = json.loads(raw_body)
    except json.JSONDecodeError:
        raise HTTPException(status_code=400, detail="Invalid JSON")

    event_type, data = parse_propelauth_event(body)
    # svix-id is stable across retries: use it to deduplicate
    print(f"Received PropelAuth webhook {svix_id}: {event_type}")

    if event_type == "user.created":
        print(f"New user signed up: {data.get('user_id')}")
    elif event_type == "user.updated":
        # Only the ID is sent so out-of-order deliveries can't overwrite newer data
        print(f"User updated, fetch the latest from the API: {data.get('user_id')}")
    elif event_type == "user.deleted":
        print(f"User deleted: {data.get('user_id')}")
    elif event_type == "org.created":
        print(f"Organization created: {data.get('org_id')}")
    elif event_type == "user.added_to_org":
        print(f"User added to org: {data.get('user_id')} {data.get('org_id')}")
    else:
        print(f"Unhandled event type: {event_type}")

    return {"success": True, "type": event_type}


if __name__ == "__main__":
    import uvicorn

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

Or install the PropelAuth webhooks skill: `npx skills add hookdeck/webhook-skills --skill propelauth-webhooks`

## Common failures

- **Body parsed before verification.** Svix's signature is sensitive to the slightest change, so parsing the JSON and serialising it again breaks it. Verify against the raw request body.
- **Secret from the wrong environment.** Test and production use separate endpoints, and a secret belongs to its endpoint, so a test secret won't verify a production delivery.
- **Secret not decoded.** In a hand-written verifier, the HMAC key is the base64-decoded part of the secret after `whsec_`, not the string as shown.
- **Delivery replayed late.** The Svix libraries reject a timestamp more than five minutes from the current time, and a message replayed through a relay keeps its original timestamp. Hand-written verifiers can widen or drop that check.

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

---

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