---
source_url: https://www.pubnub.com/docs/sdks/unreal/api-reference/channel-groups
title: Channel Groups API for Unreal SDK
updated_at: 2026-05-22T11:08:03.214Z
sdk_name: PubNub Unreal SDK
sdk_version: 2.0.5
---

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

PubNub Unreal SDK, use the latest version: 2.0.5

[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.
:::

##### Usage in Blueprints and C++

You can use PubNub's functionality via Blueprints or directly in C++ code.

* In Blueprints, the SDK is managed by a subsystem. Start by calling the Pubnub Subsystem node, then use Create Pubnub Client to create a UPubnubClient instance.
* In a C++ project, you have to add a dependency to PubnubLibrary: In your IDE, navigate to Source/_{YourProject}_/_{YourProject}_.Build.cs and add a dependency to PubnubLibrary. PrivateDependencyModuleNames.AddRange(new string[] { "PubnubLibrary" });, Compile the code and run the project.
* In C++, start by getting the UPubnubSubsystem (a Game Instance Subsystem), then create a UPubnubClient with your configuration. #include "Kismet/GameplayStatics.h"#include "PubnubSubsystem.h"#include "PubnubClient.h" UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>(); FPubnubConfig Config;Config.PublishKey = "pub-c-...";Config.SubscribeKey = "sub-c-...";Config.UserId = "my-user-id"; UPubnubClient* PubnubClient = PubnubSubsystem->CreatePubnubClient(Config); PubnubClient allows you to call PubNub SDK functions, for example: PubnubClient->PublishMessageAsync("my-channel", "Hello!", OnPublishMessageResponseDelegate); The SDK supports multiple UPubnubClient instances within the same game for different contexts such as different users or keysets. For more information, refer to Configuration.

:::note Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
* Asynchronous methods (Async suffix) return void and take an optional delegate parameter that fires when the operation completes. 1PubnubClient->AddChannelToGroupAsync("my-channel", "my-group", OnAddChannelToGroupResponseDelegate); You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubAddChannelToGroupResponseNative).
* Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly. 1FPubnubOperationResult Result = PubnubClient->AddChannelToGroup("my-channel", "my-group");
:::

## Add channels to a channel group

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on 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.
:::

This function adds a channel to a channel group. You can call `AddChannelToGroup()` on a [ChannelGroup entity](#add-channels-channel-group-entity) (which already knows its channel group) or directly on the [PubNub client](#add-channels-pubnub-client) by passing the channel group name explicitly.

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

### ChannelGroup entity

##### Available in entities

This method is available to use with the `ChannelGroup` entity. For more information, refer to [ChannelGroup](https://www.pubnub.com/docs/sdks/unreal/entities/channel-group).

#### Method(s)

```cpp
UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");

ChannelGroupEntity->AddChannelToGroup(
    FString Channel,
    FOnAddChannelToGroupResponse OnAddChannelToGroupResponse
);
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Channel | FString | Yes |  | The channel to add to the channel group. |
| OnAddChannelToGroupResponse | FOnAddChannelToGroupResponse | Yes |  | The delegate for the operation's result. You can also use a native callback of the type [FOnAddChannelToGroupResponseNative](#fonaddchanneltogroupresponsenative) to handle the result using a lambda. |

##### FOnAddChannelToGroupResponse

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

##### FOnAddChannelToGroupResponseNative

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void AddChannelToGroupSample();
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::AddChannelToGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Add channel to the channel group using the channel group entity
	FString Channel = TEXT("global_chat");
	ChannelGroupEntity->AddChannelToGroupAsync(Channel);
}
```

#### Returns

This method is void, but the delegate returns the [FOnAddChannelToGroupResponse](#fonaddchanneltogroupresponse) struct.

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### Add channels to a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void AddChannelToGroupWithResultLambdaSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::AddChannelToGroupWithResultLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind lambda to response delegate
	FOnPubnubAddChannelToGroupResponseNative OnAddChannelToGroupResponse;
	OnAddChannelToGroupResponse.BindLambda([](const FPubnubOperationResult& Result)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to add channel to group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channel successfully added to group."));
		}
	});
	
	// Add channel to the channel group using the channel group entity
	FString Channel = TEXT("guild_chat");
	ChannelGroupEntity->AddChannelToGroupAsync(Channel, OnAddChannelToGroupResponse);
}
```

##### Add channels to a channel group with result struct

Use the result struct to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void AddChannelToGroupWithResultSample();

UFUNCTION()
void OnAddChannelToGroupResponse(FPubnubOperationResult Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::AddChannelToGroupWithResultSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
	FOnPubnubAddChannelToGroupResponse OnAddChannelToGroupResponse;
	OnAddChannelToGroupResponse.BindDynamic(this, &ASample_ChannelGroupEntity::OnAddChannelToGroupResponse);

	// Add channel to the channel group using the channel group entity
	FString Channel = TEXT("trade_chat");
	ChannelGroupEntity->AddChannelToGroupAsync(Channel, OnAddChannelToGroupResponse);
}

// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::OnAddChannelToGroupResponse(FPubnubOperationResult Result)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to add channel to group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channel successfully added to group."));
	}
}
```

