Webhooks
Instead of polling, give Beru an address on your server. Set it up in the console: your project → Webhooks → Add endpoint. Choose the events, and copy the signing secret.
Events
Section titled “Events”| Event | When | data |
|---|---|---|
document.ready |
A document can be searched | document: id, title, status, pages, warnings, metadata, source_type, end_user_id |
document.failed |
A document couldn’t be processed | document, with error in plain English |
usage.threshold |
Questions or pages reach 80% and 100% of your plan; once each per period | metric (questions or pages), threshold_percent, used, included, period_start |
memory.extracted |
Facts were kept from a conversation | end_user_id, added, updated, superseded |
webhook.test |
You clicked Send test | message |
Events never contain document text, questions or answers.
What your server receives
Section titled “What your server receives”A POST with a JSON body:
{ "id": "4d6f1c2e-…", "type": "document.ready", "created_at": "2026-11-26T19:40:12.481000+00:00", "project_id": "9a1b…", "data": { "document": { "id": "…", "title": "handbook.pdf", "status": "ready", "pages": 12, "warnings": [], "metadata": {}, "source_type": "file", "end_user_id": null } }}Headers: Beru-Event (the type), Beru-Delivery (the same as id) and Beru-Signature.
Answer with any 2xx within 10 seconds. Anything else, or no answer, is retried after 1 minute,
5 minutes, 30 minutes, 2 hours, 6 hours and 15 hours (about 24 hours in all), then marked failed.
A retry or a Resend from the console has the same id, so use it to ignore duplicates.
Check the signature
Section titled “Check the signature”Beru-Signature looks like t=1795723200,v1=5b1c…. Compute HMAC-SHA256 of "{t}.{raw body}" with
your signing secret and compare it to v1. Use the raw body exactly as received, and reject old
timestamps to stop replays.
import hashlib, hmac, time
def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool: parts = dict(item.split("=", 1) for item in header.split(",")) timestamp = int(parts["t"]) if abs(time.time() - timestamp) > tolerance: return False expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256) return hmac.compare_digest(expected.hexdigest(), parts["v1"])import { createHmac, timingSafeEqual } from "node:crypto";
export function verify(rawBody: string, header: string, secret: string, tolerance = 300): boolean { const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2))); const timestamp = Number(parts.t); if (Math.abs(Date.now() / 1000 - timestamp) > tolerance) return false; const expected = createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex"); return expected.length === parts.v1?.length && timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));}- https only, on a public address and standard port. Private network addresses are refused when you save the endpoint and checked again on every delivery. Redirects aren’t followed.
- Up to 5 endpoints per project. Each gets events from its own project;
usage.thresholdgoes to every endpoint in your organisation that wants it, since usage is counted per organisation. - Turn off an endpoint to pause it, Rotate its secret if it leaks (the old one stops at once), and see the last 50 deliveries with status, response code and error.