Skip to main content
Webhooks send HTTP POST requests to your endpoints when specific events occur in Raven. Use them to trigger alerts, sync data to external systems, or build custom automation workflows.

Creating a Webhook

1

Navigate to Webhooks

Go to Webhooks in the dashboard sidebar.
2

Click Create Webhook

Enter the endpoint URL where you want to receive events.
3

Select Events

Choose which event types to subscribe to.
4

Copy the Secret

Save the webhook secret for signature verification. This is only shown once.

Event Types

Subscribe to any combination of events across the system.

Request Events

EventDescription
request.startedA request began processing
request.completedA request was successfully completed
request.failedA request failed
request.cachedA request was served from cache
request.fallbackA request used a fallback provider

Guardrail Events

EventDescription
guardrail.triggeredA guardrail rule matched content
guardrail.blockedA request was blocked by a guardrail
guardrail.warnedA guardrail issued a warning

Budget Events

EventDescription
budget.threshold.reachedA budget reached its alert threshold
budget.exceededA budget limit was exceeded
budget.resetA budget was reset for a new period

Key Events

EventDescription
key.createdA virtual key was created
key.revokedA virtual key was revoked
key.rate_limitedA key hit its rate limit
key.expiredA virtual key expired

Provider Events

EventDescription
provider.health.degradedA provider’s health degraded
provider.health.recoveredA provider recovered from degraded health
provider.outage.detectedA provider outage was detected

Webhook Payload

Each webhook delivers a JSON payload with the event details:
{
  "webhookId": "wh_abc123",
  "event": "budget.threshold.reached",
  "timestamp": "2026-03-15T10:30:00Z",
  "data": {
    "budgetId": "bud_xyz789",
    "budgetName": "Production API",
    "currentSpend": 450.00,
    "limit": 500.00,
    "percentage": 90
  }
}

Signature Verification

Every webhook request includes an X-Raven-Signature header containing an HMAC-SHA256 signature. Verify it to ensure the webhook came from Raven.
import crypto from "node:crypto";

function verifyWebhook(payload: string, signature: string, secret: string): boolean {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(payload)
    .digest("hex");
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

// In your webhook handler
app.post("/webhooks/raven", (req, res) => {
  const signature = req.headers["x-raven-signature"];
  const isValid = verifyWebhook(JSON.stringify(req.body), signature, WEBHOOK_SECRET);

  if (!isValid) {
    return res.status(401).send("Invalid signature");
  }

  // Process the event
  console.log("Event:", req.body.event);
  res.status(200).send("OK");
});
Always verify webhook signatures before processing events. Without verification, an attacker could send fake events to your endpoint.

Retry Logic

Failed webhook deliveries are retried with exponential backoff:
AttemptDelay
1Immediate
21 second
32 seconds
44 seconds
After 4 retries (3 retries + the initial attempt), the delivery is abandoned and logged as failed. Each attempt has a 10-second timeout.

Testing Webhooks

Use the dashboard to send test events to your webhook endpoint:
  1. Navigate to the webhook in the dashboard
  2. Click Send Test Event
  3. Select the event type to simulate
  4. Check your endpoint for the test payload