Webhooks

Configure webhook endpoints to receive real-time event notifications from the gateway.

About

Prism can send real-time HTTP notifications to your endpoints when gateway events occur, such as completed requests, triggered guardrails, exceeded budgets, and errors. Use webhooks to build integrations, trigger alerts, or log events in your own systems.


When to use

  • Alerting: Get notified immediately when error rates spike or budgets are exceeded
  • Audit logging: Stream every request event to your own data pipeline
  • Guardrail monitoring: React when a guardrail triggers on a request
  • Cost control: Trigger actions when a budget threshold is hit

Setting up a webhook

  1. Go to Gateway > Webhooks
  2. Click + Create Webhook
  3. Fill in the form:
FieldRequiredDescription
NameYesA label for this endpoint
URLYesYour HTTPS endpoint, e.g., https://example.com/webhook
SecretOptionalHMAC secret for verifying payload signatures
DescriptionOptionalNotes about this webhook
Event SubscriptionsOptionalSelect which events to receive (see below)
  1. Click Create

Event types

EventTrigger
request.completedA gateway request finishes (success or error)
guardrail.triggeredA guardrail rule fires on a request
budget.exceededSpend crosses a configured budget limit
error.occurredA gateway-level error occurs
batch.completedA batch processing job finishes

Subscribe to only the events you need to reduce noise.


Payload verification

If you set a Secret, Prism signs each request with HMAC-SHA256 and includes the signature in the X-Prism-Signature header. Verify it on your server to confirm the payload came from Prism.

import hmac
import hashlib
from fastapi import FastAPI, Request, HTTPException

app = FastAPI()
WEBHOOK_SECRET = "your-webhook-secret"

@app.post("/webhook")
async def handle_webhook(request: Request):
    payload = await request.body()
    signature = request.headers.get("X-Prism-Signature", "")

    expected = hmac.new(
        WEBHOOK_SECRET.encode(),
        payload,
        hashlib.sha256,
    ).hexdigest()

    if not hmac.compare_digest(f"sha256={expected}", signature):
        raise HTTPException(status_code=401, detail="Invalid signature")

    data = await request.json()
    event_type = data.get("event")

    # Handle the event
    print(f"Received event: {event_type}")
    return {"status": "ok"}
import hmac
import hashlib
from flask import Flask, request, abort, jsonify

app = Flask(__name__)
WEBHOOK_SECRET = "your-webhook-secret"

@app.route("/webhook", methods=["POST"])
def handle_webhook():
    payload = request.get_data()
    signature = request.headers.get("X-Prism-Signature", "")

    expected = hmac.new(
        WEBHOOK_SECRET.encode(),
        payload,
        hashlib.sha256,
    ).hexdigest()

    if not hmac.compare_digest(f"sha256={expected}", signature):
        abort(401)

    data = request.get_json()
    event_type = data.get("event")

    # Handle the event
    print(f"Received event: {event_type}")
    return jsonify(status="ok")

Delivery log

The Delivery Log tab on the Webhooks page shows the status of every webhook delivery attempt, including timestamp, HTTP status code, and response body. Use it to debug failed deliveries and retry them manually.


Next Steps

Was this page helpful?

Questions & Discussion