Docs⌘ K  Search
Docs/Build/Webhooks
Webhooks

Webhooks

Receive notifications when events happen in your Hebbrix account. Webhooks let you build integrations that react to memory changes, document processing, and other events.

1
Event Occurs
Memory created, document processed, etc.
2
Webhook Fired
POST request sent to your endpoint
3
You Process
Handle the event and respond 2xx

How Webhooks Work

When an event occurs (like a new memory being created), Hebbrix sends an HTTP POST request to your configured endpoint with details about the event. Your server processes the payload and responds with a 2xx status to acknowledge receipt.

Supported Events

Learning-policy v2 also emits learning.autonomy_promoted, learning.autonomy_demoted and learning.change_alert on outcome-write transitions. Payloads contain an event ID, exact policy/action/context/scope and evidence. Deduplicate retries by event ID. These are outcome-readiness notifications, not permission or live rule clearance; configuration/time changes alone do not emit them. See learning report limits.

FieldTypeDescription
memory.created-A new memory was created
memory.updated-A memory was updated
memory.deleted-A memory was deleted
memory.tier_changed-A memory was promoted/demoted between tiers
document.created-A new document was uploaded
document.processed-Document processing finished (searchable)
document.failed-Document processing failed
document.deleted-A document was deleted
collection.created-A new collection was created
collection.updated-A collection's metadata or members changed
collection.deleted-A collection was deleted (its memories and documents also send memory.deleted and document.deleted)
search.completed-A search finished: query ID, endpoint, result count, latency and cache hit. No query text or results
memory.searched-Memories were searched; same metadata-only payload as search.completed
user.feedback_received-User provided explicit feedback on a memory / answer
rl.training_started-A reinforcement-learning job kicked off
rl.training_completed-Reinforcement-learning job finished successfully
rl.training_failed-Reinforcement-learning job failed

Endpoints

Webhook Payload

Every webhook delivery includes these standard fields:

Webhook Payload
{
  "id": "1c770432-5a75-40ce-93e9-20262a87611a",
  "event_type": "memory.created",
  "timestamp": 1792234150,
  "data": {
    "memory_id": "fd99eb88-c8fe-4e93-b999-aa4a9643e228",
    "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd",
    "content_preview": "The user prefers dark mode.",
    "importance": 0.75,
    "source_type": "api",
    "created_at": "2026-10-17T10:45:57.941502"
  },
  "idempotency_key": "webhook:68b65b67-b8da-4d25-9a41-805e9be59e90:cef2af99-b289-411b-b187-6c2bf5fa5651"
}

The X-Webhook-Event-Type header equals event_type. timestamp is a Unix epoch integer (seconds). Use idempotency_key to deduplicate; the same key is used for all retry attempts of a single delivery.

Event data by type

The envelope above is the same for every event; data varies. content_preview is the first 200 characters of a memory. Deleted memories and all document, search and feedback events carry no content. A batch memory.created lists at most 20 IDs (created_count gives the total); a batch memory.deleted lists every ID, up to 1,000 per event. Events for one memory arrive in order (created, then updated, then deleted).

