Skip to main content
Subscriptions act as filters for events addressed to you. Events sent to your Client ID but outside your subscriptions will queue based on your plan’s retention period (up to 30 days). Subscribe later to automatically receive queued events.

Usage

const subscription = await client.subscribe("order/*", {
  autoAck: false
});

subscription.on(async (event) => {
  console.log("Received:", event.payload);
  await subscription.ack(event.idem, event.block);
});

Parameters

ParameterTypeRequiredDescription
eventNamestringYesEvent path (supports wildcards: order/*)
optionsobjectNoSubscription options

Options

OptionTypeDefaultDescription
autoAckbooleantrueAuto-acknowledge events
appSecretKeystringnullCustom decryption key

Event Structure

{
  idem: "unique-event-id",
  block: "block-id",
  eventName: "order/created",
  payload: { /* your data */ },
  timestamp: 1634567890123,
  sender: "sender's appId",
  metadata: {
    $internal: {
      // EnSync internal metadata
      // e.g., message_size, replay_info, etc.
    }
  }
}