Webhooks Setup Guide
Learn how to set up webhooks to receive real-time notifications when audit events are logged.
Overview
Webhooks are HTTP callbacks that notify your application when events occur. Common use cases include:
- Sending alerts for suspicious activity
- Syncing events to your SIEM
- Triggering automated workflows
- Building real-time dashboards
Step 1: Create Your Endpoint
First, create an HTTPS endpoint that can receive POST requests. Here's a simple example with Express.js:
JavaScript
1const express = require('express');2const crypto = require('crypto');34const app = express();5app.use(express.json());67const WEBHOOK_SECRET = process.env.LOGVAULT_WEBHOOK_SECRET;89app.post('/webhooks/logvault', (req, res) => {10 // 1. Verify the signature11 const signature = req.headers['x-logvault-signature'];12 const payload = JSON.stringify(req.body);1314 const expectedSig = 'sha256=' + crypto15 .createHmac('sha256', WEBHOOK_SECRET)16 .update(payload)17 .digest('hex');1819 if (signature !== expectedSig) {20 return res.status(401).send('Invalid signature');21 }2223 // 2. Process the event24 const { event } = req.body;25 console.log('Received event:', event.action, event.actor_id);2627 // 3. Return 200 quickly28 res.status(200).send('OK');2930 // 4. Do async processing after responding31 processEventAsync(event);32});3334app.listen(3000);
Step 2: Configure in Dashboard
- Go to Settings โ Webhooks in your LogVault dashboard
- Click Add Webhook
- Enter your endpoint URL (must be HTTPS)
- Copy the Webhook Secret - you'll need this to verify signatures
- Configure filters (optional)
- Click Save
Step 3: Configure Filters
You probably don't want to receive every single event. Use filters to only get what you need:
JSON
1{2 "filters": {3 "actions": [4 "user.login_failed",5 "payment.*",6 "admin.*"7 ],8 "actor_types": ["user", "admin"]9 }10}
Filter Examples
| Use Case | Filter |
|---|---|
| Security alerts | ["*.failed", "*.deleted", "admin.*"] |
| Payment events | ["payment.*", "subscription.*"] |
| User activity | ["user.*"] |
Step 4: Test Your Webhook
Use the Test button in the dashboard to send a test event to your endpoint. The test payload looks like:
JSON
1{2 "id": "wh_delivery_test_123",3 "event_id": "evt_test_123",4 "timestamp": "2025-11-28T12:00:00Z",5 "test": true,6 "event": {7 "id": "evt_test_123",8 "action": "test.webhook",9 "actor_id": "system",10 "timestamp": "2025-11-28T12:00:00Z"11 }12}
Handling Failures
If your endpoint returns an error, LogVault retries with exponential backoff. To avoid failures:
- Return 200 immediately - Don't do heavy processing before responding
- Use a queue - Push events to a message queue for async processing
- Handle duplicates - Use the delivery ID to deduplicate
- Set up monitoring - Alert on webhook failures
Example: Slack Alert
Here's a complete example that sends Slack alerts for failed login attempts:
JavaScript
1const express = require('express');2const crypto = require('crypto');34const app = express();5app.use(express.json());67const WEBHOOK_SECRET = process.env.LOGVAULT_WEBHOOK_SECRET;8const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;910function verifySignature(payload, signature) {11 const expected = 'sha256=' + crypto12 .createHmac('sha256', WEBHOOK_SECRET)13 .update(payload)14 .digest('hex');15 return crypto.timingSafeEqual(16 Buffer.from(signature),17 Buffer.from(expected)18 );19}2021async function sendSlackAlert(event) {22 await fetch(SLACK_WEBHOOK_URL, {23 method: 'POST',24 headers: { 'Content-Type': 'application/json' },25 body: JSON.stringify({26 text: `๐จ Failed login attempt\n*User:* ${event.actor_id}\n*IP:* ${event.metadata?.ip_address || 'Unknown'}\n*Time:* ${event.timestamp}`27 })28 });29}3031app.post('/webhooks/logvault', async (req, res) => {32 const signature = req.headers['x-logvault-signature'];33 const payload = JSON.stringify(req.body);3435 if (!verifySignature(payload, signature)) {36 return res.status(401).send('Invalid signature');37 }3839 res.status(200).send('OK');4041 const { event } = req.body;42 if (event.action === 'user.login_failed') {43 await sendSlackAlert(event);44 }45});4647app.listen(3000);
Next Steps
- Webhooks API Reference - Full API documentation
- Customer Audit UI - Build a customer-facing audit log viewer