---
source_url: https://www.pubnub.com/docs/sdks/freertos/api-reference/channel-groups
title: Channel Groups API for FreeRTOS SDK
updated_at: 2026-05-21T15:46:31.175Z
sdk_name: PubNub FreeRTOS SDK
---

> 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 FreeRTOS SDK

PubNub FreeRTOS 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 Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the PubNub [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 adds channels to a channel group.

### Method(s)

`Adding Channels` is accomplished by using the following method(s) in the FreeRTOS SDK:

```c
enum pubnub_res pubnub_add_channel_to_group (pubnub_t *p, char const *channel, char const *channel_group)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| p | pubnub_t* | Yes |  | Pointer to PubNub client context. |
| channel | char | Yes |  | The `channel` to add |
| channel_group | char | Yes |  | The `channel group` to add to |

### Sample code

#### Add channels

```c
static char *channel_group = "family";
```

```c
enum pubnub_res res;
res = pubnub_add_channel_to_group(pn, "wife", channel_group);
return check_response(pn, res);
```

### Rest response from server

```json
{
    "service" : "channel-registry",
    "status"  : 200,
    "error"   : false,
    "message" : "OK"
}
```

## 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)

`Listing Channels` is accomplished by using the following method(s) in the FreeRTOS SDK:

```c
enum pubnub_res pubnub_list_channel_group (pubnub_t *p, char const *channel_group)
```

| Parameter | Description |
| --- | --- |
| `p` *Type: pubnub_t* | Pointer to PubNub client context. |
| `channel_group` *Type: char const* | The channel `group` to list channels from |

### Sample code

#### List channels

```c
static char *channel_group = "family";
```

```c
pubnub_list_channel_group(ctx, channel_group);
pbresult = pubnub_await(ctx);
if (PNR_OK == pbresult) {
    char const *json_response = pubnub_get(ctx);
}
```

### Rest response from server

```json
{
    "status" : 200,
    "payload" : {
        "channels" : ["hi"],
        "group" : "abcd"
    },
    "service" : "channel-registry",
    "error" : False
}
```

## 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)

`Removing Channels` is accomplished by using the following method(s) in the FreeRTOS SDK:

```c
enum pubnub_res pubnub_remove_channel_from_group (pubnub_t *p, char const *channel, char const *channel_group)
```

| Parameter | Description |
| --- | --- |
| `p` *Type: pubnub_t* | Pointer to PubNub client context. |
| `channel` *Type: char const* | The `channel` to remove |
| `channel_group` *Type: char const* | The `channel group` to remove from |

### Sample code

Removing channels :

```c
static char *channel_group = "family";
```

```c
enum pubnub_res res;
res = pubnub_remove_channel_from_group(pn, "son", channel_group);
return check_response(pn, res);
```

### Rest response from server

```json
{
    "status" : 200,
    "message" : "OK",
    "service" : "channel-registry",
    "error" : False
}
```

## 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)

`Deleting Channel Group` is accomplished by using the following method(s) in the FreeRTOS SDK:

```c
enum pubnub_res pubnub_remove_channel_group (pubnub_t *p, char const *channel_group)
```

| Parameter | Description |
| --- | --- |
| `p` *Type: pubnub_t* | Pointer to PubNub client context. |
| `channel_group` *Type: char const* | The `channel` `group` to remove. |

### Sample code

Deleting Channel Group :

```c
static char *channel_group = "family";
```

```c
enum pubnub_res res;
res = pubnub_remove_channel_group(pn, channel_group);
return check_response(pn, res);
```

### Rest response from server

```json
{
    "status" : 200,
    "message" : "OK",
    "service" : "channel-registry",
    "error" : False
}
```

## 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.
* **PubNub** - PubNub is a real-time messaging platform that provides APIs and SDKs for building scalable applications. It handles the complex infrastructure of real-time communication, including: Message delivery and persistence, Presence detection, Access control, Push notifications, File sharing, Serverless processing with Functions and Events & Actions, Analytics and monitoring with BizOps Workspace, AI-powered insights with Illuminate.