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
- Go to app.promptguard.co
- Select your project
- Navigate to Settings or Project Overview
- Enter your Webhook URL
- Save
Delivery Monitoring
Track webhook delivery status in the dashboard:- Navigate to your project → Webhooks
- View delivery history with status, attempts, and errors
- Manually retry failed deliveries
- 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
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_idto look the event up through the API before taking any consequential action.
Best Practices
- Respond quickly — Return a
200status within 5 seconds. Process events asynchronously if needed. - Handle duplicates — Use
event_idto deduplicate events in case of retries. - 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. - Use HTTPS — Always use HTTPS endpoints for webhook delivery.
- Log everything — Store raw webhook payloads for debugging and audit trails.
- 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
- PromptGuard runs its built-in threat detectors on the content.
- Before returning a final decision, it sends a POST request to your custom policy webhook with the scan context and any threats already detected.
- Your endpoint evaluates the content and returns a verdict.
- 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.
Best Practices for Policy Webhooks
- Keep it fast — Your endpoint is in the hot path of every scan. Aim for sub-100ms response times.
- Return valid verdicts — Only
"allow","block", and"redact"are accepted. Invalid values default to"allow". - Use fail-closed sparingly — Only enable fail-closed mode when your policy check is mandatory for compliance.
- Log decisions — Record your webhook’s verdicts for auditing and debugging.
- 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