Event data examples
{"event_type": "memory.created", "data": {"action": "batch_create", "created_count": 2, "memory_ids": ["fd99eb88-c8fe-4e93-b999-aa4a9643e228", "aad007ff-769a-47cc-b8a0-28e169eaf9e0"], "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "created_at": "2026-10-17T10:45:58.683655"}}
{"event_type": "memory.updated", "data": {"memory_id": "2ed7b366-18a5-594b-8cd0-31ec4c0b27a9", "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "content_preview": "The user prefers light mode in the daytime.", "importance": 0.9, "source_type": "correction", "created_at": "2026-10-17T11:36:06.196394", "updated_at": "2026-10-17T11:36:06.196394", "previous_memory_id": "fd99eb88-c8fe-4e93-b999-aa4a9643e228", "changed_fields": ["content"]}}
{"event_type": "memory.updated", "data": {"action": "batch_update", "updated_count": 2, "memory_ids": ["2ed7b366-18a5-594b-8cd0-31ec4c0b27a9", "aad007ff-769a-47cc-b8a0-28e169eaf9e0"], "updates": [{"memory_id": "2ed7b366-18a5-594b-8cd0-31ec4c0b27a9", "previous_memory_id": "fd99eb88-c8fe-4e93-b999-aa4a9643e228", "changed_fields": ["content"]}, {"memory_id": "aad007ff-769a-47cc-b8a0-28e169eaf9e0", "previous_memory_id": null, "changed_fields": ["metadata"]}], "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "updated_at": "2026-10-17T11:40:00.000000"}}
{"event_type": "memory.deleted", "data": {"memory_id": "aad007ff-769a-47cc-b8a0-28e169eaf9e0", "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "deleted_at": "2026-10-17T10:46:07.335350"}}
{"event_type": "memory.deleted", "data": {"action": "batch_delete", "deleted_count": 2, "memory_ids": ["fd99eb88-c8fe-4e93-b999-aa4a9643e228", "aad007ff-769a-47cc-b8a0-28e169eaf9e0"], "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "deleted_at": "2026-10-17T10:46:07.335350"}}
{"event_type": "document.created", "data": {"document_id": "30dd6f27-2884-4a0c-abb4-bf617081839f", "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "filename": "runbook.md", "status": "uploaded", "file_type": "markdown", "file_size": 70, "created_at": "2026-10-17T11:36:05.821013"}}
{"event_type": "document.processed", "data": {"document_id": "30dd6f27-2884-4a0c-abb4-bf617081839f", "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "filename": "runbook.md", "status": "searchable", "file_type": "markdown", "file_size": 70, "processed_at": "2026-10-17T11:36:20.104311"}}
{"event_type": "document.failed", "data": {"document_id": "30dd6f27-2884-4a0c-abb4-bf617081839f", "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "filename": "runbook.md", "status": "failed", "file_type": "markdown", "file_size": 70, "failed_at": "2026-10-17T11:36:20.104311", "reason": "ValueError: parser rejected page 3"}}
{"event_type": "document.deleted", "data": {"document_id": "30dd6f27-2884-4a0c-abb4-bf617081839f", "collection_id": "ec0c2165-cea9-4061-8afc-2f6b70ff75bd", "filename": "runbook.md", "status": "deleted", "file_type": "markdown", "file_size": 70, "deleted_at": "2026-10-17T12:01:00.000000"}}

Verifying Signatures

Always verify signatures. Every webhook includes a signature in the X-Webhook-Signature-256 header (format sha256=<hex>) and the signing timestamp in X-Webhook-Timestamp. Verify both using your signing_secret to confirm the request came from Hebbrix.
Python (Flask)
import hmac
import hashlib
from flask import Flask, request

app = Flask(__name__)
WEBHOOK_SECRET = "whsec_your_secret_here"

@app.route("/webhooks/hebbrix", methods=["POST"])
def handle_webhook():
    # Get the signature + timestamp from headers
    signature = request.headers.get("X-Webhook-Signature-256", "")
    timestamp = request.headers.get("X-Webhook-Timestamp")

    # Strip the "sha256=" prefix
    if signature.startswith("sha256="):
        signature = signature[7:]

    # Create the signed payload (timestamp.body)
    payload = f"{timestamp}.{request.data.decode()}"

    # Calculate expected signature
    expected = hmac.new(
        WEBHOOK_SECRET.encode(),
        payload.encode(),
        hashlib.sha256
    ).hexdigest()

    # Verify signature matches (timing-safe)
    if not hmac.compare_digest(signature, expected):
        return "Invalid signature", 401

    # Process the event
    event = request.json
    print(f"Received event: {event['event_type']}")

    if event["event_type"] == "memory.created":
        handle_memory_created(event["data"])
    elif event["event_type"] == "document.processed":
        handle_document_processed(event["data"])

    return "OK", 200
TypeScript (Express)
import crypto from 'crypto';
import express from 'express';

const app = express();
const WEBHOOK_SECRET = 'whsec_your_secret_here';

app.post('/webhooks/hebbrix', express.raw({type: 'application/json'}), (req, res) => {
  const signatureHeader = (req.headers['x-webhook-signature-256'] || '') as string;
  const timestamp = req.headers['x-webhook-timestamp'] as string;

  // Strip the "sha256=" prefix
  const signature = signatureHeader.startsWith('sha256=')
    ? signatureHeader.slice(7)
    : signatureHeader;

  // Create the signed payload (timestamp.body)
  const payload = `${timestamp}.${req.body.toString()}`;

  // Calculate expected signature
  const expected = crypto
    .createHmac('sha256', WEBHOOK_SECRET)
    .update(payload)
    .digest('hex');

  // Verify signature matches (timing-safe)
  const sigBuf = Buffer.from(signature, 'hex');
  const expBuf = Buffer.from(expected, 'hex');
  if (sigBuf.length !== expBuf.length || !crypto.timingSafeEqual(sigBuf, expBuf)) {
    return res.status(401).send('Invalid signature');
  }

  // Process the event
  const event = JSON.parse(req.body.toString());
  console.log(`Received event: ${event.event_type}`);

  switch (event.event_type) {
    case 'memory.created':
      handleMemoryCreated(event.data);
      break;
    case 'document.processed':
      handleDocumentProcessed(event.data);
      break;
  }

  res.status(200).send('OK');
});

Retry Policy

If your endpoint doesn't respond with a 2xx status (or the request times out after 30 seconds or fails at the transport layer), the first delivery is followed by up to max_retries retries: 5 by default, so at most 6 delivery attempts. max_retries accepts 0 to 12; at most 11 retries (12 attempts) are made. After the n-th failed attempt the next one waits at least 2^n seconds, capped at 15 minutes; deliveries leave a queue, so the actual gap can be longer.

  • Attempt 1: when the event happens
  • Attempt 2: at least 2s after attempt 1 failed
  • Attempt 3: at least 4s after attempt 2 failed
  • Attempt 4: at least 8s later
  • Attempt 5: at least 16s later
  • Attempt 6: at least 32s later (the last attempt with the default max_retries of 5)

A 4xx response other than 408, 425 and 429 is not retried, and with retry_on_failure: false the first failure is final. A delivery whose attempts are used up is moved to the Dead Letter Queue (DLQ) and marked as failed. Each attempt uses the same idempotency_key so your receiver can safely deduplicate.

Best Practices

  • Respond Quickly: return a 2xx response within 30 seconds. Process events asynchronously if needed.
  • Handle Duplicates: use the event ID to deduplicate. The same event may be delivered multiple times.
  • Verify Signatures: always verify the X-Webhook-Signature-256 header to ensure authenticity.
  • Use HTTPS: HTTPS recommended; HTTP is accepted for public hosts. Localhost endpoints are rejected for security.

cURL Example

POST/v1/webhooks
curl -X POST "https://api.hebbrix.com/v1/webhooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://example.com/webhooks/hebbrix",
  "events": [
    "memory.created",
    "document.processed"
  ]
}'
Ask the docs
reading · this page

Hi! I'm the Hebbrix docs assistant. Ask me anything about this page: setup, code examples, endpoints, pricing, or integrations.