All documentation
Channels

Channels: List, Create and Reuse

Create channels dynamically, list existing channels and reuse a returned slug instead of hardcoding infrastructure.

Multi-language

Overview

Channels are project-scoped realtime rooms. Applications can create them from trusted backend code, so a channel does not need to be manually created in the dashboard first. A good integration normally: 1. lists or looks up existing channels, 2. creates the channel only when needed, 3. stores or uses the slug returned by PulseGrid, 4. lets clients connect only to channels allowed by their client token. This supports dynamic rooms such as order-1042, support-case-88 or team-finance without hardcoding every room in advance.

Setup

JavaScript: - pg.channels.all() returns the project's channel list. - pg.channels.create(...) creates a channel. - pg.channel(slug) returns a helper for that channel. Python: - pg.channels.all() returns the project's channel list. - pg.channels.create(...) creates a channel. - pg.channel(slug) returns a helper for that channel. Recommended pattern: search the list for the business room you want; if it does not exist, create it and use the returned channel slug.

Code example

Channels: List, Create and Reuse
JavaScript
const channels = await pg.channels.all();
let room = channels.find(c => c.slug === "order-1042");

if (!room) {
  const created = await pg.channels.create({
    name: "Order 1042",
    channelType: "private",
    description: "Live order room",
    persistEvents: true,
    retentionDays: 30,
  });
  room = created.data.channel;
}

const channel = pg.channel(room.slug);

Notes

Do not assume a slug before creation if your application allows arbitrary names. Use the response returned by PulseGrid. Channel creation is a trusted operation. Public frontend code should normally receive an already-authorized channel slug plus a short-lived client token from your backend.