API ReferenceWebhooks (Deprecated)

Webhooks API (Deprecated)

⚠️

Deprecated: This page documents only the webhook endpoints. See the comprehensive Webhooks & Notifications page for the full API including notification rules and channels.

Receive real-time notifications when events occur in ThinkHive.

List Webhooks

GET /api/v1/explainer/webhooks

Response:

{
  "success": true,
  "data": [
    {
      "id": "wh_001",
      "url": "https://your-app.com/webhooks/thinkhive",
      "events": ["trace.failure", "cluster.new"],
      "status": "active",
      "createdAt": "2024-01-15T10:00:00Z"
    }
  ]
}

Create Webhook

POST /api/v1/explainer/webhooks

Request Body:

{
  "url": "https://your-app.com/webhooks/thinkhive",
  "events": ["trace.failure", "cluster.new", "fix.proposed"],
  "secret": "your_webhook_secret"
}

Response:

{
  "success": true,
  "data": {
    "id": "wh_002",
    "url": "https://your-app.com/webhooks/thinkhive",
    "events": ["trace.failure", "cluster.new", "fix.proposed"],
    "status": "active"
  }
}

Update Webhook

PATCH /api/v1/explainer/webhooks/:id

Delete Webhook

DELETE /api/v1/explainer/webhooks/:id

Test Webhook

POST /api/v1/explainer/webhooks/:id/test

Response:

{
  "success": true,
  "data": {
    "delivered": true,
    "responseCode": 200,
    "latencyMs": 150
  }
}

Available Events

EventDescription
trace.successTrace completed successfully
trace.failureTrace failed
cluster.newNew failure cluster created
cluster.grownExisting cluster grew significantly
fix.proposedNew fix proposed
fix.appliedFix was applied
shadow_test.completedShadow test finished
eval.completedEvaluation run completed
drift.detectedModel drift detected

Webhook Payload

{
  "event": "trace.failure",
  "timestamp": "2024-01-15T10:00:00Z",
  "data": {
    "traceId": "tr_xyz789",
    "agentId": "agent_abc123",
    "failureReason": "Hallucination detected",
    "severity": "high"
  }
}

Signature Verification

Verify webhook signatures using HMAC-SHA256:

import crypto from 'crypto';
 
function verifySignature(payload: string, signature: string, secret: string) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(`sha256=${expected}`)
  );
}

Retry Policy

  • Failed webhooks retry up to 5 times
  • Exponential backoff: 1min, 5min, 30min, 2hr, 24hr
  • Webhook disabled after 5 consecutive failures

Next Steps

  • Guides - In-depth feature guides
  • SDKs - SDK documentation