Skip to main content
Webhooks let your application receive real-time notifications when PromptGuard detects security events — threats blocked, PII redacted, usage thresholds crossed, and more.

Overview

When you configure a webhook for a project, PromptGuard sends HTTP POST requests to your endpoint whenever specific security events occur. This lets you:
  • Log security events to your own systems
  • Trigger alerts in Slack, PagerDuty, or other tools
  • Build custom dashboards and analytics
  • Audit AI interactions in real-time

Setup

Via Dashboard

  1. Go to app.promptguard.co
  2. Select your project
  3. Navigate to Settings or Project Overview
  4. Enter your Webhook URL
  5. Save

Delivery Monitoring

Track webhook delivery status in the dashboard:
  1. Navigate to your project → Webhooks
  2. View delivery history with status, attempts, and errors
  3. Manually retry failed deliveries
The delivery status page shows:
  • Status: Pending, delivered, or failed
  • Attempts: Number of delivery attempts (auto-retries with exponential backoff)
  • Response Status: HTTP status code from your endpoint
  • Error Details: Last error message for failed deliveries

Via API

Event Types

Payload Format

All webhook events follow this structure:

Threat Blocked

PII Redacted

Usage Threshold

Handling Webhooks

Example Server (Node.js)

Example Server (Python)

Payload Authenticity

Alert webhook payloads are not signed today. There is no per-project webhook secret, PromptGuard sends no X-PromptGuard-Signature header on these deliveries, and there is nothing for your endpoint to verify. Treat the payload as unauthenticated input.
Until signing ships, protect the endpoint at the network or URL layer instead:
  • Restrict the endpoint to PromptGuard’s egress addresses at your firewall or load balancer, or put it behind a private network.
  • Give the endpoint an unguessable path (for example /webhooks/promptguard/<random-token>) and treat that path as a shared secret — rotate it if it leaks.
  • Do not act on webhook contents as if authenticated. Use the event_id to look the event up through the API before taking any consequential action.

Best Practices

  1. Respond quickly — Return a 200 status within 5 seconds. Process events asynchronously if needed.
  2. Handle duplicates — Use event_id to deduplicate events in case of retries.
  3. Do not trust the payload — Alert webhook deliveries are unsigned. Restrict the endpoint by network or by an unguessable path, and re-read anything consequential from the API using event_id.
  4. Use HTTPS — Always use HTTPS endpoints for webhook delivery.
  5. Log everything — Store raw webhook payloads for debugging and audit trails.
  6. Monitor failures — Track webhook delivery failures in your monitoring system.

Retry Policy

If your endpoint returns a non-2xx status code or times out, PromptGuard will retry delivery: After 3 failed retries (4 total attempts), the delivery is marked as failed. Check your dashboard for delivery failures. Failed deliveries are tracked in the webhook_deliveries table with error details.

Custom Policy Webhooks

In addition to receiving event notifications, you can use webhooks as custom policy hooks in the PromptGuard guard pipeline. This lets you run your own verdict logic on every scan without modifying the detection engine. When a custom policy webhook is configured, PromptGuard calls your endpoint during the scan pipeline and uses your response to decide whether to allow, block, or redact the content.

How It Works

  1. PromptGuard runs its built-in threat detectors on the content.
  2. Before returning a final decision, it sends a POST request to your custom policy webhook with the scan context and any threats already detected.
  3. Your endpoint evaluates the content and returns a verdict.
  4. PromptGuard incorporates your verdict into the final decision.

Request Format

Your endpoint receives a POST request with this JSON body:

Response Format

Your endpoint must return a JSON response:

Example: Custom Compliance Server

Failure Behavior

Custom policy webhooks have a 3-second timeout by default. If your endpoint is unreachable or returns an error:
  • Fail open (default): The request is allowed through. The webhook error is logged but does not block the user.
  • Fail closed: The request is blocked. Enable this for high-security environments where you require your custom policy to run on every request.
Configure the failure mode in your project settings or via the API.

Best Practices for Policy Webhooks

  1. Keep it fast — Your endpoint is in the hot path of every scan. Aim for sub-100ms response times.
  2. Return valid verdicts — Only "allow", "block", and "redact" are accepted. Invalid values default to "allow".
  3. Use fail-closed sparingly — Only enable fail-closed mode when your policy check is mandatory for compliance.
  4. Log decisions — Record your webhook’s verdicts for auditing and debugging.
  5. Handle all fields — Your endpoint should gracefully handle any combination of threat types in threats_detected.

Next Steps

Monitoring Dashboard

View security events and analytics

Usage Tracking

Monitor your API usage