Skip to content

Events & Webhooks

Because WebbiOS Apps run as isolated Cloudflare Workers with strict data ownership, asynchronous events and webhooks provide decoupled communication between Core, Apps, and external integrations.

When domain or platform events occur, subscribers receive signed HTTP POST notifications rather than polling or querying another module’s database.

import { WebbiSDK } from '@webbios/sdk';
const sdk = new WebbiSDK({
endpoint: process.env.WEBBIOS_API_ENDPOINT!,
token: process.env.WEBBIOS_API_TOKEN!,
});
await sdk.webhooks.register({
topic: 'records/updated',
address: 'https://your-integration.example.com/webhooks/webbios',
format: 'json',
});

Never trust unverified webhook payloads. Always verify the cryptographic signature against the raw request body using a constant-time comparison and reject requests when verification fails or secrets are missing:

// Pseudocode for fail-closed webhook signature verification
app.post('/webhooks/webbios', async (c) => {
const signature = c.req.header('x-webbios-signature');
if (!signature || !c.env.WEBHOOK_SECRET) {
return c.text('Unauthorized', 401);
}
const rawBody = await c.req.text();
const isValid = await verifyHmacSha256(rawBody, signature, c.env.WEBHOOK_SECRET);
if (!isValid) {
return c.text('Invalid signature', 401);
}
// Handle verified event payload
return c.text('OK', 200);
});

Security Rule (v1.1.0): Never pass internal secrets or signing keys into untrusted hooks, and never share a single global signing secret across unrelated trust boundaries.