Verify Auvik webhooks
Auvik's webhook integration has no signature, so nothing proves a body is unchanged. Choose its Header authentication method and Auvik sends a Key and Value you pick on each request, which your receiver compares with its stored value to confirm the sender knows the secret. Auvik's docs name no SDK.
The facts
Auvik webhook secret
You choose both parts and enter them on the integration's Header authentication method. Auvik doesn't generate a secret. Keep it in an environment variable, not in source code.
-
Keyis the header name andValueis the secret, both typed into the integration. - The whole Value is what you compare, so a
Bearerprefix typed into it is part of the secret. - Each integration has its own Key and Value, and alerts for a different URL need a different integration.
- Auvik documents no rotation flow. Change the Value on the integration and in your receiver together.
Source: Auvik docs ↗
Code
// Generated with: auvik-webhooks skill
// https://github.com/hookdeck/webhook-skills
require('dotenv').config({ quiet: true });
const crypto = require('crypto');
const express = require('express');
const app = express();
/**
* Constant-time string comparison. Hashing both sides first gives equal-length
* buffers, so timingSafeEqual never throws and the secret's length isn't leaked.
*/
function safeEqual(a, b) {
const ha = crypto.createHash('sha256').update(String(a)).digest();
const hb = crypto.createHash('sha256').update(String(b)).digest();
return crypto.timingSafeEqual(ha, hb);
}
/**
* Auvik does not sign payloads. With Header authentication it sends the custom
* header (Key and Value) you configured. Node lowercases header names, so the
* lookup is case-insensitive. The WHOLE value is compared: no "Bearer " parsing.
* This authenticates the sender only; it gives no body integrity or replay protection.
*/
function verifyAuvikRequest(
headers,
headerName = process.env.AUVIK_WEBHOOK_HEADER || 'Authorization',
secret = process.env.AUVIK_WEBHOOK_SECRET
) {
if (!secret) return false; // never accept when unconfigured
const received = headers[headerName.toLowerCase()];
return typeof received === 'string' && received !== '' && safeEqual(received, secret);
}
function handleAlert(payload) {
const { alertStatusString, alertName, entityName, companyName } = payload;
switch (alertStatusString) {
case 'Triggered':
console.log(`Alert triggered: ${alertName} on ${entityName} (${companyName})`);
// Your code: open an incident or ticket (payload.correlationId, payload.alertDescription, payload.link)
break;
case 'Cleared':
console.log(`Alert cleared: ${alertName} on ${entityName} (${companyName})`);
// Your code: resolve the matching incident (payload.correlationId)
break;
default:
console.log(`Unhandled alert status: ${alertStatusString}`);
}
}
// Read the body raw (any content type) so the request is authenticated before parsing.
app.post('/webhooks/auvik', express.raw({ type: '*/*' }), (req, res) => {
if (!verifyAuvikRequest(req.headers)) {
return res.status(401).json({ error: 'Invalid or missing Auvik webhook header' });
}
let payload;
try {
const raw = Buffer.isBuffer(req.body) ? req.body.toString('utf8') : '';
payload = JSON.parse(raw);
} catch {
return res.status(400).json({ error: 'Invalid JSON body' });
}
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
return res.status(400).json({ error: 'Expected a JSON object' });
}
try {
handleAlert(payload);
} catch (err) {
console.error('Error handling Auvik alert:', err);
return res.status(500).json({ error: 'Handler error' });
}
res.status(200).json({ received: true });
});
app.get('/health', (req, res) => {
res.json({ status: 'ok' });
});
module.exports = app;
module.exports.verifyAuvikRequest = verifyAuvikRequest;
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/auvik`);
});
} // Generated with: auvik-webhooks skill
// https://github.com/hookdeck/webhook-skills
import { NextRequest, NextResponse } from 'next/server';
import { verifyAuvikRequest } from '../../../lib/verify-auvik';
interface AuvikAlert {
alertId?: string;
correlationId?: string;
alertName?: string;
alertStatus?: number;
alertStatusString?: string;
alertDescription?: string;
entityName?: string;
companyName?: string;
date?: string;
link?: string;
[key: string]: unknown;
}
function handleAlert(payload: AuvikAlert): void {
const { alertStatusString, alertName, entityName, companyName } = payload;
switch (alertStatusString) {
case 'Triggered':
console.log(`Alert triggered: ${alertName} on ${entityName} (${companyName})`);
// Your code: open an incident or ticket (payload.correlationId, payload.alertDescription, payload.link)
break;
case 'Cleared':
console.log(`Alert cleared: ${alertName} on ${entityName} (${companyName})`);
// Your code: resolve the matching incident (payload.correlationId)
break;
default:
console.log(`Unhandled alert status: ${alertStatusString}`);
}
}
export async function POST(request: NextRequest) {
// Authenticate before reading or parsing the body.
if (!verifyAuvikRequest(request.headers)) {
return NextResponse.json({ error: 'Invalid or missing Auvik webhook header' }, { status: 401 });
}
let payload: unknown;
try {
// Read as text so any content type is accepted.
payload = JSON.parse(await request.text());
} catch {
return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });
}
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
return NextResponse.json({ error: 'Expected a JSON object' }, { status: 400 });
}
try {
handleAlert(payload as AuvikAlert);
} catch (err) {
console.error('Error handling Auvik alert:', err);
return NextResponse.json({ error: 'Handler error' }, { status: 500 });
}
return NextResponse.json({ received: true });
} # Generated with: auvik-webhooks skill
# https://github.com/hookdeck/webhook-skills
import hashlib
import hmac
import json
import os
from dotenv import load_dotenv
from fastapi import Depends, FastAPI, HTTPException, Request
load_dotenv()
app = FastAPI()
def safe_equal(a: str, b: str) -> bool:
"""Constant-time comparison on bytes (compare_digest on equal-length digests).
Both sides are encoded to bytes: compare_digest raises TypeError for non-ASCII str.
"""
return hmac.compare_digest(
hashlib.sha256(a.encode("utf-8")).digest(),
hashlib.sha256(b.encode("utf-8")).digest(),
)
def verify_auvik_request(headers, header_name=None, secret=None) -> bool:
"""Auvik does not sign payloads. With Header authentication it sends the custom
header (Key and Value) you configured. Starlette headers are case-insensitive.
The WHOLE value is compared: no "Bearer " parsing. This authenticates the sender
only; it gives no body integrity or replay protection.
"""
header_name = header_name or os.environ.get("AUVIK_WEBHOOK_HEADER") or "Authorization"
secret = secret if secret is not None else os.environ.get("AUVIK_WEBHOOK_SECRET")
if not secret:
return False # never accept when unconfigured
received = headers.get(header_name)
return bool(received) and safe_equal(received, secret)
async def require_auvik_header(request: Request) -> None:
"""FastAPI dependency: reject the request before the body is parsed."""
if not verify_auvik_request(request.headers):
raise HTTPException(status_code=401, detail="Invalid or missing Auvik webhook header")
def handle_alert(payload: dict) -> None:
status = payload.get("alertStatusString")
name = payload.get("alertName")
entity = payload.get("entityName")
company = payload.get("companyName")
if status == "Triggered":
print(f"Alert triggered: {name} on {entity} ({company})")
# Your code: open an incident or ticket (payload["correlationId"], payload["alertDescription"], payload["link"])
elif status == "Cleared":
print(f"Alert cleared: {name} on {entity} ({company})")
# Your code: resolve the matching incident (payload["correlationId"])
else:
print(f"Unhandled alert status: {status}")
@app.post("/webhooks/auvik", dependencies=[Depends(require_auvik_header)])
async def auvik_webhook(request: Request):
# Read the raw body so any content type is accepted.
raw_body = await request.body()
try:
payload = json.loads(raw_body)
except (json.JSONDecodeError, UnicodeDecodeError):
raise HTTPException(status_code=400, detail="Invalid JSON body")
if not isinstance(payload, dict):
raise HTTPException(status_code=400, detail="Expected a JSON object")
try:
handle_alert(payload)
except Exception as err: # noqa: BLE001
print(f"Error handling Auvik alert: {err}")
raise HTTPException(status_code=500, detail="Handler error")
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 Auvik webhooks skill:
npx skills add hookdeck/webhook-skills --skill auvik-webhooks
Common failures
The integration uses another authentication method
With No Authentication, Basic Authentication or OAuth 2.0, your custom header isn't sent unless you also added it under Additional HTTP headers. Choose Header and enter the Key and Value there.
A prefix was left out of the comparison
The whole Value is what Auvik was given. If you typed Bearer abc, compare against Bearer abc, not abc.
The header name doesn't match the Key
The Key can be any header name, so read it from your configuration, and look it up case-insensitively.
The value was rotated on one side
Auvik documents no rotation flow or overlap. Change the Value on the integration and in your receiver together.
Let Event Gateway check your Auvik header.
Choose Header authentication on the Auvik integration and enter the same Key and Value on a Hookdeck source with the Auvik type. Event Gateway checks the header on each delivery before it reaches your service, then queues it and retries failures on your schedule. It answers with a 200 either way, so confirm the key by checking that the request shows as verified, not by a passing Test Connection.