---
source_url: https://www.pubnub.com/docs/sdks/unity/api-reference/objects
title: App Context API for Unity SDK
updated_at: 2026-05-27T12:44:20.128Z
sdk_name: PubNub Unity SDK
sdk_version: v9.3.0
---

> 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


# App Context API for Unity SDK

PubNub Unity SDK, use the latest version: v9.3.0

This page describes App Context (formerly Objects v2). To upgrade from Objects v1, refer to the [migration guide](https://www.pubnub.com/docs/general/resources/migration-guides/objects-v2-migration).

App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context to store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.

PubNub also triggers events when object data is changed: set, updated, or removed from the database. Making a request to set the same data that already exists doesn't trigger an event. Clients can receive these events in real time and update their front-end application accordingly.

## User

Manage UUID metadata: list, fetch, set, and remove. Include only the fields you need to reduce payload size.

### Get metadata for all users

Get a paginated list of UUID metadata. Use filters and sorting to narrow results.

:::warning Required keyset configuration
To get all channel and user metadata, you must uncheck the
Disallow Get All Channel Metadata
and
Disallow Get All User Metadata
checkboxes in the App Context section of your keyset configuration in the
[Admin Portal](https://admin.pubnub.com)
.
:::

#### Method(s)

To `Get All UUID Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.GetAllUuidMetadata()
    .IncludeCustom(bool)
    .IncludeCount(bool)
    .Page(PNPageObject)
    .Sort(List<string>)
    .Filter(string)
    .Limit(int)
    .Execute(System.Action<PNGetAllUuidMetadataResult, PNStatus>)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| IncludeCustom | bool | Optional |  | Whether to include the Custom object in the response. |
| IncludeCount | bool | Optional |  | Whether to include the total count in the paginated response. Default is false. |
| Page | PNPageObject | Optional |  | Cursor-based pagination. |
| Sort | List<string> | Optional |  | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| Filter | string | Optional |  | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| Limit | int | Optional |  | Number of objects to return. Default/Max: 100. |
| Execute | System.Action | Yes |  | `System.Action` of type `PNGetAllUuidMetadataResult`. |
| ExecuteAsync | None | Optional |  | Returns `Task<PNResult<PNGetAllUuidMetadataResult>>`. |

#### Sample code

:::tip Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
:::

```csharp
using PubnubApi;
using PubnubApi.Unity;
using UnityEngine;

public class GetAllUuidMetadataExample : MonoBehaviour {
	// Reference to a pubnub manager previously setup in Unity Editor
	// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
	[SerializeField] private PNManagerBehaviour pubnubManager;

	private async void Start() {
		// Getting a reference to the Pubnub instance
		var pubnub = pubnubManager.pubnub;

		// Note that you can also initialize Pubnub instance for Unity directly from code:
		/*
		PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
		{
			SubscribeKey = "demo",
			PublishKey = "demo",
		};
		Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
		*/

		// Fetching all UUID metadata
		var getAllUuidMetadataResponse = await pubnub.GetAllUuidMetadata()
			.IncludeCustom(true)
			.IncludeCount(true)
			.ExecuteAsync();

		// Extracting the result and status
		var getAllUuidMetadataResult = getAllUuidMetadataResponse.Result;
		var status = getAllUuidMetadataResponse.Status;

		// Handling errors and logging results
		if (status.Error) {
			Debug.LogError($"Error fetching UUID metadata: {status.ErrorData.Information}");
		} else if (getAllUuidMetadataResult?.Uuids != null) {
			Debug.Log("Successfully fetched UUID metadata:");
			foreach (var uuidMetadata in getAllUuidMetadataResult.Uuids) {
				Debug.Log($"UUID: {uuidMetadata.Uuid}, Name: {uuidMetadata.Name}");
				if (uuidMetadata.Custom != null) {
					foreach (var kvp in uuidMetadata.Custom) {
						Debug.Log($"Custom Key: {kvp.Key}, Value: {kvp.Value}");
					}
				}
			}
		}
	}
}
```

#### Response

```json
{
    "Uuids": [
        {
            "Uuid": "uuid-1",
            "Name": "John Doe",
            "Email": "jack@twitter.com",
            "ExternalId": null,
            "ProfileUrl": null,
            "Custom": null,
            "Updated": "2020-06-17T16:28:14.060718Z"
        },
        {
            "Uuid": "uuid-2",
            "Name": "Bob Cat",
            "Email": "bobc@example.com",
            "ExternalId": null,
            "ProfileUrl": null,
            "Custom": {
                "phone": "999-999-9999"
            },
            "Updated": "2020-06-17T16:42:22.906768Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MTI",
        "Prev": ""
    }
}
```

### Get user metadata

Fetch metadata for a single UUID. Include the Custom object if you need custom fields.

#### Method(s)

To `Get UUID Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.GetUuidMetadata()
    .Uuid(string)
    .IncludeCustom(bool)
    .Execute(System.Action<PNGetUuidMetadataResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Uuid` *Type: string | Unique user identifier. If not supplied then current user's `Uuid` is used. |
| `IncludeCustom`Type: bool | Whether to include the Custom object in the response. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNGetUuidMetadataResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNGetUuidMetadataResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Get Metadata for UUID set in the pubnub instance
PNResult<PNGetUuidMetadataResult> getUuidSetMetadataResponse = await pubnub.GetUuidMetadata()
    .ExecuteAsync();
PNGetUuidMetadataResult getUuidSetMetadataResult = getUuidSetMetadataResponse.Result;
PNStatus uuidSetStatus = getUuidSetMetadataResponse.Status;

// Get Metadata for a specific UUID
PNResult<PNGetUuidMetadataResult> getSpecificUuidMetadataResponse = await pubnub.GetUuidMetadata()
    .Uuid("my-uuid")
    .ExecuteAsync();
PNGetUuidMetadataResult getSpecificUuidMetadataResult = getSpecificUuidMetadataResponse.Result;
PNStatus specificUuidStatus = getSpecificUuidMetadataResponse.Status;
```

#### Response

```json
{
    "Uuid": "uuid-1",
    "Name": "John Doe",
    "Email": "jack@twitter.com",
    "ExternalId": null,
    "ProfileUrl": null,
    "Custom": null,
    "Updated": "2020-06-17T16:28:14.060718Z"
}
```

### Set user metadata

:::warning Unsupported partial updates of custom metadata
The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:
1. Get the existing metadata and store it locally.
2. Append the new custom metadata to the existing one.
3. Set the entire updated custom object.
:::

Set metadata for a UUID in the database, including the Custom object. Use the eTag to avoid overwriting concurrent updates.

#### Method(s)

To `Set UUID Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.SetUuidMetadata()
    .Uuid(string)
    .Name(string)
    .Email(string)
    .ExternalId(string)
    .ProfileUrl(string)
    .Custom(Dictionary<string, object>)
    .IncludeCustom(bool)
    .IfMatchesEtag(string)
    .Execute(System.Action<PNSetUuidMetadataResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Uuid` *Type: string | Unique user identifier. If not supplied then current user's `Uuid` is used. |
| `Name` *Type: string | Display name for the user. |
| `Email`Type: string | The user's email address. |
| `ExternalId`Type: string | User's identifier in an external system. |
| `ProfileUrl`Type: string | The URL of the user's profile picture. |
| `Custom`Type: Dictionary`<string, object>` | Custom JSON values. Can be strings, numbers, or booleans. [App Context filtering language](https://www.pubnub.com/docs/general/metadata/filtering) doesn’t support filtering by custom properties. |
| `IfMatchesEtag`Type: string | Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412. |
| `IncludeCustom`Type: bool | Whether to include the Custom object in the response. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNSetUuidMetadataResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNSetUuidMetadataResult>>`. |

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

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Set Metadata for UUID set in the pubnub instance
PNResult<PNSetUuidMetadataResult> setUuidMetadataResponse = await pubnub.SetUuidMetadata()
    .Uuid(config.Uuid)
    .Name("John Doe")
    .Email("john.doe@user.com")
    .ExecuteAsync();
PNSetUuidMetadataResult setUuidMetadataResult = setUuidMetadataResponse.Result;
PNStatus status = setUuidMetadataResponse.Status;
```

#### Response

```json
{
    "Uuid": "uuid-1",
    "Name": "John Doe",
    "Email": "jack@twitter.com",
    "ExternalId": null,
    "ProfileUrl": null,
    "Custom": null,
    "Updated": "2020-06-17T16:28:14.060718Z"
}
```

### Remove user metadata

Removes the metadata from a specified UUID.

#### Method(s)

To `Remove UUID Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.RemoveUuidMetadata()
    .Uuid(string)
```

| Parameter | Description |
| --- | --- |
| `Uuid` *Type: string | Unique user identifier. If not supplied then current user's `Uuid` is used. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNRemoveUuidMetadataResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNRemoveUuidMetadataResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Remove Metadata for UUID set in the pubnub instance
PNResult<PNRemoveUuidMetadataResult> removeUuidMetadataResponse = await pubnub.RemoveUuidMetadata()
    .ExecuteAsync();
PNRemoveUuidMetadataResult removeUuidMetadataResult = removeUuidMetadataResponse.Result;
PNStatus status = removeUuidMetadataResponse.Status;
```

#### Response

```json
{}
```

## Channel

Manage channel metadata: list, fetch, set, and remove.

### Get metadata for all channels

Get a paginated list of channel metadata. Use filters and sorting to narrow results.

:::warning Required keyset configuration
To get all channel and user metadata, you must uncheck the
Disallow Get All Channel Metadata
and
Disallow Get All User Metadata
checkboxes in the App Context section of your keyset configuration in the
[Admin Portal](https://admin.pubnub.com)
.
:::

#### Method(s)

To `Get All Channel Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.GetAllChannelMetadata()
    .IncludeCustom(bool)
    .IncludeCount(bool)
    .Page(PNPageObject)
    .Sort(List<string>)
    .Filter(string)
    .Execute(System.Action<PNGetAllChannelMetadataResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `IncludeCustom`Type: bool | Whether to include the Custom object in the response. |
| `IncludeCount`Type: bool | Whether to include the total count in the paginated response. Default is false. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Sort`Type: List`<string>` | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| `Filter`Type: string | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNGetAllChannelMetadataResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNGetAllChannelMetadataResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

PNResult<PNGetAllChannelMetadataResult> getAllChannelMetadataResponse = await pubnub.GetAllChannelMetadata()
    .IncludeCount(true)
    .IncludeCustom(true)
    .ExecuteAsync();

PNGetAllChannelMetadataResult getAllChannelMetadataResult = getAllChannelMetadataResponse.Result;
PNStatus status2 = getAllChannelMetadataResponse.Status;
```

#### Response

```json
{
    "Channels": [
        {
            "Channel": "my-channel",
            "Name": "My channel",
            "Description": "A channel that is mine",
            "Custom": null,
            "Updated": "2020-06-17T16:52:19.562469Z"
        },
        {
            "Channel": "main",
            "Name": "Main channel",
            "Description": "The main channel",
            "Custom": {
                "public": true,
                "motd": "Always check your spelling!"
            },
            "Updated": "2020-06-17T16:52:19.562469Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MTE",
        "Prev": ""
    }
}
```

### Get channel metadata

Fetch metadata for a single channel. Include the Custom object if you need custom fields.

#### Method(s)

To `Get Channel Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.GetChannelMetadata()
    .Channel(string)
    .IncludeCustom(bool)
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: string | Channel name. |
| `IncludeCustom`Type: bool | Whether to include the Custom object in the response. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNGetChannelMetadataResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNGetChannelMetadataResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Get Metadata for a specific channel
PNResult<PNGetChannelMetadataResult> getChannelMetadataResponse = await pubnub.GetChannelMetadata()
    .Channel("my-channel")
    .IncludeCustom(true)
    .ExecuteAsync();

PNGetChannelMetadataResult getChannelMetadataResult = getChannelMetadataResponse.Result;
PNStatus status = getChannelMetadataResponse.Status;
```

#### Response

```json
{
    "Channel": "my-channel",
    "Name": "My channel",
    "Description": "A channel that is mine",
    "Custom": null,
    "Updated": "2020-06-17T16:52:19.562469Z"
}
```

### Set channel metadata

:::warning Unsupported partial updates of custom metadata
The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:
1. Get the existing metadata and store it locally.
2. Append the new custom metadata to the existing one.
3. Set the entire updated custom object.
:::

Set metadata for a channel in the database, including the Custom object. Use the eTag to avoid overwriting concurrent updates.

#### Method(s)

To `Set Channel Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.SetChannelMetadata()
    .Channel(string)
    .Name(string)
    .Description(string)
    .Custom(Dictionary<string, object>)
    .IncludeCustom(bool)
    .IfMatchesEtag(string)
    .Execute(System.Action<PNSetChannelMetadataResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: string | Channel name. |
| `Name`Type: string | Name of a channel. |
| `Description`Type: string | Description of a channel. |
| `Custom`Type: Dictionary`<string, object>` | Custom JSON values. Can be strings, numbers, or booleans. [App Context filtering language](https://www.pubnub.com/docs/general/metadata/filtering) doesn’t support filtering by custom properties. |
| `IncludeCustom`Type: bool | Whether to include the Custom object in the response. |
| `IfMatchesEtag`Type: string | Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNSetChannelMetadataResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNSetChannelMetadataResult>>`. |

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

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Set Metadata for a specific channel
PNResult<PNSetChannelMetadataResult> setChannelMetadataResponse = await pubnub.SetChannelMetadata()
    .Channel("my-channel")
    .Name("John Doe")
    .Description("sample description")
    .Custom(new Dictionary<string, object>() { { "color", "blue" } })
    .IncludeCustom(true)
    .ExecuteAsync();

PNSetChannelMetadataResult setChannelMetadataResult = setChannelMetadataResponse.Result;
PNStatus status = setChannelMetadataResponse.Status;
```

#### Response

```json
{
    "Channel": "my-channel",
    "Name": "John Doe",
    "Description": "sample description",
    "Custom": {
        "color": "blue"
    },
    "Updated": "2020-06-17T16:52:19.562469Z"
}
```

#### Other examples

##### Iteratively update existing metadata

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

PNConfiguration config = new PNConfiguration(new UserId("example"))
{
    PublishKey = "demo",
    SubscribeKey = "demo",
};
Pubnub pubnub = new Pubnub(config);
string channel = "team.red";
string name = "Red Team";
string description = "The channel for Red team.";
var customField = new Dictionary<string, object>()
{
    { "visible", "team" },
};
PNResult<PNSetChannelMetadataResult> setChannelMetadataResponse = await pubnub.SetChannelMetadata()
    .Channel(channel)
    .Name(name)
    .Description(description)
    .Custom(customField)
    .ExecuteAsync();
Debug.Log("The channel has been created with name and description.\n");

// Fetch current object with custom fields
PNResult<PNGetChannelMetadataResult> currentObjectResponse = await pubnub.GetChannelMetadata()
    .Channel(channel)
    .IncludeCustom(true)
    .ExecuteAsync();
var currentObject = currentObjectResponse.Result;

// Initialize the custom field dictionary
Dictionary<string, object> custom = currentObject?.Custom ?? new Dictionary<string, object>();

// Add or update the field
custom["edit"] = "admin";

// Writing the updated object back to the server
try
{
    setChannelMetadataResponse = await pubnub.SetChannelMetadata()
        .Channel(channel)
        .Custom(custom)
        .Name(currentObject?.Name)
        .Description(currentObject?.Description)
        .ExecuteAsync();
    Debug.Log($"Object has been updated.\n {setChannelMetadataResponse.Result}");
}
catch (Exception ex)
{
    Debug.Log(ex.Message);
}
```

### Remove channel metadata

Removes the metadata from a specified channel.

#### Method(s)

To `Remove Channel Metadata` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.RemoveChannelMetadata()
    .Channel(string)
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: string | Channel name. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNRemoveChannelMetadataResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNRemoveChannelMetadataResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Delete Metadata for a specific channel
PNResult<PNRemoveChannelMetadataResult> removeChannelMetadataResponse = await pubnub.RemoveChannelMetadata()
    .Channel("mychannel")
    .ExecuteAsync();

PNRemoveChannelMetadataResult removeChannelMetadataResult = removeChannelMetadataResponse.Result;
PNStatus status = removeChannelMetadataResponse.Status;
```

#### Response

```json
{}
```

## Channel memberships

Manage the channels a UUID belongs to: list, set, remove, and manage in bulk.

### Get channel memberships

List channel memberships for a UUID. This doesn't return subscriptions.

#### Method(s)

To `Get Memberships` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.GetMemberships()
    .Uuid(string)
    .Include(PNMembershipField[])
    .IncludeCount(bool)
    .Page(PNPageObject)
    .Execute(System.Action<PNGetMembershipsResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Uuid` *Type: string | Unique user identifier. If not supplied then current user's `Uuid` is used. |
| `Include`Type: PNMembershipField[] | Whether to include additional fields. |
| `IncludeCount`Type: bool | Whether to include the total count in the paginated response. Default is false. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNGetMembershipsResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNGetMembershipsResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

PNResult<PNMembershipsResult> getMembershipsResponse = await pubnub.GetMemberships()
    .Uuid("my-uuid")
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .Page(new PNPageObject() { Next = "", Prev = "" })
    .ExecuteAsync();

PNMembershipsResult getMembeshipsResult = getMembershipsResponse.Result;
PNStatus status = getMembershipsResponse.Status;
```

#### Response

```json
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}
```

### Set channel memberships

Replace or add memberships for a UUID. Provide channels (optionally with custom data).

#### Method(s)

To `Set Memberships` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.SetMemberships()
    .Uuid(string)
    .Channels(List<PNMembership>)
    .Include(PNMembershipField[])
    .IncludeCount(bool)
    .Page(PNPageObject)
    .Sort(List<string>)
    .Filter(string)
    .Limit(int)
    .Execute(System.Action<PNMembershipsResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Uuid` *Type: string | Unique user identifier. If not supplied then current user's `Uuid` is used. |
| `Channels` *Type: [List<PNMembership>](#pnmembership) | List of memberships to set. Accepts channel names or PNMembership objects (with optional custom data). |
| `Include`Type: PNMembershipField[] | Whether to include additional fields. |
| `IncludeCount`Type: bool | Whether to include the total count in the paginated response. Default is false. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Sort`Type: List`<string>` | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| `Filter`Type: string | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `Limit`Type: int | Number of objects to return. Default/Max: 100. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNMembershipsResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNMembershipsResult>>`. |

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

#### PNMembership

| Property | Description |
| --- | --- |
| `Channel` *Type: `string` | The name of the channel associated with this membership. |
| `Custom`Type: `Dictionary<string, object>` | A dictionary that stores custom metadata related to the membership, allowing for additional context or information. |
| `Status`Type: `string` | The status of the membership, for example: "active" or "inactive" |
| `Type`Type: `string` | The type of membership for categorization purposes. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

List<PNMembership> setMembershipChannelMetadataIdList =
 new() {
  new PNMembership()
   { Channel = "my-channel", Custom = new Dictionary<string, object>() { { "item", "book" } } }
 };

PNResult<PNMembershipsResult> setMembershipsResponse = await pubnub.SetMemberships()
    .Uuid("my-uuid")
    .Channels(setMembershipChannelMetadataIdList)
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNMembershipsResult setMembershipsResult = setMembershipsResponse.Result;
PNStatus status = setMembershipsResponse.Status;
```

#### Response

```json
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}
```

### Remove channel memberships

Remove memberships for a UUID. Provide the channels to remove.

#### Method(s)

To `Remove Memberships` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.RemoveMemberships()
    .Uuid(string)
    .Channels(List<string>)
    .Include(PNMembershipField[])
    .IncludeCount(bool)
    .Page(PNPageObject)
    .Sort(List<string>)
    .Filter(string)
    .Limit(int)
    .Execute(System.Action<PNMembershipsResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Uuid`Type: String | Unique user identifier. If not supplied then current user's `Uuid` is used. |
| `Channels` *Type: List`<string>` | Channels to remove from membership. |
| `Include`Type: PNMembershipField[] | Whether to include additional fields. |
| `IncludeCount`Type: bool | Whether to include the total count in the paginated response. Default is false. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Sort`Type: List`<string>` | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| `Filter`Type: string | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `Limit`Type: int | Number of objects to return. Default/Max: 100. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNMembershipsResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNMembershipsResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

List<string> removeMembershipList =
 new() {
  "my-channel",
  "your-channel"
 };

PNResult<PNMembershipsResult> removeMembershipsResponse = await pubnub.RemoveMemberships()
    .Uuid("uuid")
    .Channels(removeMembershipList)
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNMembershipsResult removeMembershipsResult = removeMembershipsResponse.Result;
PNStatus status2 = removeMembershipsResponse.Status;
```

#### Response

```json
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}
```

### Manage channel memberships

Add and remove memberships for a UUID in one request.

#### Method(s)

To `Manage Memberships` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.ManageMemberships()
    .Uuid(string)
    .Set(List<PNMembership>)
    .Remove(List<string>)
    .Include(PNMembershipField[])
    .IncludeCount(bool)
    .Page(PNPageObject)
    .Sort(List<string>)
    .Execute(System.Action<PNMembership, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Uuid` *Type: string | Unique user identifier. If not supplied then current user's `Uuid` is used. |
| `Set`Type: [List<PNMembership>](#pnmembership) | Set channel memberships for the user. |
| `Remove`Type: List`<string>` | Remove channel memberships for the user. |
| `Include`Type: PNMembershipField[] | Whether to include additional fields. |
| `IncludeCount`Type: bool | Whether to include the total count in the paginated response. Default is false. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Sort`Type: List`<string>` | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNMembership`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNMembership>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

List<PNMembership> setMembrshipList =
 new() {
  new PNMembership()
   { Channel = "ch1", Custom = new Dictionary<string, object>() { { "say", "hello" } } },
  new PNMembership()
   { Channel = "ch2", Custom = new Dictionary<string, object>() { { "say", "world" } } },
  new PNMembership() { Channel = "ch3", Custom = new Dictionary<string, object>() { { "say", "bye" } } }
 };

List<string> removeMembrshipList = new() { "ch4" };

PNResult<PNMembershipsResult> manageMmbrshipsResponse = await pubnub.ManageMemberships()
    .Uuid("my-uuid")
    .Set(setMembrshipList)
    .Remove(removeMembrshipList)
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .Page(new PNPageObject() { Next = "", Prev = "" })
    .Sort(new List<string>() { "channel.id:asc" })
    .ExecuteAsync();

PNMembershipsResult manageMmbrshipsResult = manageMmbrshipsResponse.Result;
PNStatus status = manageMmbrshipsResponse.Status;
```

#### Response

```json
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}
```

## Channel members

Manage the users in a channel: list, set, and remove.

### Get channel members

List users in a channel. Include user metadata if needed.

#### Method(s)

To `Get Channel Members` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.GetChannelMembers()
    .Channel(string)
    .Include(PNChannelMemberField[])
    .IncludeCount(bool)
    .Page(PNPageObject)
    .Sort(List<string>)
    .Filter(string)
    .Limit(int)
    .Execute(System.Action<PNChannelMembersResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: string | Channel name. |
| `Include`Type: PNChannelMemberField[] | Whether to include additional fields. |
| `IncludeCount`Type: bool | Whether to include the total count in the paginated response. Default is false. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Sort`Type: List`<string>` | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| `Filter`Type: string | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `Limit`Type: int | Number of objects to return. Default/Max: 100. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNChannelMembersResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNChannelMembersResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Get Members (uuids) for a specific channel
PNResult<PNChannelMembersResult> getChannelMembersResponse = await pubnub.GetChannelMembers()
    .Channel("my-channel")
    .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNChannelMembersResult getChannelMembersResult = getChannelMembersResponse.Result;
PNStatus status2 = getChannelMembersResponse.Status;
```

#### Response

```json
{
    "ChannelMembers": [
        {
            "UuidMetadata": {
                "Uuid": "uuid-1",
                "Name": "John Doe",
                "Email": "jack@twitter.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": null,
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": {
                "role": "admin"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "UuidMetadata": {
                "Uuid": "uuid-2",
                "Name": "Bob Cat",
                "Email": "bobc@example.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": {
                    "phone": "999-999-9999"
                },
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": null,
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}
```

### Set channel members

Set users in a channel. Provide UUIDs (optionally with custom data).

#### Method(s)

To `Set Channel Members` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.SetChannelMembers()
    .Channel(string)
    .Uuids(List<PNChannelMember>)
    .Include(PNChannelMemberField[])
    .Page(PNPageObject)
    .Sort(List<string>)
    .Filter(string)
    .Limit(int)
    .Execute(System.Action<PNChannelMembersResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: String | Channel name. |
| `Uuids` *Type: List`<PNChannelMember>` | List of members to add to the `channel`. List can contain strings (Uuids only) or objects (which can include custom data). |
| `Include`Type: PNChannelMemberField[] | Whether to include additional fields. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Sort`Type: List`<string>` | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| `Filter`Type: string | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `Limit`Type: int | Number of objects to return. Default/Max: 100. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNChannelMembersResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNChannelMembersResult>>`. |

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

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Add Members (UUID) for a specific channel
List<PNChannelMember> setMemberChannelList =
 new() {
  new PNChannelMember()
   { Uuid = "my-uuid", Custom = new Dictionary<string, object>() { { "planet", "earth" } } }
 };

PNResult<PNChannelMembersResult> setChannelMembersResponse = await pubnub.SetChannelMembers()
    .Channel("my-channel")
    .Uuids(setMemberChannelList)
    .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNChannelMembersResult setChannelMembersResult = setChannelMembersResponse.Result;
PNStatus status2 = setChannelMembersResponse.Status;
```

#### Response

```json
{
    "ChannelMembers": [
        {
            "UuidMetadata": {
                "Uuid": "uuid-1",
                "Name": "John Doe",
                "Email": "jack@twitter.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": null,
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": {
                "role": "admin"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "UuidMetadata": {
                "Uuid": "uuid-2",
                "Name": "Bob Cat",
                "Email": "bobc@example.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": {
                    "phone": "999-999-9999"
                },
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": null,
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}
```

### Remove channel members

Remove users from a channel. Provide the UUIDs to remove.

#### Method(s)

To `Remove Channel Members` you can use the following method(s) in the Unity SDK:

```csharp
pubnub.RemoveChannelMembers()
    .Channel(string)
    .Uuids(List)
    .Include(PNChannelMembersInclude[])
    .IncludeCount(bool)
    .Page(PnPageObject)
    .Sort(List)
    .Filter(string)
    .Limit(int)
    .Execute(System.Action<PNChannelMembersResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `Channel` *Type: string | Channel name. |
| `Uuids` *Type: List`<string>` | Members to remove from channel. |
| `Include`Type: PNChannelMemberField[] | Whether to include additional fields. |
| `IncludeCount`Type: bool | Whether to include the total count in the paginated response. Default is false. |
| `Page`Type: PNPageObject | Cursor-based pagination. |
| `Sort`Type: List`<string>` | Sort by `id`, `name`, `updated` with `asc`/`desc` (for example, `{name: 'asc'}`). |
| `Filter`Type: string | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `Limit`Type: int | Number of objects to return. Default/Max: 100. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNChannelMembersResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNChannelMembersResult>>`. |

#### Sample code

```csharp
using PubnubApi;
using PubnubApi.Unity;

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

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// Remove Members (UUID) for a specific channel
List<string> removeChannelMemberList =
 new() {
  "my-uuid",
  "your-uuid"
 };

PNResult<PNChannelMembersResult> removeChannelMembersResponse = await pubnub.RemoveChannelMembers()
    .Channel("my-channel")
    .Uuids(removeChannelMemberList)
    .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNChannelMembersResult removeChannelMembersResult = removeChannelMembersResponse.Result;
PNStatus status = removeChannelMembersResponse.Status;
```

#### Response

```json
{
    "ChannelMembers": [
        {
            "UuidMetadata": {
                "Uuid": "uuid-1",
                "Name": "John Doe",
                "Email": "jack@twitter.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": null,
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": {
                "role": "admin"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "UuidMetadata": {
                "Uuid": "uuid-2",
                "Name": "Bob Cat",
                "Email": "bobc@example.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": {
                    "phone": "999-999-9999"
                },
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": null,
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}
```

## 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.
* **Channel pattern** - A way to group and analyze channel data to track performance metrics like message counts and user engagement over time with PubNub Insights.
* **User** - An individual or entity that interacts with a system, application, or service. In PubNub, a user typically refers to someone who sends or receives messages through the platform, identified by a unique user ID or username.
* **User ID** - UTF-8 encoded, unique string of up to 92 characters used to identify a single client (end user, device, or server) that connects to PubNub.