FabricFabricSDK

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:

  1. Identifies the plugin via pluginWebhookMatcher
  2. Verifies the HMAC signature (Stripe, Resend, Asana, Twilio supported out of the box)
  3. Runs webhookHooks.before
  4. Invokes the webhook handler
  5. Runs webhookHooks.after
  6. 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.