### PubNub client

#### Method(s)

```cpp
PubnubClient->AddChannelToGroupAsync(
    FString Channel,
    FString ChannelGroup,
    FOnPubnubAddChannelToGroupResponse OnAddChannelToGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: `FString` | The channel to add to the channel group. |
| `ChannelGroup` *Type: `FString` | The channel group to add the channels to. |
| `OnAddChannelToGroupResponse` *Type: [FOnPubnubAddChannelToGroupResponse](#fonpubnubaddchanneltogroupresponse) | The delegate for the operation's result. You can also use a native callback of the type [FOnPubnubAddChannelToGroupResponseNative](#fonpubnubaddchanneltogroupresponsenative) to handle the result using a lambda. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"

// blueprint.3rwckkal
UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void AddChannelToGroupSample();
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::AddChannelToGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	//Add channel to a channel group
	FString Channel = TEXT("global_chat");
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->AddChannelToGroupAsync(Channel, ChannelGroup);
}
```

###### Blueprint

#### Returns

This method is void. The delegate returns the following struct:

##### FOnPubnubAddChannelToGroupResponse

Delegate type: `DECLARE_DYNAMIC_DELEGATE_OneParam`

| Parameter | Description |
| --- | --- |
| `Result`Type: [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

##### FOnPubnubAddChannelToGroupResponseNative

Native callback variant that accepts a lambda.

| Parameter | Description |
| --- | --- |
| `Result`Type: [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### Add channels to a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void AddChannelToGroupWithResultLambdaSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::AddChannelToGroupWithResultLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind lambda to response delegate
	FOnPubnubAddChannelToGroupResponseNative OnAddChannelToGroupResponse;
	OnAddChannelToGroupResponse.BindLambda([](const FPubnubOperationResult& Result)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to add channel to group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channel successfully added to group."));
		}
	});
	
	//Add channel to a channel group
	FString Channel = TEXT("guild_chat");
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->AddChannelToGroupAsync(Channel, ChannelGroup, OnAddChannelToGroupResponse);
}
```

##### Add channels to a channel group with result struct

Use the result struct to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void AddChannelToGroupWithResultSample();

UFUNCTION()
void OnAddChannelToGroupResponse(FPubnubOperationResult Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::AddChannelToGroupWithResultSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
	FOnPubnubAddChannelToGroupResponse OnAddChannelToGroupResponse;
	OnAddChannelToGroupResponse.BindDynamic(this, &ASample_Groups::OnAddChannelToGroupResponse);

	//Add channel to a channel group
	FString Channel = TEXT("trade_chat");
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->AddChannelToGroupAsync(Channel, ChannelGroup, OnAddChannelToGroupResponse);
}

// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::OnAddChannelToGroupResponse(FPubnubOperationResult Result)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to add channel to group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channel successfully added to group."));
	}
}
```

## List channels in a channel group

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on 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.
:::

