---
source_url: https://www.pubnub.com/docs/sdks/angular2/api-reference/channel-groups
title: Channel Groups API for Angular2 SDK
updated_at: 2026-05-19T12:11:36.551Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Channel Groups API for Angular2 SDK

[Channel groups](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) allow PubNub developers to bundle thousands of [channels](https://www.pubnub.com/docs/general/channels/overview) into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.

:::note Channel group operations
You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.
:::

## Add channels to a channel group

:::note Maximum number of channels
You can add up to 200 channels to a channel group per API call.
:::

This function adds channels to a channel group.

### Method(s)

Use the following method in the Angular2 SDK:

:::note
`200 channels` can be added to the `channel group` per API call.
:::

```javascript
pubnub.channelGroups.addChannels({Array channels, String channelGroup},Function callback)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channels | Array | Yes |  | The channels to add to the channel group. |
| channelGroup | String | Yes |  | The channel group to add the channels to. |
| callback | Function | Optional |  | Executes on a successful/unsuccessful `addChannels`. |

### Sample code

#### Add channels

```javascript
pubnub.channelGroups.addChannels(
    {
        channels: ['my_channel1', 'my_channel2'],
        channelGroup: "my_channelGroup"
    },
    function(status) {
        if (status.error) {
            console.log("operation failed w/ status: ", status);
        } else {
            console.log("operation done!");
        }
    }
);
```

### Response

```javascript
{
    error: false,
    operation: "PNAddChannelsToGroupOperation",
    statusCode: 200
}
```

## List channels in a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function lists all channels in a channel group.

### Method(s)

Use the following method in the Angular2 SDK:

```javascript
pubnub.channelGroups.listChannels({String channelGroup},Function callback)
```

| Parameter | Description |
| --- | --- |
| `channelGroup` *Type: String | The channel group for which to list channels. |
| `callback`Type: Function | Executes on a successful/unsuccessful `listChannels`. |

### Sample code

#### List channels

```javascript
// assuming an intialized Pubnub instance already exists
pubnub.channelGroups.listChannels(
    {
        channelGroup: "my_channelGroup"
    },
    function (status, response) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
            return;
        }
        console.log("listing push channel for device");
        response.channels.forEach( function (channel) {
            console.log(channel);
        });
    }
);
```

### Response

```javascript
// Example of Status
{
    error: false,
    operation: "PNChannelsForGroupOperation",
    statusCode: 200
}

// Example of Response
{
    channels: ["ch1", "ch2"]
}
```

## Remove channels from a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function removes channels from a channel group.

### Method(s)

Use the following method in the Angular2 SDK:

```javascript
pubnub.channelGroups.removeChannels({Array channels, String channelGroup},Function callback)
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: Array | The channels to remove from the channel group. |
| `channelGroup` *Type: String | The channel group from which to remove the channels. |
| `callback`Type: Function | Executes on a successful/unsuccessful `removeChannels`. |

### Sample code

#### Remove channels

```javascript
pubnub.channelGroups.removeChannels(
    {
        channels: ["my_channel2"],
        channelGroup: "my_channelGroup"
    },
    function (status) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
        } else {
            console.log("operation done!");
        }
    }
);
```

### Response

```javascript
{
    error: false,
    operation: "PNRemoveChannelsFromGroupOperation",
    statusCode: 200
}
```

## Delete a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function deletes a channel group.

### Method(s)

Use the following method in the Angular2 SDK:

```javascript
pubnub.channelGroups.deleteGroup({String channelGroup},Function callback)
```

| Parameter | Description |
| --- | --- |
| `channelGroup` *Type: String | The channel group to delete. |
| `callback`Type: Function | Executes on a successful/unsuccessful `deleteGroup`. |

### Sample code

#### Delete channel group

```javascript
pubnub.channelGroups.deleteGroup(
    {
        channelGroup: "my_channelGroup"
    },
    function (status) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
        } else {
            console.log("operation done!");
        }
    }
);
```

### Response

```javascript
{
    error: false,
    operation: "PNRemoveGroupOperation",
    statusCode: 200
}
```

## Terms in this document

* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
