Webhooks
Real-time event notifications for your AI governance pipeline
Overview
Webhooks allow you to receive real-time HTTP notifications when events occur in your Tork AI Governance pipeline. Instead of polling the API, your server receives POST requests with event data whenever something important happens.
Real-time
Instant notifications when events occur
Secure
HMAC-SHA256 signature verification
Reliable
Automatic retries with exponential backoff
Webhook Events
Subscribe to the events that matter to your workflow. Each webhook can listen to multiple event types.
Governance Events
policy.violationTriggered when content violates a configured policy rule. Includes policy details, violation type, and severity.
pii.detectedTriggered when personally identifiable information is detected in content. Includes detected entity types and confidence scores.
agent.blockedTriggered when an AI agent action is blocked by governance rules. Includes the blocked action and reason.
Human-in-the-Loop Events
hitl.pendingTriggered when a request requires human review before proceeding.
hitl.approvedTriggered when a human reviewer approves a pending request.
hitl.rejectedTriggered when a human reviewer rejects a pending request.
System Events
circuit_breaker.triggeredTriggered when a circuit breaker opens due to repeated failures, temporarily blocking requests.
rate_limit.exceededTriggered when rate limits are exceeded for an API key or IP address.
security.alertTriggered for security-related events such as suspicious activity or authentication anomalies.
Setting Up Webhooks
1. Create a Webhook Endpoint
2. Store the Secret Securely
The response includes a secret that you must store securely. This secret is only shown once and is used to verify webhook signatures.
Store your webhook secret in a secure environment variable. Never commit it to source control or expose it in client-side code.
Webhook Payload
All webhook payloads follow a consistent structure with event metadata and event-specific data:
HTTP Headers
Signature Verification
Always verify webhook signatures to ensure requests are from Tork. The signature uses HMAC-SHA256 with your webhook secret.
Retry Policy
Tork automatically retries failed webhook deliveries with exponential backoff:
4xx errors are not retried as they indicate a client-side issue. Ensure your endpoint returns a 2xx status code to acknowledge receipt.
Best Practices
- Always verify signatures - Never process webhooks without verifying the HMAC signature
- Respond quickly - Return a 2xx response within 10 seconds; process asynchronously if needed
- Handle duplicates - Use the delivery ID to deduplicate; webhooks may be sent more than once
- Use HTTPS - Webhook URLs must use HTTPS in production for security
- Rotate secrets periodically - Use the API to rotate your webhook secret regularly
- Monitor delivery logs - Check the deliveries endpoint to track webhook health
- Implement idempotency - Design handlers to safely process the same event multiple times