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.
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.
| Field | Type | Description |
|---|---|---|
| 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
Create a new webhook subscription to receive events at your endpoint.
Request body
| Field | Type | Description |
|---|---|---|
urlrequired | string | Public HTTP or HTTPS URL; localhost is blocked. |
eventsrequired | string[] | Events to subscribe to (see the full list above) |
description | string | Human-readable description of this webhook |
retry_on_failure | boolean | Retry delivery on 5xx / network errors (default true) |
max_retries | integer | Retries after the first failed delivery, 0 to 12 (default 5, so at most 6 attempts; at most 11 retries are made) |
timeout_seconds | integer | Per-attempt timeout (default 30s) |
Response
| Field | Type | Description |
|---|---|---|
id | string | Webhook ID |
url | string | Webhook endpoint URL |
events | string[] | Subscribed events |
signing_secret | string | HMAC secret used to verify request signatures. Store this securely: it's only shown in full on creation. |
secret | string | Legacy alias of signing_secret (same value). Prefer signing_secret in new code. |
is_active | boolean | Whether this webhook is currently receiving events |
delivery_statistics | object | Nested delivery stats: {total, successful, failed, success_rate, last_delivery_at, last_success_at, last_failure_at, last_error} |
created_at | datetime | Creation timestamp |
Example
{
"url": "https://example.com/webhooks/hebbrix",
"events": [
"memory.created",
"memory.updated",
"document.processed"
]
}{
"id": "wh_abc123",
"url": "https://example.com/webhooks/hebbrix",
"events": [
"memory.created",
"memory.updated",
"document.processed"
],
"signing_secret": "whsec_7f3b9a2c1d4e5f6a7b8c9d0e1f2a3b4c",
"secret": "whsec_7f3b9a2c1d4e5f6a7b8c9d0e1f2a3b4c",
"is_active": true,
"delivery_statistics": {
"total": 0,
"successful": 0,
"failed": 0,
"success_rate": 0,
"last_delivery_at": null,
"last_success_at": null,
"last_failure_at": null,
"last_error": null
},
"created_at": "2024-01-15T10:30:00Z"
}List all webhook subscriptions for your account.
Get details for a specific webhook including delivery statistics.
Response
| Field | Type | Description |
|---|---|---|
id | string | Webhook ID |
url | string | Endpoint URL |
events | string[] | Subscribed events |
is_active | boolean | Whether the webhook is active |
delivery_statistics | object | Nested delivery stats object |
delivery_statistics.total | integer | Total attempted deliveries |
delivery_statistics.successful | integer | Successful deliveries (2xx response) |
delivery_statistics.failed | integer | Failed deliveries after retries |
delivery_statistics.success_rate | number | Percentage success (0-100) |
delivery_statistics.last_delivery_at | datetime? | Timestamp of most recent delivery attempt |
delivery_statistics.last_success_at | datetime? | Timestamp of most recent successful delivery |
delivery_statistics.last_failure_at | datetime? | Timestamp of most recent failure |
delivery_statistics.last_error | string? | Error message from the most recent failure |
total_deliveries | integer | Legacy flat field, same as delivery_statistics.total |
successful_deliveries | integer | Legacy flat field, same as delivery_statistics.successful |
failed_deliveries | integer | Legacy flat field, same as delivery_statistics.failed |
signing_secret | string | The HMAC signing secret (shown as *** after initial creation) |
Partial update of a webhook (preferred). Only the fields you send are changed. Same handler as PUT; use either verb.
Request body
| Field | Type | Description |
|---|---|---|
url | string | New endpoint URL |
events | string[] | Updated events list |
description | string | Updated description |
is_active | boolean | Activate or deactivate the webhook |
retry_on_failure | boolean | Toggle retry-on-failure |
max_retries | integer | Updated retry limit (retries after the first attempt, 0 to 12) |
timeout_seconds | integer | Updated per-attempt timeout |
Legacy alias of PATCH with the same semantics. Prefer PATCH for new integrations.
Request body
| Field | Type | Description |
|---|---|---|
url | string | New endpoint URL |
events | string[] | Updated events list |
is_active | boolean | Activate or deactivate the webhook |
Delete a webhook subscription.
Send a test event to your webhook endpoint to verify it's working.
Rotate the HMAC signing secret for a webhook. The old secret is immediately invalidated, so update your receiver with the new value returned in the response.
Webhook Payload
Every webhook delivery includes these standard fields:
{
"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_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
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.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", 200import 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_retriesof 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
/v1/webhookscurl -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"
]
}'