This function lists all channels in the channel group. You can call `ListChannelsFromGroup()` on a [ChannelGroup entity](#list-channels-channel-group-entity) (which already knows its channel group) or directly on the [PubNub client](#list-channels-pubnub-client) by passing the channel group name explicitly.

### ChannelGroup entity

##### Available in entities

This method is available to use with the `ChannelGroup` entity. For more information, refer to [ChannelGroup](https://www.pubnub.com/docs/sdks/unreal/entities/channel-group).

#### Method(s)

```cpp
UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");

ChannelGroupEntity->ListChannelsFromGroup(
    FOnListChannelsFromGroupResponse OnListChannelsResponse
);
```

| Parameter | Description |
| --- | --- |
| `OnListChannelsResponse` *Type: [FOnListChannelsFromGroupResponse](#fonlistchannelsfromgroupresponse) | The operation result delegate. You can also use [FOnListChannelsFromGroupResponseNative](#fonlistchannelsfromgroupresponsenative) with a lambda. |

##### FOnListChannelsFromGroupResponse

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |
| `Channels` | `TArray<FString>&` | Channel names in the group. |

##### FOnListChannelsFromGroupResponseNative

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |
| `Channels` | `const TArray<FString>&` | Channel names in the group. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void ListChannelsFromGroupSample();
	
UFUNCTION()
void OnListChannelsFromGroupResponse(FPubnubOperationResult Result, const TArray<FString>& Channels);
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::ListChannelsFromGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
	FOnPubnubListChannelsFromGroupResponse OnListChannelsFromGroupResponse;
	OnListChannelsFromGroupResponse.BindDynamic(this, &ASample_ChannelGroupEntity::OnListChannelsFromGroupResponse);

	// List channels from the channel group using the channel group entity
	ChannelGroupEntity->ListChannelsFromGroupAsync(OnListChannelsFromGroupResponse);
}

// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::OnListChannelsFromGroupResponse(FPubnubOperationResult Result, const TArray<FString>& Channels)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to list channels from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channels successfully listed from group. Listed channels:"));
		for (const FString& Channel : Channels)
		{
			UE_LOG(LogTemp, Log, TEXT("- %s"), *Channel);
		}
	}
}
```

#### Returns

This function is void, but the delegate returns the [FOnListChannelsFromGroupResponse](#fonlistchannelsfromgroupresponse) struct.

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### List channels from a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void ListChannelsFromGroupWithLambdaSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::ListChannelsFromGroupWithLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind lambda to response delegate
	FOnPubnubListChannelsFromGroupResponseNative OnListChannelsFromGroupResponse;
	OnListChannelsFromGroupResponse.BindLambda([](const FPubnubOperationResult& Result, const TArray<FString>& Channels)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to list channels from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channels successfully listed from group. Listed channels:"));
			for (const FString& Channel : Channels)
			{
				UE_LOG(LogTemp, Log, TEXT("- %s"), *Channel);
			}
		}
	});
	
	// List channels from the channel group using the channel group entity
	ChannelGroupEntity->ListChannelsFromGroupAsync(OnListChannelsFromGroupResponse);
}
```

##### List channels from a channel group with result struct

Use the result struct to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void ListChannelsFromGroupSample();
	
UFUNCTION()
void OnListChannelsFromGroupResponse(FPubnubOperationResult Result, const TArray<FString>& Channels);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::ListChannelsFromGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
	FOnPubnubListChannelsFromGroupResponse OnListChannelsFromGroupResponse;
	OnListChannelsFromGroupResponse.BindDynamic(this, &ASample_ChannelGroupEntity::OnListChannelsFromGroupResponse);

	// List channels from the channel group using the channel group entity
	ChannelGroupEntity->ListChannelsFromGroupAsync(OnListChannelsFromGroupResponse);
}

// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::OnListChannelsFromGroupResponse(FPubnubOperationResult Result, const TArray<FString>& Channels)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to list channels from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channels successfully listed from group. Listed channels:"));
		for (const FString& Channel : Channels)
		{
			UE_LOG(LogTemp, Log, TEXT("- %s"), *Channel);
		}
	}
}
```

### PubNub client

#### Method(s)

```cpp
PubnubClient->ListChannelsFromGroupAsync(
    FString ChannelGroup,
    FOnPubnubListChannelsFromGroupResponse OnListChannelsResponse
);
```

| Parameter | Description |
| --- | --- |
| `ChannelGroup` *Type: `FString` | The channel group to list channels of. |
| `OnListChannelsResponse` *Type: [FOnPubnubListChannelsFromGroupResponse](#fonpubnublistchannelsfromgroupresponse) | The operation result delegate. You can also use [FOnPubnubListChannelsFromGroupResponseNative](#fonpubnublistchannelsfromgroupresponsenative) with a lambda. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"

// blueprint.saoacm0a
UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void ListChannelsFromGroupSample();
	
UFUNCTION()
void OnListChannelsFromGroupResponse(FPubnubOperationResult Result, const TArray<FString>& Channels);
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::ListChannelsFromGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
	FOnPubnubListChannelsFromGroupResponse OnListChannelsFromGroupResponse;
	OnListChannelsFromGroupResponse.BindDynamic(this, &ASample_Groups::OnListChannelsFromGroupResponse);

	//List channels from a channel group
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->ListChannelsFromGroupAsync(ChannelGroup, OnListChannelsFromGroupResponse);
}

// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::OnListChannelsFromGroupResponse(FPubnubOperationResult Result, const TArray<FString>& Channels)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to list channels from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channels successfully listed from group. Listed channels:"));
		for (const FString& Channel : Channels)
		{
			UE_LOG(LogTemp, Log, TEXT("- %s"), *Channel);
		}
	}
}
```

###### Blueprint

#### Returns

This method is void. The delegate returns the following struct:

##### FOnPubnubListChannelsFromGroupResponse

Delegate type: `DECLARE_DYNAMIC_DELEGATE_TwoParams`

