---
source_url: https://www.pubnub.com/docs/sdks/dart/api-reference/objects
title: App Context API for Dart SDK
updated_at: 2026-06-04T11:11:38.003Z
sdk_name: PubNub Dart SDK
sdk_version: 7.1.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 Dart SDK

PubNub Dart SDK, use the latest version: 7.1.0

Install:

```bash
dart pub add pubnub@7.1.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 set or removed from the database. Clients can receive these events in real time and update their front-end application accordingly.

## User

### Get metadata for all users

Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.

:::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 Dart SDK:

```dart
pubnub.objects.getAllUUIDMetadata(
  {bool? includeCustomFields,
  int? limit,
  String? start,
  String? end,
  bool? includeCount,
  bool includeStatus,
  bool includeType,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
) 
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| includeCustomFields | bool | Optional | `false` | Whether to include the Custom object in the response. |
| limit | int | Optional | `100` | Number of objects to return. Default/Max: 100. |
| start | String | Optional |  | Cursor-based pagination. |
| end | String | Optional |  | Cursor-based pagination. |
| includeCount | bool | Optional | `true` | Whether to include the total count in the paginated response. Default is false. |
| includeStatus | bool | Optional | `true` | Whether to include the `status` object in the response. |
| includeType | bool | Optional | `true` | Whether to include the `type` object in the response. |
| filter | String | Optional | `null` | Filter expression. Only matching objects are returned. See [filtering guide](https://www.pubnub.com/docs/general/metadata/filtering). |
| sort | Set<String> | Optional |  | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| keyset | Keyset | Optional |  | Override for the PubNub default keyset configuration. |
| using | String | Optional |  | Keyset name from the `keysetStore` to be used for this method call. |

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

```dart
import 'package:pubnub/pubnub.dart';

void main() async {
  // Create PubNub instance with default keyset.
  var pubnub = PubNub(
    defaultKeyset: Keyset(
      subscribeKey: 'demo',
      publishKey: 'demo',
      userId: UserId('myUniqueUserId'),
    ),
  );

  // Get metadata for all users
  try {
    var result = await pubnub.objects.getAllUUIDMetadata(
      includeCustomFields: true,
      limit: 20,
    );

    // Print the result
    for (var metadata in result.data) {
      print('UUID: ${metadata.id}, Name: ${metadata.name}');
    }
  } catch (e) {
    print('Failed to get all UUID metadata: $e');
  }
}
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "id": "uuid-1",
            "name": "John Doe",
            "externalId": null,
            "profileUrl": null,
            "email": "johndoe@pubnub.com",
            "custom": null,
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
        },
        {
            "id": "uuid-2",
            "name": "Bob Cat",
            "externalId": null,
            "profileUrl": null,
            "email": "bobc@example.com",
            "custom": {
                "phone": "999-999-9999"
            },
            "updated": "2019-02-21T03:29:00.173452",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        }
    ]
}
```

### Get user metadata

Returns metadata for the specified UUID, optionally including the custom data object for each.

#### Method(s)

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

```dart
pubnub.objects.getUUIDMetadata(
  {String? uuid,
  Keyset? keyset,
  String? using,
  bool? includeCustomFields,
  bool includeStatus,
  bool includeType
  }
) 
```

| Parameter | Description |
| --- | --- |
| `uuid`Type: `String`Default: defaultKeyset UUID | The UUID to get the metadata for. If not supplied, the UUID from configuration will be used. |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |

#### Sample code

```dart
var result = await pubnub.objects.getUUIDMetadata();
```

#### Response

```json
{
    "status": 200,
    "data": {
        "id": "uuid-1",
        "name": "John Doe",
        "externalId": null,
        "profileUrl": null,
        "email": "johndoe@pubnub.com",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
    }
}
```

### 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, optionally including the custom data object for each.

#### Method(s)

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

```dart
pubnub.objects.setUUIDMetadata(
  UuidMetadataInput uuidMetadataInput,
  {String? uuid,
  bool? includeCustomFields,
  bool includeStatus,
  bool includeType,
  String? ifMatchesEtag,
  Keyset? keyset,
  String? using}
)

class UuidMetadataInput {
  String? name;
  String? email;
  dynamic custom;
  String? externalId;
  String? profileUrl;
  String? status;
  String? type;
}
```

| Parameter | Description |
| --- | --- |
| `uuidMetadataInput` *Type: [UuidMetadataInput](https://pub.dev/documentation/pubnub/latest/pubnub/UuidMetadataInput-class.html)Default: n/a | UUID metadata details. [App Context filtering language](https://www.pubnub.com/docs/general/metadata/filtering) doesn’t support filtering by custom properties. |
| `uuid`Type: `String`Default: defaultKeyset UUID | UUID to set the metadata to. If not supplied, the UUID from configuration will be used. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `ifMatchesEtag`Type: String?Default: n/a | 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. |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

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

```dart
var uuidMetadataInput = UuidMetadataInput(
    name: 'foo',
    email: 'foo@example.domain',
    profileUrl: 'http://sample.com');
var result = await pubnub.objects.setUUIDMetadata(uuidMetadataInput);
```

#### Response

```json
{
    "status": 200,
    "data": {
        "id": "uuid-1",
        "name": "John Doe",
        "externalId": null,
        "profileUrl": null,
        "email": "johndoe@pubnub.com",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
    }
}
```

### 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 Dart SDK:

```dart
pubnub.objects.removeUUIDMetadata(
  {String? uuid,
  Keyset? keyset,
  String? using}
) 
```

| Parameter | Description |
| --- | --- |
| `uuid`Type: `String` | Unique UUID Metadata identifier. If not supplied, the UUID from configuration will be used. |
| `keyset`Type: `Keyset` | Override for the PubNub default keyset configuration. |
| `using`Type: `String` | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
var result = await pubnub.objects.removeUUIDMetadata();
```

#### Response

The `removeUUIDMetadata()` returns `RemoveUuidMetadataResult` which does not have actionable data. In case of an error, an exception with error details is thrown.

## Channel

### Get metadata for all channels

Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

:::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 Dart SDK:

```dart
pubnub.objects.getAllChannelMetadata(
  {int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeCount,
  bool includeStatus,
  bool includeType,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
)
```

| Parameter | Description |
| --- | --- |
| `limit`Type: `int`Default: 100 | The number of objects to retrieve at a time. |
| `start`Type: `String`Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
| `end`Type: `String`Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the `start` parameter is supplied. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeCount`Type: `bool`Default: `true` | Whether to include the total count in the paginated response. Default is false. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `filter`Type: `String`Default: `null` | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
var result = await pubnub.objects.getAllChannelMetadata();
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "id": "my-channel",
            "name": "My channel",
            "description": "A channel that is mine",
            "custom": null,
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
        },
        {
            "id": "main",
            "name": "Main channel",
            "description": "The main channel",
            "custom": {
                "public": true,
                "motd": "Always check your spelling!"
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
        }
    ],
    "totalCount": 9,
    "next": "MUIwQTAwMUItQkRBRC00NDkyLTgyMEMtODg2OUU1N0REMTNBCg==",
    "prev": "M0FFODRENzMtNjY2Qy00RUExLTk4QzktNkY1Q0I2MUJFNDRCCg=="
}
```

### Get channel metadata

Returns metadata for the specified Channel, optionally including the custom data object for each.

#### Method(s)

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

```dart
pubnub.objects.getChannelMetadata(
  String channelId,
  {Keyset? keyset,
  String? using,
  bool? includeCustomFields
  bool includeStatus,
  bool includeType}
) 
```

| Parameter | Description |
| --- | --- |
| `channelId` *Type: `String`Default: n/a | Channel name. |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |

#### Sample code

```dart
var channelMetadata = await pubnub.objects.getChannelMetadata('my_channel');
```

#### Response

```json
{
    "status": 200,
    "data": {
        "id": "my-channel",
        "name": "My channel",
        "description": "A channel that is mine",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
    }
}
```

### 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, optionally including the custom data object for each.

#### Method(s)

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

```dart
pubnub.objects.setChannelMetadata(
  String channelId,
  ChannelMetadataInput channelMetadataInput,
  {bool? includeCustomFields,
  bool includeStatus,
  bool includeType,
  String? ifMatchesEtag,
  Keyset? keyset,
  String? using}
) 

class ChannelMetadataInput {
  String? name;
  String? description;
  dynamic custom;
  String? status;
  String? type;
}
```

| Parameter | Description |
| --- | --- |
| `channelId` *Type: `String`Default: n/a | Channel name. |
| `channelMetadataInput` *Type: [ChannelMetadataInput](https://pub.dev/documentation/pubnub/latest/pubnub/ChannelMetadataInput-class.html)Default: n/a | Channel metadata details. [Filtering](https://www.pubnub.com/docs/general/metadata/filtering) by `Custom` isn’t supported. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the `Custom` field in the fetch response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `ifMatchesEtag`Type: String?Default: n/a | 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. |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

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

```dart
var channelMetadataInput = ChannelMetadataInput(
    name: 'Channel name', description: 'A channel that is mine');
    
var result = await pubnub.objects
    .setChannelMetadata('my_channel', channelMetadataInput);
```

#### Response

```json
{
    "status": 200,
    "data": {
        "id": "my-channel",
        "name": "My channel",
        "description": "A channel that is mine",
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
    }
}
```

#### Other examples

##### Iteratively update existing metadata

```dart
import 'dart:async';
import 'package:pubnub/pubnub.dart';
Future<void> main() async {
  var keyset = Keyset(
      publishKey: 'demo',
      subscribeKey: 'demo',
      userId: const UserId('example'));
  var pubnub = PubNub(defaultKeyset: keyset);
  var channel = 'main';
  var name = 'Main Channel';
  var description = 'This is the main channel.';
  var custom = {'users': 10};

  // Setting the basic channel info
  var channelMetadataInput = ChannelMetadataInput(
    name: name,
    description: description,
    custom: custom
  );
  var setResult =
      await pubnub.objects.setChannelMetadata(channel, channelMetadataInput);
  print('The channel has been created with name and description.\n');

    // First we have to get the current object to know what fields are already set
    var currentObject = await pubnub.objects
        .getChannelMetadata(channel, includeCustomFields: true);

    // We may have to initialize the custom field
    var customFields = currentObject.metadata.custom;
    customFields ??= {};

    // Updating the custom field
    customFields['private'] = false;

    // Writing the updated object back to the server
    channelMetadataInput = ChannelMetadataInput(
      name: currentObject.metadata.name,
      description: currentObject.metadata.description,
      custom: customFields,
    );

    try {
      setResult =
          await pubnub.objects.setChannelMetadata(channel, channelMetadataInput);
      print('The channel has been updated with the custom field.\n');
    } on PubNubException catch (e) {
      print('An error occurred: ${e.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 Dart SDK:

```dart
pubnub.objects.removeChannelMetadata(
  String channelId,
  {Keyset? keyset,
  String? using}
) 
```

| Parameter | Description |
| --- | --- |
| `channelID` *Type: `String` | Channel name. |
| `keyset`Type: `Keyset` | Override for the PubNub default keyset configuration. |
| `using`Type: `String` | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
var result = await pubnub.objects.removeChannelMetadata('my_channel');
```

#### Response

The `removeChannelMetadata()` returns `RemoveChannelMetadataResult` which does not have actionable data. In case of an error, an exception with error details is thrown.

## Channel memberships

### Get channel memberships

The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.

#### Method(s)

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

```dart
pubnub.objects.getMemberships(
  {String? uuid,
  int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeChannelFields,
  bool? includeChannelCustomFields,
  bool? includeChannelStatus,
  bool? includeChannelType,
  bool? includeCount = true,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
) 
```

| Parameter | Description |
| --- | --- |
| `uuid`Type: `String`Default: defaultKeyset UUID | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. |
| `limit`Type: `Int`Default: 100 | Number of objects to return. Default/Max: 100. |
| `start`Type: `String`Default: n/a | Cursor-based pagination. |
| `end`Type: `String`Default: n/a | Cursor-based pagination. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeChannelFields`Type: `bool`Default: `false` | Include fields for channels metadata. |
| `includeCustomChannelFields`Type: `bool`Default: `false` | Include custom fields for channels metadata. |
| `includeChannelStatus`Type: `bool`Default: `true` | Whether to include the channel `status` object in the response. |
| `includeChannelType`Type: `bool`Default: `true` | Whether to include the channel `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Whether to include the total count in the paginated response. Default is false. |
| `filter`Type: `String`Default: `null` | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
var memberships = await pubnub.objects.getMemberships();
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "channel": {
                "id": "my-channel",
                "name": "My channel",
                "description": "A channel that is mine",
                "custom": null,
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "custom": {
                "starred": false
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        },
        {
            "channel": {
                "id": "main",
                "name": "Main channel",
                "description": "The main channel",
                "custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        }
    ],
    "totalCount": 7,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

### Set channel memberships

Set channel memberships for a UUID.

#### Method(s)

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

```dart
pubnub.objects.setMemberships(
  List<MembershipMetadataInput> setMetadata,
  {String? uuid,
  int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeChannelFields,
  bool? includeChannelCustomFields,
  bool includeChannelStatus,
  bool includeChannelType,
  bool includeStatus,
  bool includeType,
  bool? includeCount = true,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
)

class MembershipMetadataInput {
  String channelId;
  Map<String, dynamic>? custom;
}
```

| Parameter | Description |
| --- | --- |
| `setMetadata` *Type: `List<MembershipMetadataInput>`Default: n/a | The memberships to be set. |
| `uuid`Type: `String`Default: defaultKeyset UUID | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. |
| `limit`Type: `Int`Default: 100 | Number of objects to return. Default/Max: 100. |
| `start`Type: `String`Default: n/a | Cursor-based pagination. |
| `end`Type: `String`Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the `start` parameter is supplied. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the `Custom` field in the fetch response. |
| `includeChannelFields`Type: `bool`Default: `false` | Include fields for channels metadata. |
| `includeCustomChannelFields`Type: `bool`Default: `false` | Include custom fields for channels metadata. |
| `includeChannelStatus`Type: `bool`Default: `true` | Whether to include the channel `status` object in the response. |
| `includeChannelType`Type: `bool`Default: `true` | Whether to include the channel `type` object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Whether to include the total count in the paginated response. Default is false. |
| `filter`Type: `String`Default: `null` | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined [here](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | List of properties to sort by. Available options are `id`, `name`, and `updated`. Use `asc` or `desc` to specify sort direction. |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

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

#### Sample code

```dart
  var setMetadata = [
    MembershipMetadataInput('my_channel', custom: {'starred': 'false'})
  ];

  var result = await pubnub.objects
      .setMemberships(setMetadata, includeChannelFields: true);
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "channel": {
              "id": "my-channel",
              "name": "My channel",
              "description": "A channel that is mine",
              "custom": null,
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "custom": {
                "starred": false
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        },
        {
          "channel": {
              "id": "main",
              "name": "Main channel",
              "description": "The main channel",
              "custom": {
                  "public": true,
                  "motd": "Always check your spelling!"
              },
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
          },
          "updated": "2019-02-20T23:11:20.893755",
          "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        }
    ],
    "totalCount": 7,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

### Remove channel memberships

Remove channel memberships for a UUID.

#### Method(s)

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

```dart
pubnub.objects.removeMemberships(
  Set<String> channelIds,
  {String? uuid,
  int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeChannelFields,
  bool? includeChannelCustomFields,
  bool includeStatus,
  bool includeType,
  bool includeChannelStatus,
  bool includeChannelType,
  bool? includeCount = true,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
)
```

| Parameter | Description |
| --- | --- |
| `channelIds` *Type: `Set<String>`Default: n/a | List of channels to remove from membership. |
| `uuid`Type: `String`Default: n/a | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. |
| `limit`Type: `Int`Default: 100 | Number of objects to return. Default/Max: 100. |
| `start`Type: `String`Default: n/a | Cursor-based pagination. |
| `end`Type: `String`Default: n/a | Cursor-based pagination. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the `Custom` field in the fetch response. |
| `includeChannelFields`Type: `bool`Default: `false` | Include fields for channels metadata. |
| `includeCustomChannelFields`Type: `bool`Default: `false` | Include custom fields for channels metadata. |
| `includeChannelStatus`Type: `bool`Default: `true` | Whether to include the channel `status` object in the response. |
| `includeChannelType`Type: `bool`Default: `true` | Whether to include the channel `type` object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Request `IncludeCount` to be included in paginated response. By default, `includeCount` is omitted. |
| `filter`Type: `String`Default: `null` | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
  var result = await pubnub.objects.removeMemberships({'my_channel', 'main_channel'});

  // for other uuid
  var result = await pubnub.objects.removeMemberships({'my_channel'}, uuid: 'uuid1');
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "channel": {
              "id": "my-channel",
              "name": "My channel",
              "description": "A channel that is mine",
              "custom": null,
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "custom": {
                "starred": false
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        },
        {
            "channel": {
              "id": "main",
              "name": "Main channel",
              "description": "The main channel",
              "custom": {
                  "public": true,
                  "motd": "Always check your spelling!"
              },
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        }
    ],
    "totalCount": 7,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

### Manage channel memberships

Manage a user's channel memberships.

#### Method(s)

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

```dart
pubnub.objects.manageMemberships(
  List<MembershipMetadataInput> setMetadata,
  Set<String> removeChannelIds,
  {String? uuid,
  int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeChannelFields,
  bool? includeChannelCustomFields,
  bool includeStatus,
  bool includeType,
  bool includeChannelStatus,
  bool includeChannelType,
  bool? includeCount,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
)

class MembershipMetadataInput {
  String channelId;
  Map<String, dynamic>? custom;
}
```

| Parameter | Description |
| --- | --- |
| `setMetadata` *Type: `List<MembershipMetadataInput>`Default: n/a | The memberships to be set. |
| `channelIds` *Type: `Set<String>`Default: n/a | List of channels to remove from membership. |
| `uuid`Type: `String`Default: n/a | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. |
| `limit`Type: `Int`Default: 100 | Number of objects to return. Default/Max: 100. |
| `start`Type: `String`Default: n/a | Cursor-based pagination. |
| `end`Type: `String`Default: n/a | Cursor-based pagination. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeChannelFields`Type: `bool`Default: `false` | Include fields for channels metadata. |
| `includeCustomChannelFields`Type: `bool`Default: `false` | Include custom fields for channels metadata. |
| `includeChannelStatus`Type: `bool`Default: `true` | Whether to include the channel `status` object in the response. |
| `includeChannelType`Type: `bool`Default: `true` | Whether to include the channel `type` object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Request `IncludeCount` to be included in paginated response. By default, `includeCount` is omitted. |
| `filter`Type: `String`Default: `null` | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
  var setMetadata = [
    MembershipMetadataInput('my_channel', custom: {'starred': 'false'})
  ];
  var result =
      await pubnub.objects.manageMemberships(setMetadata, {'main_channel'});
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "channel": {
              "id": "my-channel",
              "name": "My channel",
              "description": "A channel that is mine",
              "custom": null,
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "custom": {
                "starred": false
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        },
        {
            "channel": {
              "id": "main",
              "name": "Main channel",
              "description": "The main channel",
              "custom": {
                  "public": true,
                  "motd": "Always check your spelling!"
              },
              "updated": "2019-02-20T23:11:20.893755",
              "eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "RUNDMDUwNjktNUYwRC00RTI0LUI1M0QtNUUzNkE2NkU0MEVFCg=="
        }
    ],
    "totalCount": 7,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

## Channel members

### Get channel members

The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.

#### Method(s)

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

```dart
pubnub.objects.getChannelMembers(
  String channelId,
  {int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeUUIDFields,
  bool? includeUUIDCustomFields,
  bool includeStatus,
  bool includeType,
  bool includeUUIDStatus,
  bool includeUUIDType,
  bool? includeCount = true,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
) 
```

| Parameter | Description |
| --- | --- |
| `channelId`Type: `String`Default: n/a | Channel name. |
| `limit`Type: `Int`Default: 100 | Number of objects to return. Default/Max: 100. |
| `start`Type: `String`Default: n/a | Cursor-based pagination. |
| `end`Type: `String`Default: n/a | Cursor-based pagination. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeUUIDFields`Type: BooleanDefault: `false` | Whether to include additional fields. |
| `includeUUIDCustomFields`Type: BooleanDefault: `false` | Whether to include additional fields. |
| `includeUUIDStatus`Type: `bool`Default: `true` | Whether to include the user `status` object in the response. |
| `includeUUIDType`Type: `bool`Default: `true` | Whether to include the user `type` object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Whether to include the total count in the paginated response. Default is false. |
| `filter`Type: `String`Default: `null` | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
var channelMembers = await pubnub.objects.getChannelMembers('my_channel');
```

#### Response

```json
{
  "status": 200,
  "data": [
    {
      "uuid": {
        "id": "uuid-1",
        "name": "John Doe",
        "externalId": null,
        "profileUrl": null,
        "email": "someone@pubnub.com",
        "custom": null,
        "updated": "2019-02-20T23:11:20.893755",
        "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
      },
      "custom": {
        "role": "admin"
      },
      "updated": "2019-02-20T23:11:20.893755",
      "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
    },
    {
      "uuid": {
        "id": "uuid-2",
        "name": "Bob Cat",
        "externalId": null,
        "profileUrl": null,
        "email": "bobc@example.com",
        "custom": {
          "phone": "999-999-9999"
        },
        "updated": "2019-02-21T03:29:00.173452",
        "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
      },
      "updated": "2019-02-20T23:11:20.893755",
      "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
    }
  ],
  "totalCount": 37,
  "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
  "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

### Set channel members

This method sets members in a channel.

#### Method(s)

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

```dart
pubnub.objects.setChannelMembers(
  String channelId,
  List<ChannelMemberMetadataInput> setMetadata,
  {int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeUUIDFields,
  bool? includeUUIDCustomFields,
  bool includeStatus,
  bool includeType,
  bool includeUUIDStatus,
  bool includeUUIDType,
  bool? includeCount,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
)

class ChannelMemberMetadataInput {
  String uuid;
  Map<String, dynamic>? custom;
  String? status;
  String type;
}
```

| Parameter | Description |
| --- | --- |
| `channelId` *Type: `String`Default: n/a | Channel name. |
| `setMetadata` *Type: [ChannelMemberMetadataInput](https://pub.dev/documentation/pubnub/latest/pubnub/ChannelMemberMetadataInput-class.html)Default: n/a | The metadata to be added. |
| `limit`Type: `Int`Default: 100 | Number of objects to return. Default/Max: 100. |
| `start`Type: `String`Default: n/a | Cursor-based pagination. |
| `end`Type: `String`Default: n/a | Cursor-based pagination. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeUUIDFields`Type: BooleanDefault: `false` | Whether to include additional fields. |
| `includeUUIDCustomFields`Type: BooleanDefault: `false` | Whether to include additional fields. |
| `includeUUIDStatus`Type: `bool`Default: `true` | Whether to include the user `status` object in the response. |
| `includeUUIDType`Type: `bool`Default: `true` | Whether to include the user `type` object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Whether to include the total count in the paginated response. Default is false. |
| `filter`Type: `String`Default: `null` | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

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

```dart
  var setMetadata = [
    ChannelMemberMetadataInput('myUUID', custom: {'role': 'admin'})
  ];
  var result =
      await pubnub.objects.setChannelMembers('my_channel', setMetadata);
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "uuid": {
                "id": "uuid-1",
                "name": "John Doe",
                "externalId": null,
                "profileUrl": null,
                "email": "johndoe@pubnub.com",
                "custom": null,
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
            },
            "custom": {
                "role": "admin"
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        },
        {
            "uuid": {
                "id": "uuid-2",
                "name": "Bob Cat",
                "externalId": null,
                "profileUrl": null,
                "email": "bobc@example.com",
                "custom": {
                    "phone": "999-999-9999"
                },
                "updated": "2019-02-21T03:29:00.173452",
                "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        }
    ],
    "totalCount": 37,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

### Remove channel members

Remove members from a Channel.

#### Method(s)

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

```dart
pubnub.objects.removeChannelMembers(
  String channelId,
  Set<String> uuids,
  {int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeUUIDFields,
  bool? includeUUIDCustomFields,
  bool includeStatus,
  bool includeType,
  bool includeUUIDStatus,
  bool includeUUIDType,
  bool? includeCount,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
) 
```

| Parameter | Description |
| --- | --- |
| `channelId` *Type: `String`Default: n/a | Channel name. |
| `uuids` *Type: `Set<String>`Default: n/a | UUIDs to remove from the channel. |
| `limit`Type: `Int`Default: 100 | The number of objects to retrieve at a time. |
| `start`Type: `String`Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
| `end`Type: `String`Default: n/a | Cursor-based pagination. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the Custom object in the response. |
| `includeUUIDFields`Type: BooleanDefault: `false` | Whether to include additional fields. |
| `includeUUIDCustomFields`Type: BooleanDefault: `false` | Whether to include additional fields. |
| `includeUUIDStatus`Type: `bool`Default: `true` | Whether to include the user `status` object in the response. |
| `includeUUIDType`Type: `bool`Default: `true` | Whether to include the user `type` object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Whether to include the total count in the paginated response. Default is false. |
| `filter`Type: `String`Default: `null` | Filter expression. Only matching objects are returned. See [filtering](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | Sort by `id`, `name`, `updated` with `asc`/`desc` for sort direction (for example, `{name: 'asc'}`). |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
  var result = await pubnub.objects
      .removeChannelMembers('my_channel', {'uuid-1', 'uuid-2'});
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "uuid": {
                "id": "uuid-1",
                "name": "John Doe",
                "externalId": null,
                "profileUrl": null,
                "email": "johndoe@pubnub.com",
                "custom": null,
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
            },
            "custom": {
                "role": "admin"
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        },
        {
            "uuid": {
                "id": "uuid-2",
                "name": "Bob Cat",
                "externalId": null,
                "profileUrl": null,
                "email": "bobc@example.com",
                "custom": {
                    "phone": "999-999-9999"
                },
                "updated": "2019-02-21T03:29:00.173452",
                "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        }
    ],
    "totalCount": 37,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

### Manage channel members

Set and Remove channel memberships for a user.

#### Method(s)

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

```dart
pubnub.objects.manageChannelMembers(
  String channelId,
  List<ChannelMemberMetadataInput> setMetadata,
  Set<String> removeMemberUuids,
  {int? limit,
  String? start,
  String? end,
  bool? includeCustomFields,
  bool? includeUUIDFields,
  bool? includeUUIDCustomFields,
  bool includeStatus,
  bool includeType,
  bool includeUUIDStatus,
  bool includeUUIDType,
  bool? includeCount = true,
  String? filter,
  Set<String>? sort,
  Keyset? keyset,
  String? using}
)

class ChannelMemberMetadataInput {
  String uuid;
  Map<String, dynamic>? custom;
  String? status;
  String type;
}
```

| Parameter | Description |
| --- | --- |
| `channelId` *Type: `String`Default: n/a | Channel name. |
| `setMetadata` *Type: [List<ChannelMemberMetadataInput>](https://pub.dev/documentation/pubnub/latest/pubnub/ChannelMemberMetadataInput-class.html)Default: n/a | The metadata to set. |
| `removeMemberUuids` *Type: `Set<String>`Default: n/a | UUIDs to remove from the channel. |
| `limit`Type: `Int`Default: 100 | The number of objects to retrieve at a time. |
| `start`Type: `String`Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
| `end`Type: `String`Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the `start` parameter is supplied. |
| `includeCustomFields`Type: `bool`Default: `false` | Whether to include the `Custom` field in the fetch response. |
| `includeUUIDFields`Type: BooleanDefault: `false` | Include fields for UUIDs metadata. |
| `includeUUIDCustomFields`Type: BooleanDefault: `false` | Include custom fields for UUIDs metadata. |
| `includeUUIDStatus`Type: `bool`Default: `true` | Whether to include the user `status` object in the response. |
| `includeUUIDType`Type: `bool`Default: `true` | Whether to include the user `type` object in the response. |
| `includeStatus`Type: `bool`Default: `true` | Whether to include the `status` object in the response. |
| `includeType`Type: `bool`Default: `true` | Whether to include the `type` object in the response. |
| `includeCount`Type: `bool`Default: `false` | Request `IncludeCount` to be included in paginated response. By default, `includeCount` is omitted. |
| `filter`Type: `String`Default: `null` | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined [here](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `Set<String>`Default: n/a | List of properties to sort by. Available options are `id`, `name`, and `updated`. Use `asc` or `desc` to specify sort direction. |
| `keyset`Type: `Keyset`Default: n/a | Override for the PubNub default keyset configuration. |
| `using`Type: `String`Default: n/a | Keyset name from the `keysetStore` to be used for this method call. |

#### Sample code

```dart
  var setMetadata = [
    ChannelMemberMetadataInput('uuidToSet', custom: {'role': 'admin'})
  ];
  var result = await pubnub.objects
      .manageChannelMembers('my_channel', setMetadata, {'uuidToRemove'});
```

#### Response

```json
{
    "status": 200,
    "data": [
        {
            "uuid": {
                "id": "uuid-1",
                "name": "John Doe",
                "externalId": null,
                "profileUrl": null,
                "email": "johndoe@pubnub.com",
                "custom": null,
                "updated": "2019-02-20T23:11:20.893755",
                "eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
            },
            "custom": {
                "role": "admin"
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        },
        {
            "uuid": {
                "id": "uuid-2",
                "name": "Bob Cat",
                "externalId": null,
                "profileUrl": null,
                "email": "bobc@example.com",
                "custom": {
                    "phone": "999-999-9999"
                },
                "updated": "2019-02-21T03:29:00.173452",
                "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
            },
            "updated": "2019-02-20T23:11:20.893755",
            "eTag": "QkRENDA5MjItMUZCNC00REI5LUE4QTktRjJGNUMxNTc2MzE3Cg=="
        }
    ],
    "totalCount": 37,
    "next": "RDIwQUIwM0MtNUM2Ni00ODQ5LUFGRjMtNDk1MzNDQzE3MUVCCg==",
    "prev": "MzY5RjkzQUQtNTM0NS00QjM0LUI0M0MtNjNBQUFGODQ5MTk2Cg=="
}
```

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