Guardian API
Webhooks

Webhooks

Configure webhook notifications for real-time vault events.

Overview

Guardian can send HTTP POST requests to your webhook endpoint when events occur, enabling real-time notifications and integrations.

Supported Events

EventDescriptionPayload
transaction.executedTransaction successfulTransaction details
transaction.blockedTransaction blocked by policyBlock reason + Blink URL
override.createdOverride request createdOverride details
override.approvedOverride approved by ownerApproval confirmation
vault.pausedVault pausedVault address
vault.resumedVault resumedVault address
policy.updatedVault policy changedNew policy values

Webhook Registration

Create Webhook Subscription

curl -X POST https://aegis-guardian-production.up.railway.app/api/webhooks \
  -H "Content-Type: application/json" \
  -H "X-Wallet-Address: YOUR_PUBKEY" \
  -H "X-Signature: SIGNATURE" \
  -H "X-Message: MESSAGE" \
  -d '{
    "url": "https://your-server.com/webhooks/aegis",
    "events": ["transaction.blocked", "override.created"],
    "vault": "VAULT_ADDRESS"
  }'

Webhook Payload Example

{
  "event": "transaction.blocked",
  "timestamp": "2025-12-03T00:00:00.000Z",
  "data": {
    "vault": "7xKX...",
    "destination": "recipient_pubkey",
    "amount": "50000000",
    "blockReason": "not_whitelisted",
    "blinkUrl": "https://aegis-guardian-production.up.railway.app/api/actions/7xKX.../0"
  },
  "signature": "hmac_sha256_signature"
}

Verifying Webhooks

Verify HMAC signature to ensure webhooks are authentic:

import crypto from 'crypto';
 
function verifyWebhook(
  payload: string,
  signature: string,
  secret: string
): boolean {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
 
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}
 
// Express webhook handler
app.post('/webhooks/aegis', (req, res) => {
  const signature = req.headers['x-aegis-signature'] as string;
  const payload = JSON.stringify(req.body);
 
  if (!verifyWebhook(payload, signature, process.env.WEBHOOK_SECRET!)) {
    return res.status(401).json({ error: 'Invalid signature' });
  }
 
  // Process webhook
  console.log('Event:', req.body.event);
  console.log('Data:', req.body.data);
 
  res.json({ received: true });
});

Next Steps