---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/create
title: Create channels
updated_at: 2026-05-25T11:25:50.026Z
---

> 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


# Create channels

:::tip Channel naming
Before creating channels, take the time to carefully plan your [naming strategy](https://www.pubnub.com/docs/general/channels/channel-naming). Stick to consistent naming conventions and structure your channels thoughtfully. This preparation helps you avoid increased complexity, performance bottlenecks, and scalability issues, ensuring your app remains manageable and efficient as it grows.
:::

Create channels ([Channel](https://www.pubnub.com/docs/chat/unity-chat-sdk/learn/chat-entities/channel) objects) of one of these types:

* [Direct (1:1)](#create-direct-channel)
* [Group](#create-group-channel)
* [Public](#create-public-channel)

:::note Requires App Context
To store data about channels, you must [enable App Context](https://youtu.be/9UEoSlngpYI) for your app's keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

:::warning No support for channel groups
Chat SDKs don't support channel groups. We recommend using a [Core SDK](https://www.pubnub.com/docs/sdks) to manage [channel groups](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups).
:::

## Create direct channel

Direct channels enable private 1:1 conversations. Use cases include personal conversations and professional collaboration.

`CreateDirectConversation()` performs these actions:

1. Creates a channel with the `direct` type
2. Sets [channel membership](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership) for the channel owner
3. [Invites](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/invite#invite-one-user) the other user and creates a membership with a `"pending"` status (generates an [invite event](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/custom-events#events-for-channel-initations))

If a conversation between the two users already exists, the method returns that existing channel.

:::note Receive messages
Call [Connect()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/watch) to start receiving messages on the channel.
:::

### Method signature

This method takes the following parameters:

```csharp
chat.CreateDirectConversation(
    User user,
    string channelId = "",
    ChatChannelData? channelData = null,
    ChatMembershipData? hostMembershipData = null,
    ChatMembershipData? inviteeMembershipData = null)

public class ChatChannelData
{
    public string Name { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
    public Dictionary<string, object> CustomData { get; set; } = new ();
    public string Updated { get; internal set; } = string.Empty;
    public string Status { get; set; } = string.Empty;
    public string Type { get; set; } = string.Empty;
}
```

#### Input

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| user | User | Yes |  | User that you invite to join a channel. |
| channelId | string | Optional | `Guid.NewGuid()` | ID of the direct channel. If no value is provided a random `Guid()` will be generated and set as the Channel ID. |
| channelData | ChatChannelData | Optional | `null` | Information about the channel. |
| > Name | string | Optional | `string.Empty` | Display name for the channel. |
| > Description | string | Optional | `string.Empty` | Additional details about the channel. |
| > CustomData | Dictionary<string, | Optional | `new ()` | Any custom properties or metadata associated with the channel. |
| > Updated | string | Optional | `string.Empty` | Timestamp indicating when the channel was last updated or modified. |
| > Status | string | Optional | `string.Empty` | Current status of the channel, such as `online`, `offline`, or `archived`. |
| > Type | string | Optional | `string.Empty` | Type of the channel, like `direct`. |
| hostMembershipData | ChatMembershipData | Optional | `null` | Custom membership data for the channel creator (host). |
| inviteeMembershipData | ChatMembershipData | Optional | `null` | Custom membership data for the invited user. |

:::tip API limits
To learn about the maximum length of parameters used to set channel metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-channel-metadata).
:::

#### Output

This method returns a `Task<ChatOperationResult<CreatedChannelWrapper>>` with the following data:

| Parameter | Description |
| --- | --- |
| `CreatedChannel`Type: [Channel](https://www.pubnub.com/docs/chat/unity-chat-sdk/learn/chat-entities/channel) | Returned object containing the updated channel metadata. |
| `HostMembership`Type: [Membership](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership) | Returned object containing the updated host (channel owner) metadata. |
| `InviteesMemberships`Type: `List<Membership>` | Single-item list containing the updated data of the invited user. |

### Sample code

Invite `agent-007` to a 1:1 conversation to talk about `customer XYZ`.

```csharp
using System.Collections.Generic;
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
var user = await chat.GetUser("agent-007");
if (user.Error)
{
    Debug.Log("Couldn't find user!");
    return;
}

string channelId = "direct.agent-001&agent-007"; 
ChatChannelData channelData = new ChatChannelData
{
    Name = "Customer XYZ Discussion",
    Description = "Conversation about customer XYZ",
    CustomData = new Dictionary<string, object>(),
    Status = "active",
    Type = "direct"    
};

// Call the method to create the direct conversation
var result = await chat.CreateDirectConversation(user.Result, channelId, channelData);
```

## Create group channel

Group channels enable multi-user conversations for team collaboration and community building. Access requires an invitation.

`CreateGroupConversation()` performs these actions:

1. Creates a channel with the `group` type
2. Sets channel membership for the channel owner
3. [Invites](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/invite#invite-multiple-users) other users to join and creates memberships with a `"pending"` status

:::note Receive messages
Call [Connect()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/watch) to start receiving messages on the channel.
:::

### Method signature

This method takes the following parameters:

```csharp
chat.CreateGroupConversation(
    List<User> users,
    string channelId = "",
    ChatChannelData? channelData = null,
    ChatMembershipData? hostMembershipData = null,
    List<ChatMembershipData>? inviteesMembershipData = null)

public class ChatChannelData
{
    public string Name { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
    public Dictionary<string, object> CustomData { get; set; } = new ();
    public string Updated { get; internal set; } = string.Empty;
    public string Status { get; set; } = string.Empty;
    public string Type { get; set; } = string.Empty;
}
```

#### Input

| Parameter | Description |
| --- | --- |
| `users` *Type: `List<User>`Default: n/a | List of users that you invite to join a channel. You can invite a maximum number of 100 users at once as this is the limitation set by the [App Context API](https://www.pubnub.com/docs/sdks/unity/api-reference/objects#set-channel-memberships) that the `InviteMultiple()` method calls. |
| `channelId`Type: `string`Default: `Guid.NewGuid()` | ID of the group channel. If no value is provided a random `Guid()` will be generated and set as the Channel ID. |
| `channelData`Type: `ChatChannelData`Default: `null` | Information about the channel. |
| `> Name`Type: `string`Default: `string.Empty` | Display name for the channel. |
| `> Description`Type: `string`Default: `string.Empty` | Additional details about the channel. |
| `> CustomData`Type: `Dictionary<string, object>`Default: `new ()` | Any custom properties or metadata associated with the channel. |
| `> Updated`Type: `string`Default: `string.Empty` | Timestamp indicating when the channel was last updated or modified. |
| `> Status`Type: `string`Default: `string.Empty` | Current status of the channel, such as `online`, `offline`, or `archived`. |
| `> Type`Type: `string`Default: `string.Empty` | Type of the channel, like `group`. |
| `hostMembershipData`Type: `ChatMembershipData`Default: `null` | Custom membership data for the channel creator (host). |
| `inviteesMembershipData`Type: `List<ChatMembershipData>`Default: `null` | List of custom membership data objects for the invited users, corresponding to each user in the `users` list. |

:::tip API limits
To learn about the maximum length of parameters used to set channel metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-channel-metadata).
:::

#### Output

This method returns a `Task<ChatOperationResult<CreatedChannelWrapper>>` with the following data:

| Parameter | Description |
| --- | --- |
| `CreatedChannel`Type: `Channel` | Returned object containing the updated channel metadata. |
| `HostMembership`Type: `Membership` | Returned object containing the updated host (channel owner) data. |
| `InviteesMemberships`Type: `List<Membership>` | Returned object containing the updated metadata of the invited users. |

### Sample code

Create a group conversation and invite `agent-007` and `agent-008` to have weekly syncs on `customer XYZ`.

```csharp
using System.Collections.Generic;
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// reference both agents you want to talk to
var user1Result = await chat.GetUser("agent-007");
if (user1Result.Error)
{
    Debug.Log("Couldn't find first user!");
    return;
}
var user2Result = await chat.GetUser("agent-008");
if (user2Result.Error)
{
    Debug.Log("Couldn't find second user!");
    return;
}

List<User> users = new List<User> { user1Result.Result, user2Result.Result };

// Define the channel's ID and details via ChatChannelData
string channelId = "group-chat-1";  // Optional, can be auto-generated
ChatChannelData channelData = new ChatChannelData
{
    Name = "Weekly syncs on customer XYZ",
    Description = "Discussion about customer XYZ",
    CustomData = new Dictionary<string, object>() { { "purpose", "premium-support" } },
    Status = "active", 
    Type = "group" 
};

// Call the method to create the group conversation
var result = await chat.CreateGroupConversation(users, channelId, channelData);
```

## Create public channel

Public channels are open to anyone without invitation. Use cases include Q&A forums, knowledge sharing, and live event chat.

:::warning Supported features
Public channels do not support [typing indicators](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/typing-indicator) or [read receipts](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/read-receipts). These features are impractical for large audiences.
:::

`CreatePublicConversation()` creates a channel with the `public` type and the specified metadata.

:::note Receive messages
Call [Connect()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/watch) to start receiving messages on the channel.
:::

### Method signature

This method takes the following parameters:

```csharp
chat.CreatePublicConversation(
    string channelId = "", 
    ChatChannelData? additionalData = null
)

public class ChatChannelData
{
    public string Name { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
    public Dictionary<string, object> CustomData { get; set; } = new ();
    public string Updated { get; internal set; } = string.Empty;
    public string Status { get; set; } = string.Empty;
    public string Type { get; set; } = string.Empty;
}
```

#### Input

| Parameter | Description |
| --- | --- |
| `channelId`Type: `string`Default: `Guid.NewGuid()` | ID of the group channel. If no value is provided a random `Guid()` will be generated and set as the Channel ID. |
| `additionalData`Type: `ChatChannelData`Default: `null` | Information about the channel. |
| `> Name`Type: `string`Default: `string.Empty` | Display name for the channel. |
| `> Description`Type: `string`Default: `string.Empty` | Additional details about the channel. |
| `> CustomData`Type: `Dictionary<string, object>`Default: `new ()` | Any custom properties or metadata associated with the channel. |
| `> Updated`Type: `string`Default: `string.Empty` | Timestamp indicating when the channel was last updated or modified. |
| `> Status`Type: `string`Default: n/a | Current status of the channel, such as `online`, `offline`, or `archived`. |
| `> Type`Type: `string`Default: n/a | Type of the channel, like `public`. |

:::tip API limits
To learn about the maximum length of parameters used to set channel metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-channel-metadata).
:::

#### Output

| Type | Description |
| --- | --- |
| `Task<ChatOperationResult<Channel>>` | Async task with the created Channel object. |

### Sample code

Create a public `ask-support` channel.

```csharp
using System.Collections.Generic;
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
ChatChannelData additionalData = new ChatChannelData
{
    Name = "Support channel",
    Description = "Discussion about support for all suers",
    Status = "active", 
    Type = "public" 
};

var publicConversation = await chat.CreatePublicConversation("ask-support", additionalData);
```