Webhooks
Signature verification, hook system, out-of-order recovery.
Plugins declare webhooks the same way they declare endpoints — a nested tree under the plugin's namespace, with typed payloads and an HMAC signature verifier.
Wire a webhook handler
import { processWebhook } from '@fabricorg/integrations';
// In your HTTP handler:
const response = await processWebhook(fabric, {
request: {
url: '/webhooks/slack',
headers: req.headers,
body: req.body,
},
});The dispatcher:
- Identifies the plugin via
pluginWebhookMatcher - Verifies the HMAC signature (Stripe, Resend, Asana, Twilio supported out of the box)
- Runs
webhookHooks.before - Invokes the webhook handler
- Runs
webhookHooks.after - Returns a structured response
Out-of-order recovery
For event streams that may arrive out of order (e.g. a contact.updated before the contact.created), wrap the handler with withEntityRecovery:
import { withEntityRecovery } from '@fabricorg/integrations';
const handler = withEntityRecovery({
store: entityStore,
pluginId: 'hubspot',
entityType: 'contacts',
resolveId: (payload) => payload.objectId,
fetch: async (id) => fabric.hubspot.api.contacts.get({ id }),
apply: async (entity) => {
// …downstream logic
},
});The recovery layer fetches the missing parent record if the cache miss happens, then applies the original event.