Skip to main content
npayload is launching soon.
npayloadDocs
Concepts

Channels

Named message streams with privacy modes, retention, and channel types

A channel is a named message stream. You publish messages to a channel and create subscriptions to receive them. Channels are the fundamental organising unit in npayload.

Channel types

TypeBehaviourUse case
StandardMessages delivered to all subscribers in orderEvent notifications, audit logs
CompactedKey-value semantics; only the latest message per key is retainedConfiguration state, inventory levels
PriorityMessages delivered in priority orderTask queues, alert escalation

Standard channels

The default. Every message published is stored immutably and delivered to every active subscription.

const channel = await npayload.channels.create({
  name: 'orders',
  description: 'Order lifecycle events',
  privacy: 'standard',
});

Compacted channels

Compacted channels retain only the latest message per key. When a new message with the same key is published, the previous message is replaced. This is ideal for state that changes over time.

const channel = await npayload.channels.create({
  name: 'inventory',
  description: 'Current stock levels per SKU',
  type: 'compacted',
});

// Later messages with the same key overwrite earlier ones
await npayload.messages.publish({
  channel: 'inventory',
  key: 'SKU-001',
  payload: { quantity: 42 },
});

Priority channels

Messages in priority channels are delivered in priority order rather than publish order. Higher priority messages are delivered first.

await npayload.messages.publish({
  channel: 'alerts',
  payload: { severity: 'critical', message: 'Database unreachable' },
  priority: 10, // Higher = delivered first
});

Privacy modes

Every channel has a privacy mode that controls who can read the message payload.

ModeMetadataPayloadnpayload can read?
StandardVisibleVisibleYes
HybridVisibleEncryptedNo (payload only)
E2EEncryptedEncryptedNo

Standard (default)

All features available. npayload can read payloads for routing, filtering, and schema validation.

{ privacy: 'standard' }

Hybrid

Metadata (routing keys, timestamps, trace IDs) remains visible for routing and debugging. The payload is encrypted with keys that npayload does not hold.

{ privacy: 'hybrid' }

E2E (end-to-end)

Zero-knowledge encryption. npayload cannot read the payload or metadata. Only the publisher and subscriber hold the decryption keys. Routing is limited to channel-level only.

{ privacy: 'e2e' }

E2E mode disables payload-based filtering and schema validation because npayload cannot inspect the encrypted content.

Channel settings

SettingDefaultDescription
retentionDays30How long messages are stored before automatic deletion
maxMessageSize256 KBMaximum payload size per message
maxSubscriptions100Maximum number of subscriptions per channel
const channel = await npayload.channels.create({
  name: 'events',
  settings: {
    retentionDays: 90,
    maxMessageSize: 524288, // 512 KB
    maxSubscriptions: 50,
  },
});

Channel lifecycle

Channels have three states:

StateDescription
ActiveNormal operation. Messages can be published and delivered.
PausedPublishing is blocked. Existing subscriptions continue receiving queued messages.
ArchivedSoft-deleted. No publishing, no delivery. Can be restored.
// Pause
await npayload.channels.pause('orders');

// Resume
await npayload.channels.resume('orders');

// Archive (soft delete)
await npayload.channels.archive('orders');

Cross-instance channels

When a channel spans multiple instances, npayload automatically replicates messages between them with exactly-once delivery guarantees.

Cross-instance channels enable:

  • Multi-region messaging for data residency compliance
  • Cross-organisation communication for B2B integrations
  • Instance-to-instance routing with automatic discovery

Cross-region replication requires explicit data residency consent from both the source and destination organisations.

Next steps

Was this page helpful?

On this page