# Verify VGS (Very Good Security) webhooks

VGS signs each notification with a `vgs-signature` header, so you can confirm it came from VGS and that the body wasn't changed. The header holds a timestamp `t` and a signature `v0`, a hex HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the secret VGS generates for each webhook integration. VGS publishes a Python sample of the check rather than an SDK.

These pages cover the notifications VGS sends you. To pass another service's webhook through a VGS proxy route so that sensitive values are redacted, see [VGS's webhook example](https://docs.verygoodsecurity.com/vault/example-integrations/webhooks).

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

> Independent reference generated from hookdeck/webhook-registry (commit ff7f882, 20 Nov 2026). [VGS (Very Good Security)'s official docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures).

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

## The facts

| Fact | Value | Source |
|---|---|---|
| Signature header | `vgs-signature` Format: t=<unix seconds>,v0=<hex> | [VGS (Very Good Security) docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures) |
| Scheme | `HMAC-SHA256` **Docs discrepancy:** VGS's prose calls the signature a sha256 hash of the raw request body, but its Python sample computes an HMAC-SHA256 over `t`, a dot and the body. Follow the sample. ([docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures)) | [VGS (Very Good Security) docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures) |
| Signed material | `{t}.{raw body}` t from the vgs-signature header, a literal dot, then the body as sent. The version tag is v0, not v1. | [VGS (Very Good Security) docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures) |
| Send timestamp | `vgs-signature` Reject deliveries older than 1 minutes. | [VGS (Very Good Security) docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures) |
| What to build | `Recompute HMAC-SHA256 over the header's 't', a dot and the raw body, then compare the hex with 'v0'.` | [VGS (Very Good Security) docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures) |
| Key | `shared secret` | [VGS (Very Good Security) docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures) |

## VGS (Very Good Security) webhook secret

VGS generates one secret per webhook integration. The docs don't say where it's displayed. Keep it in an environment variable, not in source code.

- VGS generates a unique secret for every webhook integration, so each endpoint has its own.
- VGS's sample uses it as a UTF-8 string: `secret.encode("utf-8")`.
- The docs don't say where it's displayed, how to rotate it, or whether sandbox and live sources differ.

Source: [VGS (Very Good Security) docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#managing-webhooks)

## Code

> **Docs discrepancy. Read before the code.** VGS's prose calls the signature a sha256 hash of the raw request body, but its Python sample computes an HMAC-SHA256 over `t`, a dot and the body. Follow the sample. [Docs](https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications#webhook-signatures)

### Express

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

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

const express = require('express');
const crypto = require('crypto');
require('dotenv').config({ quiet: true });

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

// VGS signs every notification with the vgs-signature header:
//   vgs-signature: t=<unix seconds>,v0=<hex>
// v0 is HMAC-SHA256 of "<t>.<raw body>" keyed with the integration secret (UTF-8).
// https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications

// Optional freshness window in seconds. Off by default (0): VGS retries and Hookdeck
// retries/replays carry the original timestamp, so a window would reject late redeliveries.
// Set VGS_TIMESTAMP_TOLERANCE_SECONDS to a positive whole number to opt in; any other value is
// treated as 0, with a warning.
let warnedInvalidTolerance = false;
function timestampToleranceSeconds() {
  const raw = (process.env.VGS_TIMESTAMP_TOLERANCE_SECONDS ?? '').trim();
  if (raw === '') return 0;
  if (!/^\d+$/.test(raw)) {
    if (!warnedInvalidTolerance) {
      console.warn(`VGS_TIMESTAMP_TOLERANCE_SECONDS=${JSON.stringify(raw)} is not a whole number of seconds; the timestamp check is off`);
      warnedInvalidTolerance = true;
    }
    return 0;
  }
  return Number(raw);
}
timestampToleranceSeconds(); // surface an invalid value at startup

function safeEqual(a, b) {
  const x = Buffer.from(a);
  const y = Buffer.from(b);
  return x.length === y.length && crypto.timingSafeEqual(x, y);
}

function parseSignatureHeader(header) {
  const parts = {};
  for (const kv of header.split(',')) {
    const i = kv.indexOf('=');
    if (i > 0) parts[kv.slice(0, i).trim()] = kv.slice(i + 1).trim();
  }
  return parts;
}

function verifyVgs(rawBody, signatureHeader, secret) {
  if (!signatureHeader || !secret) return false;

  const { t, v0 } = parseSignatureHeader(signatureHeader);
  if (!t || !v0) return false;

  const ts = Number(t);
  if (!Number.isInteger(ts)) return false;
  // VGS's own example uses 60s. It's opt-in here: off unless VGS_TIMESTAMP_TOLERANCE_SECONDS > 0.
  const tolerance = timestampToleranceSeconds();
  if (tolerance > 0 && Math.abs(Math.floor(Date.now() / 1000) - ts) > tolerance) {
    return false;
  }

  const expected = crypto
    .createHmac('sha256', secret)
    .update(`${t}.`)
    .update(rawBody)
    .digest('hex');
  return safeEqual(v0, expected);
}

// Raw body is required: the signature covers the exact bytes VGS sent, whatever the content type
app.post('/webhooks/vgs', express.raw({ type: '*/*' }), (req, res) => {
  const secret = process.env.VGS_WEBHOOK_SECRET;
  if (!secret) {
    console.error('VGS_WEBHOOK_SECRET is not set');
    return res.status(500).send('Webhook secret not configured');
  }

  const rawBody = Buffer.isBuffer(req.body) ? req.body : Buffer.alloc(0);
  if (!verifyVgs(rawBody, req.headers['vgs-signature'], secret)) {
    console.error('VGS webhook signature verification failed');
    return res.status(400).send('Invalid signature');
  }

  let payload;
  try {
    payload = JSON.parse(rawBody.toString('utf8'));
  } catch {
    return res.status(400).send('Invalid JSON');
  }

  // The event type is the top-level "event" field (there is no event header)
  const event = payload.event;
  const details = payload.details || {};

  switch (event) {
    case 'route.created':
    case 'route.updated':
    case 'route.delete':
      console.log(`Route ${details.route_name} (${details.route_id}): ${event}`);
      break;
    case 'vault.created':
      console.log(`Vault created: ${details.vault_name} (${details.vault_id})`);
      break;
    case 'user.permissions_updated':
    case 'user.permissions_deleted':
      console.log(`Permissions changed for ${details.user_email}: ${event}`);
      break;
    case 'user.logged_in':
    case 'user.password_updated':
    case 'user.mfa_created':
    case 'user.mfa_deleted':
      console.log(`User ${details.user_email} from ${details.user_ip}: ${event}`);
      break;
    case 'proxy.upstream_error':
      console.log(`Upstream error from ${details.upstream_host} (occurrence ${payload.occurrence})`);
      break;
    case 'alias.reveal_failed':
      console.log(`Alias reveal failed (occurrence ${payload.occurrence})`);
      break;
    default:
      console.log(`Unhandled event: ${event}`);
  }

  res.json({ received: true });
});

if (require.main === module) {
  app.listen(PORT, () => {
    console.log(`VGS webhook server listening on http://localhost:${PORT}`);
  });
}

module.exports = { app, verifyVgs };
```

### Next.js

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

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

import { NextRequest, NextResponse } from 'next/server';
import crypto from 'crypto';

// VGS signs every notification with the vgs-signature header:
//   vgs-signature: t=<unix seconds>,v0=<hex>
// v0 is HMAC-SHA256 of "<t>.<raw body>" keyed with the integration secret (UTF-8).
// https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications

// Optional freshness window in seconds. Off by default (0): VGS retries and Hookdeck
// retries/replays carry the original timestamp, so a window would reject late redeliveries.
// Set VGS_TIMESTAMP_TOLERANCE_SECONDS to a positive whole number to opt in; any other value is
// treated as 0, with a warning.
let warnedInvalidTolerance = false;
function timestampToleranceSeconds(): number {
  const raw = (process.env.VGS_TIMESTAMP_TOLERANCE_SECONDS ?? '').trim();
  if (raw === '') return 0;
  if (!/^\d+$/.test(raw)) {
    if (!warnedInvalidTolerance) {
      console.warn(`VGS_TIMESTAMP_TOLERANCE_SECONDS=${JSON.stringify(raw)} is not a whole number of seconds; the timestamp check is off`);
      warnedInvalidTolerance = true;
    }
    return 0;
  }
  return Number(raw);
}
timestampToleranceSeconds(); // surface an invalid value at startup

function safeEqual(a: string, b: string): boolean {
  const x = Buffer.from(a);
  const y = Buffer.from(b);
  return x.length === y.length && crypto.timingSafeEqual(x, y);
}

function parseSignatureHeader(header: string): Record<string, string> {
  const parts: Record<string, string> = {};
  for (const kv of header.split(',')) {
    const i = kv.indexOf('=');
    if (i > 0) parts[kv.slice(0, i).trim()] = kv.slice(i + 1).trim();
  }
  return parts;
}

function verifyVgs(rawBody: string, signatureHeader: string | null, secret: string): boolean {
  if (!signatureHeader || !secret) return false;

  const { t, v0 } = parseSignatureHeader(signatureHeader);
  if (!t || !v0) return false;

  const ts = Number(t);
  if (!Number.isInteger(ts)) return false;
  // VGS's own example uses 60s. It's opt-in here: off unless VGS_TIMESTAMP_TOLERANCE_SECONDS > 0.
  const tolerance = timestampToleranceSeconds();
  if (tolerance > 0 && Math.abs(Math.floor(Date.now() / 1000) - ts) > tolerance) {
    return false;
  }

  const expected = crypto
    .createHmac('sha256', secret)
    .update(`${t}.${rawBody}`)
    .digest('hex');
  return safeEqual(v0, expected);
}

export async function POST(request: NextRequest) {
  const secret = process.env.VGS_WEBHOOK_SECRET;
  if (!secret) {
    console.error('VGS_WEBHOOK_SECRET is not set');
    return NextResponse.json({ error: 'Webhook secret not configured' }, { status: 500 });
  }

  // Raw body: read as text before any JSON parsing
  const rawBody = await request.text();

  if (!verifyVgs(rawBody, request.headers.get('vgs-signature'), secret)) {
    console.error('VGS webhook signature verification failed');
    return NextResponse.json({ error: 'Invalid signature' }, { status: 400 });
  }

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

  // The event type is the top-level "event" field (there is no event header)
  const event = payload.event;
  const details = payload.details || {};

  switch (event) {
    case 'route.created':
    case 'route.updated':
    case 'route.delete':
      console.log(`Route ${details.route_name} (${details.route_id}): ${event}`);
      break;
    case 'vault.created':
      console.log(`Vault created: ${details.vault_name} (${details.vault_id})`);
      break;
    case 'user.permissions_updated':
    case 'user.permissions_deleted':
      console.log(`Permissions changed for ${details.user_email}: ${event}`);
      break;
    case 'user.logged_in':
    case 'user.password_updated':
    case 'user.mfa_created':
    case 'user.mfa_deleted':
      console.log(`User ${details.user_email} from ${details.user_ip}: ${event}`);
      break;
    case 'proxy.upstream_error':
      console.log(`Upstream error from ${details.upstream_host} (occurrence ${payload.occurrence})`);
      break;
    case 'alias.reveal_failed':
      console.log(`Alias reveal failed (occurrence ${payload.occurrence})`);
      break;
    default:
      console.log(`Unhandled event: ${event}`);
  }

  return NextResponse.json({ received: true });
}
```

### FastAPI

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

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

import hashlib
import hmac
import json
import logging
import os
import time

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

load_dotenv()

logger = logging.getLogger("vgs-webhooks")
app = FastAPI()

# VGS signs every notification with the vgs-signature header:
#   vgs-signature: t=<unix seconds>,v0=<hex>
# v0 is HMAC-SHA256 of "<t>.<raw body>" keyed with the integration secret (UTF-8).
# https://docs.verygoodsecurity.com/enterprise-platform/developer-resources/webhook-notifications

# Optional freshness window in seconds. Off by default (0): VGS retries and Hookdeck
# retries/replays carry the original timestamp, so a window would reject late redeliveries.
# Set VGS_TIMESTAMP_TOLERANCE_SECONDS to a positive whole number to opt in; any other value is
# treated as 0, with a warning.
_warned_invalid_tolerance = False


def timestamp_tolerance_seconds() -> int:
    global _warned_invalid_tolerance
    raw = (os.getenv("VGS_TIMESTAMP_TOLERANCE_SECONDS") or "").strip()
    if not raw:
        return 0
    if not (raw.isascii() and raw.isdigit()):
        if not _warned_invalid_tolerance:
            logging.getLogger(__name__).warning(
                "VGS_TIMESTAMP_TOLERANCE_SECONDS=%r is not a whole number of seconds; the timestamp check is off",
                raw,
            )
            _warned_invalid_tolerance = True
        return 0
    return int(raw)


timestamp_tolerance_seconds()  # surface an invalid value at startup


def parse_signature_header(header: str) -> dict:
    parts = {}
    for kv in header.split(","):
        key, sep, value = kv.partition("=")
        if sep and key.strip():
            parts[key.strip()] = value.strip()
    return parts


def verify_vgs(raw_body: bytes, signature_header: str | None, secret: str) -> bool:
    if not signature_header or not secret:
        return False

    parts = parse_signature_header(signature_header)
    t, v0 = parts.get("t"), parts.get("v0")
    if not t or not v0:
        return False
    try:
        ts = int(t)
    except ValueError:
        return False
    # VGS's own example uses 60s. It's opt-in here: off unless VGS_TIMESTAMP_TOLERANCE_SECONDS > 0.
    tolerance = timestamp_tolerance_seconds()
    if tolerance > 0 and abs(time.time() - ts) > tolerance:
        return False

    expected = hmac.new(secret.encode("utf-8"), t.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(v0.encode(), expected.encode())


async def verified_body(request: Request) -> bytes:
    """Dependency: read the raw body and verify it before any JSON parsing."""
    secret = os.getenv("VGS_WEBHOOK_SECRET", "")
    if not secret:
        logger.error("VGS_WEBHOOK_SECRET is not set")
        raise HTTPException(status_code=500, detail="Webhook secret not configured")

    raw_body = await request.body()
    if not verify_vgs(raw_body, request.headers.get("vgs-signature"), secret):
        logger.error("VGS webhook signature verification failed")
        raise HTTPException(status_code=400, detail="Invalid signature")
    return raw_body


@app.post("/webhooks/vgs")
async def vgs_webhook(raw_body: bytes = Depends(verified_body)):
    try:
        payload = json.loads(raw_body)
    except json.JSONDecodeError:
        raise HTTPException(status_code=400, detail="Invalid JSON")
    if not isinstance(payload, dict):
        raise HTTPException(status_code=400, detail="Invalid payload")

    # The event type is the top-level "event" field (there is no event header)
    event = payload.get("event")
    details = payload.get("details") or {}

    if event in ("route.created", "route.updated", "route.delete"):
        logger.info("Route %s (%s): %s", details.get("route_name"), details.get("route_id"), event)
    elif event == "vault.created":
        logger.info("Vault created: %s (%s)", details.get("vault_name"), details.get("vault_id"))
    elif event in ("user.permissions_updated", "user.permissions_deleted"):
        logger.info("Permissions changed for %s: %s", details.get("user_email"), event)
    elif event in ("user.logged_in", "user.password_updated", "user.mfa_created", "user.mfa_deleted"):
        logger.info("User %s from %s: %s", details.get("user_email"), details.get("user_ip"), event)
    elif event == "proxy.upstream_error":
        logger.info("Upstream error from %s (occurrence %s)", details.get("upstream_host"), payload.get("occurrence"))
    elif event == "alias.reveal_failed":
        logger.info("Alias reveal failed (occurrence %s)", payload.get("occurrence"))
    else:
        logger.info("Unhandled event: %s", event)

    return {"received": True}


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

Or install the VGS (Very Good Security) webhooks skill: `npx skills add hookdeck/webhook-skills --skill vgs-webhooks`

## Common failures

- **Signing only the body.** VGS's prose says the signature is a sha256 hash of the raw body. Its sample signs `t`, a dot and the body with HMAC-SHA256, so a digest of the body alone never matches.
- **A timestamp check on a retry.** Retries keep the original `t`, so the sample's 60-second check rejects them even though the signature is valid.
- **Body parsed before verification.** The signature covers the exact bytes VGS sent. Read the raw body before anything parses or re-serialises it.
- **Wrong secret.** Each webhook integration has its own secret, so a secret from another integration fails even in the same organisation.

From [Hookdeck's VGS (Very Good Security) guide](https://hookdeck.com/webhooks/vgs/guide-duplicates-ordering-retries-timeouts).

---

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