anirag.io

API

Webhooks

Event-getriebene Integration: Document-Indexed, Query-Completed, Audit-Trigger.

Anirag liefert Events per Webhook für event-getriebene Integrationen.

Setup

bashPOST /v1/webhooks
{
  "url": "https://your-app.example/anirag-webhook",
  "events": ["document.indexed", "source.indexed", "query.completed", "audit.threshold"],
  "secret": "whsec_..."
}

Events

source.indexed

Wird gefeuert, wenn eine Source (YouTube-Video, Zoom-Recording, Podcast-Episode, …) transkribiert + indiziert ist. Siehe Sources.

json{
  "type": "source.indexed",
  "workspace": "ws_01HKQR...",
  "source": {
    "id": "src_01HKQR...",
    "type": "youtube",
    "url": "https://youtube.com/watch?v=...",
    "duration_minutes": 47,
    "language": "de",
    "transcript_chars": 28412,
    "chunks_count": 38
  },
  "cost_eur": 0.376,
  "ts": "2026-04-15T09:00:00Z"
}

document.indexed

Wird gefeuert, wenn ein Dokument fertig indiziert ist.

json{
  "type": "document.indexed",
  "workspace": "ws_01HKQR...",
  "document": {
    "id": "doc_01HKQR...",
    "name": "handbuch.pdf",
    "chunks_count": 287
  },
  "ts": "2026-04-15T09:00:00Z"
}

query.completed

Wird gefeuert nach jeder Query (asynchron, blockiert Query-Response nicht).

json{
  "type": "query.completed",
  "workspace": "ws_01HKQR...",
  "query_id": "q_01HKQR...",
  "user_id": "usr_01HKQR...",
  "tokens": { "input": 1234, "output": 156 },
  "latency_ms": 642,
  "ts": "2026-04-15T09:00:00Z"
}

audit.threshold

Wird gefeuert, wenn Audit-Log-Schwellen erreicht sind (z. B. >100 Queries/min von einem User → Alert).

json{
  "type": "audit.threshold",
  "workspace": "ws_01HKQR...",
  "rule": "queries_per_user_per_minute",
  "actual": 142,
  "threshold": 100,
  "ts": "2026-04-15T09:00:00Z"
}

Signatur-Verifikation

Anirag signiert Webhooks mit HMAC-SHA-256. Header:

httpX-Anirag-Signature: sha256=abcdef...
X-Anirag-Timestamp: 1714378800

Verifizieren Sie die Signatur auf Ihrer Seite, um Replay-Angriffe zu vermeiden:

typescriptimport crypto from "node:crypto";

function verify(body: string, signature: string, secret: string): boolean {
  const expected = "sha256=" + crypto.createHmac("sha256", secret).update(body).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
}

Retry-Verhalten

  • Anirag erwartet 200-2xx-Antwort innerhalb 5 s.
  • Bei Fehler: 5 Retries mit Exponential-Backoff (1m, 5m, 15m, 1h, 6h).
  • Nach 6 h endgültiger Fehler — Webhook wird im Dashboard markiert.