| Parameter | Description |
| --- | --- |
| `Result`Type: [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |
| `Channels`Type: `const TArray<FString>&` | Channel names in the group. |

##### FOnPubnubListChannelsFromGroupResponseNative

Native callback variant that accepts a lambda.

| Parameter | Description |
| --- | --- |
| `Result`Type: [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |
| `Channels`Type: `const TArray<FString>&` | Channel names in the group. |

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### List channels from a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void ListChannelsFromGroupWithLambdaSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::ListChannelsFromGroupWithLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind lambda to response delegate
	FOnPubnubListChannelsFromGroupResponseNative OnListChannelsFromGroupResponse;
	OnListChannelsFromGroupResponse.BindLambda([](const FPubnubOperationResult& Result, const TArray<FString>& Channels)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to list channels from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channels successfully listed from group. Listed channels:"));
			for (const FString& Channel : Channels)
			{
				UE_LOG(LogTemp, Log, TEXT("- %s"), *Channel);
			}
		}
	});
	
	//List channels from a channel group
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->ListChannelsFromGroupAsync(ChannelGroup, OnListChannelsFromGroupResponse);
}
```

## Remove channels from a channel group

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on 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.
:::

This function removes channels from the channel group. You can call `RemoveChannelFromGroup()` on a [ChannelGroup entity](#remove-channels-channel-group-entity) (which already knows its channel group) or directly on the [PubNub client](#remove-channels-pubnub-client) by passing the channel group name explicitly.

### ChannelGroup entity

##### Available in entities

This method is available to use with the `ChannelGroup` entity. For more information, refer to [ChannelGroup](https://www.pubnub.com/docs/sdks/unreal/entities/channel-group).

#### Method(s)

```cpp
UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");

ChannelGroupEntity->RemoveChannelFromGroup(
    FString Channel,
    FOnRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: `FString` | The channel to remove from the channel group. |
| `OnRemoveChannelFromGroupResponse` *Type: [FOnRemoveChannelFromGroupResponse](#fonremovechannelfromgroupresponse) | The operation result delegate. You can also use [FOnRemoveChannelFromGroupResponseNative](#fonremovechannelfromgroupresponsenative) with a lambda. |

##### FOnRemoveChannelFromGroupResponse

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

##### FOnRemoveChannelFromGroupResponseNative

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void RemoveChannelFromGroupSample();
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::RemoveChannelFromGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Remove channel from the channel group using the channel group entity
	FString Channel = TEXT("global_chat");
	ChannelGroupEntity->RemoveChannelFromGroupAsync(Channel);
}
```

#### Returns

This method is void, but the delegate returns the [FOnRemoveChannelFromGroupResponse](#fonremovechannelfromgroupresponse) struct.

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### Remove channels from a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void RemoveChannelFromGroupWithResultLambdaSample();
	
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::RemoveChannelFromGroupWithResultLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind lambda to response delegate
	FOnPubnubRemoveChannelFromGroupResponseNative OnRemoveChannelFromGroupResponse;
	OnRemoveChannelFromGroupResponse.BindLambda([](const FPubnubOperationResult& Result)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to remove channel from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channel successfully removed from group."));
		}
	});
	
	// Remove channel from the channel group using the channel group entity
	FString Channel = TEXT("guild_chat");
	ChannelGroupEntity->RemoveChannelFromGroupAsync(Channel, OnRemoveChannelFromGroupResponse);
}
```

##### Remove channels from a channel group with result struct

Use the result struct to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void RemoveChannelFromGroupWithResultSample();

UFUNCTION()
void OnRemoveChannelFromGroupResponse(FPubnubOperationResult Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::RemoveChannelFromGroupWithResultSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
	FOnPubnubRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse;
	OnRemoveChannelFromGroupResponse.BindDynamic(this, &ASample_ChannelGroupEntity::OnRemoveChannelFromGroupResponse);

	// Remove channel from the channel group using the channel group entity
	FString Channel = TEXT("trade_chat");
	ChannelGroupEntity->RemoveChannelFromGroupAsync(Channel, OnRemoveChannelFromGroupResponse);
}

// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::OnRemoveChannelFromGroupResponse(FPubnubOperationResult Result)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to remove channel from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channel successfully removed from group."));
	}
}
```

### PubNub client

#### Method(s)

```cpp
PubnubClient->RemoveChannelFromGroupAsync(
    FString Channel,
    FString ChannelGroup,
    FOnPubnubRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: `FString` | The channel to remove from the channel group. |
| `ChannelGroup` *Type: `FString` | The channel group to remove the channel from. |
| `OnRemoveChannelFromGroupResponse` *Type: [FOnPubnubRemoveChannelFromGroupResponse](#fonpubnubremovechannelfromgroupresponse) | The operation result delegate. You can also use [FOnPubnubRemoveChannelFromGroupResponseNative](#fonpubnubremovechannelfromgroupresponsenative) with a lambda. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"

// blueprint.stmbdo5-
UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void RemoveChannelFromGroupSample();
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::RemoveChannelFromGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	//Remove channel from a channel group
	FString Channel = TEXT("global_chat");
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->RemoveChannelFromGroupAsync(Channel, ChannelGroup);
}
```

###### Blueprint

#### Returns

This method is void. The delegate returns the following struct:

##### FOnPubnubRemoveChannelFromGroupResponse

Delegate type: `DECLARE_DYNAMIC_DELEGATE_OneParam`

| Parameter | Description |
| --- | --- |
| `Result`Type: [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

##### FOnPubnubRemoveChannelFromGroupResponseNative

Native callback variant that accepts a lambda.

| Parameter | Description |
| --- | --- |
| `Result`Type: [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### Remove channels from a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void RemoveChannelFromGroupWithResultLambdaSample();
	
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::RemoveChannelFromGroupWithResultLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind lambda to response delegate
	FOnPubnubRemoveChannelFromGroupResponseNative OnRemoveChannelFromGroupResponse;
	OnRemoveChannelFromGroupResponse.BindLambda([](const FPubnubOperationResult& Result)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to remove channel from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channel successfully removed from group."));
		}
	});
	
	//Remove channel from a channel group
	FString Channel = TEXT("guild_chat");
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->RemoveChannelFromGroupAsync(Channel, ChannelGroup, OnRemoveChannelFromGroupResponse);
}
```

##### Remove channels from a channel group with result struct

Use the result struct to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void RemoveChannelFromGroupWithResultSample();

UFUNCTION()
void OnRemoveChannelFromGroupResponse(FPubnubOperationResult Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::RemoveChannelFromGroupWithResultSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
	FOnPubnubRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse;
	OnRemoveChannelFromGroupResponse.BindDynamic(this, &ASample_Groups::OnRemoveChannelFromGroupResponse);

	//Remove channel from a channel group
	FString Channel = TEXT("trade_chat");
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->RemoveChannelFromGroupAsync(Channel, ChannelGroup, OnRemoveChannelFromGroupResponse);
}

// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::OnRemoveChannelFromGroupResponse(FPubnubOperationResult Result)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to remove channel from group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channel successfully removed from group."));
	}
}
```

## Delete a channel group

:::note Requires Stream Controller add-on
This method requires the *Stream Controller* add-on 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.
:::

This function removes a channel group. You can call `RemoveChannelGroup()` on a [ChannelGroup entity](#delete-group-channel-group-entity) (which already knows its channel group) or directly on the [PubNub client](#delete-group-pubnub-client) by passing the channel group name explicitly.

### ChannelGroup entity

##### Available in entities

This method is available to use with the `ChannelGroup` entity. For more information, refer to [ChannelGroup](https://www.pubnub.com/docs/sdks/unreal/entities/channel-group).

#### Method(s)

```cpp
UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");

ChannelGroupEntity->RemoveChannelGroup(
    FOnRemoveChannelGroupResponse OnRemoveChannelGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `OnRemoveChannelGroupResponse` *Type: [FOnRemoveChannelGroupResponse](#fonremovechannelgroupresponse) | The operation result delegate. You can also use [FOnRemoveChannelGroupResponseNative](#fonremovechannelgroupresponsenative) with a lambda. |

##### FOnRemoveChannelGroupResponse

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

##### FOnRemoveChannelGroupResponseNative

| Field | Type | Description |
| --- | --- | --- |
| `Result` | [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void RemoveChannelGroupSample();
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::RemoveChannelGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Remove the entire channel group using the channel group entity
	ChannelGroupEntity->RemoveChannelGroupAsync();
}
```

#### Returns

This method is void, but the delegate returns the [FOnRemoveChannelGroupResponse](#fonremovechannelgroupresponse) struct.

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### Delete a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void RemoveChannelGroupWithResultLambdaSample();

	
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::RemoveChannelGroupWithResultLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind lambda to response delegate
	FOnPubnubRemoveChannelGroupResponseNative OnRemoveChannelGroupResponse;
	OnRemoveChannelGroupResponse.BindLambda([](const FPubnubOperationResult& Result)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to remove channel group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channel group successfully removed."));
		}
	});
	
	// Remove the entire channel group using the channel group entity
	ChannelGroupEntity->RemoveChannelGroupAsync(OnRemoveChannelGroupResponse);
}
```

##### Delete a channel group with result struct

Use the result struct to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"
#include "Entities/PubnubChannelGroupEntity.h"
#include "Entities/PubnubSubscription.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|ChannelGroupEntity")
void RemoveChannelGroupWithResultSample();

UFUNCTION()
void OnRemoveChannelGroupResponse(FPubnubOperationResult Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::RemoveChannelGroupWithResultSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Create a channel group entity for the group you want to work with
	FString ChannelGroupName = TEXT("all-chats");
	UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubClient->CreateChannelGroupEntity(ChannelGroupName);

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
	FOnPubnubRemoveChannelGroupResponse OnRemoveChannelGroupResponse;
	OnRemoveChannelGroupResponse.BindDynamic(this, &ASample_ChannelGroupEntity::OnRemoveChannelGroupResponse);

	// Remove the entire channel group using the channel group entity
	ChannelGroupEntity->RemoveChannelGroupAsync(OnRemoveChannelGroupResponse);
}

// ACTION REQUIRED: Replace ASample_ChannelGroupEntity with name of your Actor class
void ASample_ChannelGroupEntity::OnRemoveChannelGroupResponse(FPubnubOperationResult Result)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to remove channel group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channel group successfully removed."));
	}
}
```

### PubNub client

#### Method(s)

```cpp
PubnubClient->RemoveChannelGroupAsync(
    FString ChannelGroup,
    FOnPubnubRemoveChannelGroupResponse OnRemoveChannelGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `ChannelGroup` *Type: `FString` | The channel group to remove. |
| `OnRemoveChannelGroupResponse` *Type: [FOnPubnubRemoveChannelGroupResponse](#fonpubnubremovechannelgroupresponse) | The operation result delegate. You can also use [FOnPubnubRemoveChannelGroupResponseNative](#fonpubnubremovechannelgroupresponsenative) with a lambda. |

#### Sample code

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

###### C++

##### Actor.h

```cpp
#include "PubnubClient.h"

// blueprint.ygpybt62
UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void RemoveChannelGroupSample();
```

##### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::RemoveChannelGroupSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	//Remove a channel group
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->RemoveChannelGroupAsync(ChannelGroup);
}
```

###### Blueprint

#### Returns

This method is void. The delegate returns the following struct:

##### FOnPubnubRemoveChannelGroupResponse

Delegate type: `DECLARE_DYNAMIC_DELEGATE_OneParam`

| Parameter | Description |
| --- | --- |
| `Result`Type: [FPubnubOperationResult](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

##### FOnPubnubRemoveChannelGroupResponseNative

Native callback variant that accepts a lambda.

| Parameter | Description |
| --- | --- |
| `Result`Type: [const FPubnubOperationResult&](https://www.pubnub.com/docs/sdks/unreal/api-reference/configuration#operation-result) | The operation result. |

#### Other Examples

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

##### Delete a channel group with lambda

Use a lambda function to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void RemoveChannelGroupWithResultLambdaSample();
	
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::RemoveChannelGroupWithResultLambdaSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind lambda to response delegate
	FOnPubnubRemoveChannelGroupResponseNative OnRemoveChannelGroupResponse;
	OnRemoveChannelGroupResponse.BindLambda([](const FPubnubOperationResult& Result)
	{
		if(Result.Error)
		{
			UE_LOG(LogTemp, Error, TEXT("Failed to remove channel group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		}
		else
		{
			UE_LOG(LogTemp, Log, TEXT("Channel group successfully removed."));
		}
	});
	
	//Remove a channel group
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->RemoveChannelGroupAsync(ChannelGroup, OnRemoveChannelGroupResponse);
}
```

##### Delete a channel group with result struct

Use the result struct to handle the response:

###### Actor.h

```cpp
#include "PubnubClient.h"

UFUNCTION(BlueprintCallable, Category = "Pubnub|Samples|Channel Groups")
void RemoveChannelGroupWithResultSample();

UFUNCTION()
void OnRemoveChannelGroupResponse(FPubnubOperationResult Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::RemoveChannelGroupWithResultSample()
{
	// snippet.hide
	UPubnubClient* PubnubClient = GetPubnubClient();
	// snippet.show
	
	//Assumes PubnubClient is created and UserID is set

	// Bind response delegate
	// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
	FOnPubnubRemoveChannelGroupResponse OnRemoveChannelGroupResponse;
	OnRemoveChannelGroupResponse.BindDynamic(this, &ASample_Groups::OnRemoveChannelGroupResponse);

	//Remove a channel group
	FString ChannelGroup = TEXT("all-chats");
	PubnubClient->RemoveChannelGroupAsync(ChannelGroup, OnRemoveChannelGroupResponse);
}

// ACTION REQUIRED: Replace ASample_Groups with name of your Actor class
void ASample_Groups::OnRemoveChannelGroupResponse(FPubnubOperationResult Result)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Failed to remove channel group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channel group successfully removed."));
	}
}
```

## Complete example

:::tip Reference code
Set up your Unreal project and follow the instructions in the lines marked with
ACTION REQUIRED
before running the code.
:::

#### ASample_GroupsFull.h

```cpp
#pragma once

#include "PubnubClient.h"

#include "GameFramework/Actor.h"
#include "CoreMinimal.h"
#include "Sample_GroupsFull.generated.h"

// ACTION REQUIRED: Replace PUBNUBLIBRARYTESTS_API with your project's module API macro (usually ProjectName_API)
UCLASS()
class PUBNUBLIBRARYTESTS_API ASample_GroupsFull : public AActor
{
	GENERATED_BODY()

protected:
	virtual void BeginPlay() override;

public:

	UFUNCTION(BlueprintCallable, Category = "Pubnub|FullExamples|Channel Groups")
	void RunGroupsFullExample();

private:
	UPROPERTY()
	UPubnubClient* PubnubClient = nullptr;
	
	FString ChannelGroup = "all-chats";
	FString Channel = "global_chat";

	UFUNCTION()
	void OnAddChannelToGroupResponse(FPubnubOperationResult Result);

	UFUNCTION()
	void OnPubnubMessageReceived(FPubnubMessageData Message);

	UFUNCTION()
	void OnPublishResult(FPubnubOperationResult Result, FPubnubMessageData Message);
	
};
```

#### ASample_GroupsFull.cpp

```cpp
#include "Samples/Sample_GroupsFull.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/GameInstance.h"
#include "PubnubSubsystem.h"
#include "PubnubClient.h"

void ASample_GroupsFull::BeginPlay()
{
	Super::BeginPlay();

	//Run the example on BeginPlay
	RunGroupsFullExample();
}

void ASample_GroupsFull::RunGroupsFullExample()
{
	//Get PubnubSubsystem from GameInstance
	UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
	UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();
	
	//Create Pubnub Client using Pubnub Subsystem
	FPubnubConfig Config;
	Config.PublishKey = TEXT("demo");   //replace with your Publish Key from Admin Portal
	Config.SubscribeKey = TEXT("demo"); //replace with your Subscribe Key from Admin Portal
	Config.UserID = TEXT("Player_001");
	PubnubClient = PubnubSubsystem->CreatePubnubClient(Config);

	UE_LOG(LogTemp, Log, TEXT("Channel Groups example: Pubnub Client is created"));
	
	
	// Bind delegate for AddChannelToGroup result
	FOnPubnubAddChannelToGroupResponse OnAddChannelToGroupResponse;
	OnAddChannelToGroupResponse.BindDynamic(this, &ASample_GroupsFull::OnAddChannelToGroupResponse);

	//Add channel to the group
	PubnubClient->AddChannelToGroupAsync(Channel, ChannelGroup, OnAddChannelToGroupResponse);
}

void ASample_GroupsFull::OnAddChannelToGroupResponse(FPubnubOperationResult Result)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Groups example, failed to add channel to group. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
		return;
	}

	UE_LOG(LogTemp, Log, TEXT("Channel Groups example: channel successfully added to group."));
	
	//Subscribe to the group
	PubnubClient->OnMessageReceived.AddDynamic(this, &ASample_GroupsFull::OnPubnubMessageReceived);
	PubnubClient->SubscribeToGroupAsync(ChannelGroup);

	// NOTE: Subscribing to a group or channel may take a few seconds to complete.
	// This sleep is used to simulate the waiting period in an actual application.
	FPlatformProcess::Sleep(3);
	
	UE_LOG(LogTemp, Log, TEXT("Channel Groups example: subscribed to group: %s"), *ChannelGroup);
		
	//Publish a message to the channel (which is in the subscribed group)
	FOnPubnubPublishMessageResponse OnPublishMessageResponse;
	OnPublishMessageResponse.BindDynamic(this, &ASample_GroupsFull::OnPublishResult);
	
	FString Message = R"({"message": "Welcome to the 'all-chats' group!"})";
	PubnubClient->PublishMessageAsync(Channel, Message, OnPublishMessageResponse);

	UE_LOG(LogTemp, Log, TEXT("Channel Groups example: message published to channel: %s"), *Channel);
}

void ASample_GroupsFull::OnPubnubMessageReceived(FPubnubMessageData Message)
{
	UE_LOG(LogTemp, Log, TEXT("Channel Groups example: message received on Channel: %s, via Group: %s, Message Content: %s"), *Message.Channel, *Message.MatchOrGroup, *Message.Message);

	PubnubClient->UnsubscribeFromGroupAsync(ChannelGroup);
	
	// NOTE: Unsubscribing from a group or channel may take a few seconds to complete.
	// This sleep is used to simulate the waiting period in an actual application.
	FPlatformProcess::Sleep(3);

	UE_LOG(LogTemp, Log, TEXT("Channel Groups example: unsubscribed from group: %s"), *ChannelGroup);

	//Remove channel from the group
	PubnubClient->RemoveChannelFromGroupAsync(Channel, ChannelGroup);

	UE_LOG(LogTemp, Log, TEXT("Channel Groups example: channel removed from group"));
}

void ASample_GroupsFull::OnPublishResult(FPubnubOperationResult Result, FPubnubMessageData Message)
{
	if(Result.Error)
	{
		UE_LOG(LogTemp, Error, TEXT("Channel Groups example: failed to publish message. Status: %d, Reason: %s"), Result.Status, *Result.ErrorMessage);
	}
	else
	{
		UE_LOG(LogTemp, Log, TEXT("Channel Groups example: message published successfully. Published message timetoken: %s"), *Message.Timetoken);
	}
}
```

## Deprecated methods

### Add channels to a channel group (deprecated)

:::warning Deprecated
Use [PubnubClient->AddChannelToGroup()](#add-channels-pubnub-client) (synchronous) or [PubnubClient->AddChannelToGroupAsync()](#add-channels-pubnub-client) (asynchronous) instead.
:::

#### Method(s) (deprecated)

```cpp
PubnubSubsystem->AddChannelToGroup(
    FString Channel,
    FString ChannelGroup,
    FOnAddChannelToGroupResponse OnAddChannelToGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: `FString` | The channel to add to the channel group. |
| `ChannelGroup` *Type: `FString` | The channel group to add the channels to. |
| `OnAddChannelToGroupResponse` *Type: `FOnAddChannelToGroupResponse` | The delegate for the operation's result. |

#### Returns (deprecated)

This method doesn't return a value.

### List channels in a channel group (deprecated)

:::warning Deprecated
Use [PubnubClient->ListChannelsFromGroup()](#list-channels-pubnub-client) (synchronous) or [PubnubClient->ListChannelsFromGroupAsync()](#list-channels-pubnub-client) (asynchronous) instead.
:::

#### Method(s) (deprecated)

```cpp
PubnubSubsystem->ListChannelsFromGroup(
    FString ChannelGroup,
    FOnListChannelsFromGroupResponse OnListChannelsResponse
);
```

| Parameter | Description |
| --- | --- |
| `ChannelGroup` *Type: `FString` | The channel group to list channels of. |
| `OnListChannelsResponse` *Type: `FOnListChannelsFromGroupResponse` | The operation result delegate. |

#### Returns (deprecated)

This function is void, but the delegate returns the `FOnListChannelsFromGroupResponse` struct.

| Field | Type | Description |
| --- | --- | --- |
| `Result` | `FPubnubOperationResult` | The operation result. |
| `Channels` | `TArray<FString>&` | Channel names in the group. |

### Remove channels from a channel group (deprecated)

:::warning Deprecated
Use [PubnubClient->RemoveChannelFromGroup()](#remove-channels-pubnub-client) (synchronous) or [PubnubClient->RemoveChannelFromGroupAsync()](#remove-channels-pubnub-client) (asynchronous) instead.
:::

#### Method(s) (deprecated)

```cpp
PubnubSubsystem->RemoveChannelFromGroup(
    FString Channel,
    FString ChannelGroup,
    FOnRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: `FString` | The channel to remove from the channel group. |
| `ChannelGroup` *Type: `FString` | The channel group to remove the channel from. |
| `OnRemoveChannelFromGroupResponse` *Type: `FOnRemoveChannelFromGroupResponse` | The operation result delegate. |

#### Returns (deprecated)

This method doesn't return a value.

### Delete a channel group (deprecated)

:::warning Deprecated
Use [PubnubClient->RemoveChannelGroup()](#delete-group-pubnub-client) (synchronous) or [PubnubClient->RemoveChannelGroupAsync()](#delete-group-pubnub-client) (asynchronous) instead.
:::

#### Method(s) (deprecated)

```cpp
PubnubSubsystem->RemoveChannelGroup(
    FString ChannelGroup,
    FOnRemoveChannelGroupResponse OnRemoveChannelGroupResponse
);
```

| Parameter | Description |
| --- | --- |
| `ChannelGroup` *Type: `FString` | The channel group to remove. |
| `OnRemoveChannelGroupResponse` *Type: `FOnRemoveChannelGroupResponse` | The operation result delegate. |

#### Returns (deprecated)

This method doesn't return a value.

## Terms in this document

* **Entity** - A subscribable object within a PubNub SDK that allows you to perform context-specific operations.