---
source_url: https://www.pubnub.com/docs/sdks/asyncio/api-reference/objects
title: App Context API for Python-Asyncio SDK
updated_at: 2026-11-25T12:28:11.000Z
sdk_name: PubNub Python Asyncio SDK
sdk_version: 10.9.1
description: "Reference for the PubNub Python-Asyncio SDK App Context methods: get, set, and remove metadata for users and channels, and get, set, remove, and manage channel memberships and channel members."
---

# App Context API for Python-Asyncio SDK

PubNub Python Asyncio SDK, use the latest version: 10.9.1

Install:

```bash
pip install pubnub==10.9.1
```

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

App Context lets a PubNub client for Python-Asyncio store metadata about users and channels, and the memberships that link them, without running a database. The methods live on the `PubNubAsyncio` client, and the User ID parameter is named `uuid`.

This page describes App Context (formerly Objects v2). To upgrade from Objects v1, see the [migration guide](https://www.pubnub.com/docs/migration-guides/app-context.md).

The methods fall into four groups:

* User metadata: [Get metadata for all users](#get-metadata-for-all-users), [Get user metadata](#get-user-metadata), [Set user metadata](#set-user-metadata), and [Remove user metadata](#remove-user-metadata).
* Channel metadata: [Get metadata for all channels](#get-metadata-for-all-channels), [Get channel metadata](#get-channel-metadata), [Set channel metadata](#set-channel-metadata), and [Remove channel metadata](#remove-channel-metadata).
* Channel memberships: [Get channel memberships](#get-channel-memberships), [Set channel memberships](#set-channel-memberships), [Remove channel memberships](#remove-channel-memberships), and [Manage channel memberships](#manage-channel-memberships).
* Channel members: [Get channel members](#get-channel-members), [Set channel members](#set-channel-members), [Remove channel members](#remove-channel-members), and [Manage channel members](#manage-channel-members).

A membership is the stored link between a user and a channel. A membership is not a subscription and delivers no messages. Membership methods start from a user and act on the channels that the user belongs to. Member methods start from a channel and act on its users. Both kinds change the same underlying membership.

PubNub publishes an App Context event when a set or delete call succeeds. See [App Context events](https://www.pubnub.com/docs/data-storage/metadata/events.md).

A builder sends its request when you await its `future()`. A request that fails, or fails validation, does not raise an exception. `future()` resolves with a `PubNubAsyncioException` whose `result` is `None` and whose `status` holds the error. Call `is_error()` on the awaited value before you read `result`.

Each keyword argument is also a builder method of the same name, except where a table says otherwise.

The builder methods `include_custom()`, `include_status()`, `include_type()`, `include_total_count()`, `include_channel()`, and `include_uuid()` are deprecated since 10.1.0 and issue a `DeprecationWarning`, but they still work. Use the keyword arguments of the same names on the user and channel metadata methods. On the membership and member methods, use the `include` parameter with `MembershipIncludes` or `MemberIncludes` instead. Keyword arguments with the same names are not deprecated.

The methods take channel and user ID strings, not SDK channel entities.

## Get metadata for all users

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.get_all_uuid_metadata()` returns a paginated list of the user metadata objects stored in App Context, through a PubNub client for Python-Asyncio. Each object holds the profile fields of a user and, on request, its custom data.

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

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of user metadata objects that match the request. Without it, `total_count` is `None`. |
| include_custom | bool | Optional | `False` | Whether each user metadata object in the response includes its `custom` object. |
| include_status | bool | Optional | `True` | Whether each user metadata object in the response includes its `status` field. |
| include_type | bool | Optional | `True` | Whether each user metadata object in the response includes its `type` field. |
| filter | str | Optional | n/a | The filter expression. The response includes only the user metadata objects that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of user metadata objects to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. The keyword arguments of `get_all_uuid_metadata()` do not include `page`, so set it with the builder method `page()`. |

### Returns

`get_all_uuid_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNGetAllUUIDMetadataResult` and whose `status` is a `PNStatus`.

#### PNGetAllUUIDMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The user metadata objects on this page. |
| > id | str | The ID of the user. |
| > name | str | The display name of the user, or `None` when unset. |
| > externalId | str | The ID in an external system of the user, or `None` when unset. |
| > profileUrl | str | The URL of the profile picture of the user, or `None` when unset. |
| > email | str | The email address of the user, or `None` when unset. |
| > type | str | The type of the user, or `None` when unset. The result includes it unless `include_type` is `False`. |
| > status | str | The status of the user, or `None` when unset. The result includes it unless `include_status` is `False`. |
| > custom | dict | The custom data of the user. The key is present only when `include_custom` is `True`. The key holds `None` when the user has none. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the user metadata. |
| total_count | int | The number of user metadata objects that match the request, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.get_all_uuid_metadata(
    include_total_count: bool,
    include_custom: bool,
    include_status: bool,
    include_type: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.sort import PNSortKey, PNSortKeyValue
result = await pubnub.get_all_uuid_metadata(include_custom=True, include_total_count=True) \
    .limit(10) \
    .filter("name == 'doc_type'") \
    .sort(PNSortKey.asc(PNSortKeyValue.ID), PNSortKey.desc(PNSortKeyValue.UPDATED)) \
    .page(None) \
    .future()

for uuid_data in result.result.data:
    print(f"UUID: {uuid_data['id']}")
    print(f"Name: {uuid_data['name']}")
    print(f"Custom: {uuid_data['custom']}")
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.sort import PNSortKey, PNSortKeyValue

metadata = await pubnub.get_all_uuid_metadata(
    limit=10,
    include_custom=True,
    filter="name == 'doc_type'",
    include_total_count=True,
    sort_keys=[PNSortKey.asc(PNSortKeyValue.ID), PNSortKey.desc(PNSortKeyValue.UPDATED)]
).future()

for uuid_data in metadata.result.data:
    print(f"UUID: {uuid_data['id']}")
    print(f"Name: {uuid_data['name']}")
    print(f"Custom: {uuid_data['custom']}")
```

## Get user metadata

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.get_uuid_metadata()` returns the metadata of one user from App Context through a PubNub client for Python-Asyncio. The metadata holds the profile fields of the user and, on request, its custom data.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Optional | n/a | The ID of the user to get metadata for. When omitted, the SDK uses the `user_id` of the PubNub client. An empty string fails validation with the message `uuid missing or not a string`. |
| include_custom | bool | Optional | `False` | Whether the response includes the `custom` object of the user. |
| include_status | bool | Optional | `True` | Whether the result includes the `status` field of the user. |
| include_type | bool | Optional | `True` | Whether the result includes the `type` field of the user. |

### Returns

`get_uuid_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNGetUUIDMetadataResult` and whose `status` is a `PNStatus`.

#### PNGetUUIDMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | dict | The user metadata object. |
| > id | str | The ID of the user. |
| > name | str | The display name of the user, or `None` when unset. |
| > externalId | str | The ID in an external system of the user, or `None` when unset. |
| > profileUrl | str | The URL of the profile picture of the user, or `None` when unset. |
| > email | str | The email address of the user, or `None` when unset. |
| > type | str | The type of the user, or `None` when unset. The result includes it unless `include_type` is `False`. |
| > status | str | The status of the user, or `None` when unset. The result includes it unless `include_status` is `False`. |
| > custom | dict | The custom data of the user. The key is present only when `include_custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the user metadata. |

### Examples

#### Syntax

```python
await pubnub.get_uuid_metadata(
    uuid: str,
    include_custom: bool,
    include_status: bool,
    include_type: bool
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
envelope = await pubnub.get_uuid_metadata(include_custom=True).future()
```

#### Basic usage (Named Arguments)

```python
metadata = await pubnub.get_uuid_metadata(include_custom=True).future()
```

## Set user metadata

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.set_uuid_metadata()` sets the metadata of one user in App Context through a PubNub client for Python-Asyncio and returns the stored object. The call creates the metadata when the user has none yet.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Optional | n/a | The ID of the user to set metadata for. When omitted, the SDK uses the `user_id` of the PubNub client. An empty string fails validation with the message `uuid missing or not a string`. |
| name | str | Optional | n/a | The display name of the user. The builder method is `set_name()`. |
| external_id | str | Optional | n/a | The ID of the user in an external system. |
| profile_url | str | Optional | n/a | The URL of the profile picture of the user. |
| email | str | Optional | n/a | The email address of the user. |
| type | str | Optional | n/a | The type of the user. The builder method is `set_type()`. |
| status | str | Optional | n/a | The status of the user. The builder method is `set_status()`. |
| custom | dict | Optional | n/a | The custom data of the user. A set call replaces the whole stored `custom` object. To add a key, get the metadata first, add the key, and set the complete object. Values can be strings, numbers, or booleans. The builder method `custom()` also sets `include_custom` to `True`, but the keyword argument `custom` does not. |
| include_custom | bool | Optional | `False` | Whether the response includes the `custom` object of the user. |
| include_status | bool | Optional | `True` | Whether the result includes the `status` field of the user. |
| include_type | bool | Optional | `True` | Whether the result includes the `type` field of the user. |
| if_matches_etag | str | Optional | n/a | The `eTag` of the user metadata that you last read. The update applies only if the stored metadata still has this `eTag`. Otherwise PubNub rejects the update with HTTP status 412. Get the `eTag` from the response of `get_uuid_metadata()`. The keyword arguments do not include it, so set it with the builder method `if_matches_etag()`, available since 10.2.0. |

The SDK sends name, external_id, email, and profile_url as `null` when you leave them out. Pass every field that you want to keep, because a set call without `name` clears the stored value.

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

### Returns

`set_uuid_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNSetUUIDMetadataResult` and whose `status` is a `PNStatus`. Its `data` property holds the stored user metadata and has the same properties as the `data` property of the [Get user metadata](#get-user-metadata) response.

#### PNSetUUIDMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | dict | The stored user metadata object. |

### Examples

#### Syntax

```python
await pubnub.set_uuid_metadata(
    uuid: str,
    name: str,
    external_id: str,
    profile_url: str,
    email: str,
    type: str,
    status: str,
    custom: dict,
    include_custom: bool,
    include_status: bool,
    include_type: bool
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
envelope = await pubnub.set_uuid_metadata(include_custom=True) \
    .uuid("some_uuid") \
    .set_name("Some Name") \
    .set_status("Active") \
    .set_type("User") \
    .email("test@example.com") \
    .profile_url("http://example.com") \
    .external_id("1234567890") \
    .custom({"key1": "val1", "key2": "val2"}) \
    .future()
```

#### Basic usage (Named Arguments)

```python
envelope = await pubnub.set_uuid_metadata(uuid="some_uuid_named",
                                          name="Some Name",
                                          status="Active", type="User",
                                          email="test@example.com",
                                          profile_url="http://example.com",
                                          external_id="1234567890",
                                          custom={"key1": "val1", "key2": "val2"},
                                          include_custom=True) \
    .future()
```

## Remove user metadata

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.remove_uuid_metadata()` deletes the metadata of one user from App Context through a PubNub client for Python-Asyncio. Deleting the metadata deletes the memberships of the user only when the keyset enforces [referential integrity](https://www.pubnub.com/docs/data-storage/metadata/overview.md#membership-connects-users-and-channels).

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Optional | n/a | The ID of the user to delete metadata for. When omitted, the SDK uses the `user_id` of the PubNub client. An empty string fails validation with the message `uuid missing or not a string`. |

### Returns

`remove_uuid_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNRemoveUUIDMetadataResult` and whose `status` is a `PNStatus`.

#### PNRemoveUUIDMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | None | Always `None`. |

### Examples

#### Syntax

```python
await pubnub.remove_uuid_metadata(
    uuid: str
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
envelope = await pubnub.remove_uuid_metadata() \
    .uuid("some_uuid").future()
```

#### Basic usage (Named Arguments)

```python
envelope = await pubnub.remove_uuid_metadata(uuid="some_uuid_named").future()
```

## Get metadata for all channels

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.get_all_channel_metadata()` returns a paginated list of the channel metadata objects stored in App Context, through a PubNub client for Python-Asyncio. Each object holds the name and description of a channel and, on request, its custom data.

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

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of channel metadata objects that match the request. Without it, `total_count` is `None`. |
| include_custom | bool | Optional | `False` | Whether each channel metadata object in the response includes its `custom` object. |
| include_status | bool | Optional | `True` | Whether each channel metadata object in the response includes its `status` field. |
| include_type | bool | Optional | `True` | Whether each channel metadata object in the response includes its `type` field. |
| filter | str | Optional | n/a | The filter expression. The response includes only the channel metadata objects that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of channel metadata objects to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

### Returns

`get_all_channel_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNGetAllChannelMetadataResult` and whose `status` is a `PNStatus`.

#### PNGetAllChannelMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The channel metadata objects on this page. |
| > id | str | The ID of the channel. |
| > name | str | The name of the channel, or `None` when unset. |
| > description | str | The description of the channel, or `None` when unset. |
| > type | str | The type of the channel, or `None` when unset. The result includes it unless `include_type` is `False`. |
| > status | str | The status of the channel, or `None` when unset. The result includes it unless `include_status` is `False`. |
| > custom | dict | The custom data of the channel. The key is present only when `include_custom` is `True`. The key holds `None` when the channel has none. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the channel metadata. |
| total_count | int | The number of channel metadata objects that match the request, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.get_all_channel_metadata(
    include_total_count: bool,
    include_custom: bool,
    include_status: bool,
    include_type: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.sort import PNSortKey, PNSortKeyValue
envelope = await pubnub.get_all_channel_metadata(include_custom=True, include_total_count=True) \
    .limit(10) \
    .filter("name == 'doc_type'") \
    .sort(PNSortKey.asc(PNSortKeyValue.ID), PNSortKey.desc(PNSortKeyValue.UPDATED)) \
    .page(None) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.sort import PNSortKey, PNSortKeyValue

metadata = await pubnub.get_all_channel_metadata(limit=10,
                                                 include_custom=True,
                                                 filter="name == 'doc_type'",
                                                 include_total_count=True,
                                                 sort_keys=[PNSortKey.asc(PNSortKeyValue.ID),
                                                            PNSortKey.desc(PNSortKeyValue.UPDATED)]) \
    .future()
```

## Get channel metadata

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.get_channel_metadata()` returns the metadata of one channel from App Context through a PubNub client for Python-Asyncio. The metadata holds the name and description of the channel and, on request, its custom data.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel to get metadata for. A request without a channel fails validation with the message `Channel missing`. |
| include_custom | bool | Optional | `False` | Whether the response includes the `custom` object of the channel. |
| include_status | bool | Optional | `True` | Whether the result includes the `status` field of the channel. |
| include_type | bool | Optional | `True` | Whether the result includes the `type` field of the channel. |

### Returns

`get_channel_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNGetChannelMetadataResult` and whose `status` is a `PNStatus`.

#### PNGetChannelMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | dict | The channel metadata object. |
| > id | str | The ID of the channel. |
| > name | str | The name of the channel, or `None` when unset. |
| > description | str | The description of the channel, or `None` when unset. |
| > type | str | The type of the channel, or `None` when unset. The result includes it unless `include_type` is `False`. |
| > status | str | The status of the channel, or `None` when unset. The result includes it unless `include_status` is `False`. |
| > custom | dict | The custom data of the channel. The key is present only when `include_custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the channel metadata. |

### Examples

#### Syntax

```python
await pubnub.get_channel_metadata(
    channel: str,
    include_custom: bool,
    include_status: bool,
    include_type: bool
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
envelope = await pubnub.get_channel_metadata(include_custom=True) \
    .channel("channel_id") \
    .future()
```

#### Basic usage (Named Arguments)

```python
metadata = await pubnub.get_channel_metadata(channel="channel_id", include_custom=True).future()
```

## Set channel metadata

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.set_channel_metadata()` sets the metadata of one channel in App Context through a PubNub client for Python-Asyncio and returns the stored object. The call creates the metadata when the channel has none yet.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel to set metadata for. A request without a channel fails validation with the message `Channel missing`. |
| name | str | Optional | n/a | The name of the channel. The builder method is `set_name()`. |
| description | str | Optional | n/a | The description of the channel. |
| type | str | Optional | n/a | The type of the channel. The builder method is `set_type()`. |
| status | str | Optional | n/a | The status of the channel. The builder method is `set_status()`. |
| custom | dict | Optional | n/a | The custom data of the channel. A set call replaces the whole stored `custom` object. To add a key, get the metadata first, add the key, and set the complete object. Values can be strings, numbers, or booleans. The builder method `custom()` also sets `include_custom` to `True`, but the keyword argument `custom` does not. |
| include_custom | bool | Optional | `False` | Whether the response includes the `custom` object of the channel. |
| include_status | bool | Optional | `True` | Whether the result includes the `status` field of the channel. |
| include_type | bool | Optional | `True` | Whether the result includes the `type` field of the channel. |
| if_matches_etag | str | Optional | n/a | The `eTag` of the channel metadata that you last read. The update applies only if the stored metadata still has this `eTag`. Otherwise PubNub rejects the update with HTTP status 412. Get the `eTag` from the response of `get_channel_metadata()`. The keyword arguments do not include it, so set it with the builder method `if_matches_etag()`, available since 10.2.0. |

The SDK sends name, description, type, status, and custom as `null` when you leave them out. Pass every field that you want to keep, because a set call without `name` clears the stored value.

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

### Returns

`set_channel_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNSetChannelMetadataResult` and whose `status` is a `PNStatus`. Its `data` property holds the stored channel metadata and has the same properties as the `data` property of the [Get channel metadata](#get-channel-metadata) response.

#### PNSetChannelMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | dict | The stored channel metadata object. |

### Examples

#### Syntax

```python
await pubnub.set_channel_metadata(
    channel: str,
    name: str,
    description: str,
    type: str,
    status: str,
    custom: dict,
    include_custom: bool,
    include_status: bool,
    include_type: bool
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
envelope = await pubnub.set_channel_metadata(include_custom=True) \
    .channel("channel_id") \
    .set_name("Channel Name") \
    .set_status("Archived") \
    .set_type("Archived") \
    .description("Description") \
    .custom({"key1": "val1", "key2": "val2"}) \
    .future()
```

#### Basic usage (Named Arguments)

```python
envelope = await pubnub.set_channel_metadata(channel="channel_id_named",
                                             name="Channel Name",
                                             status="Archived",
                                             type="Archived",
                                             description="Description",
                                             custom={"key1": "val1", "key2": "val2"},
                                             include_custom=True) \
    .future()
```

## Remove channel metadata

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.remove_channel_metadata()` deletes the metadata of one channel from App Context through a PubNub client for Python-Asyncio. Deleting the metadata deletes the memberships of the channel only when the keyset enforces [referential integrity](https://www.pubnub.com/docs/data-storage/metadata/overview.md#membership-connects-users-and-channels).

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel to delete metadata for. A request without a channel fails validation with the message `Channel missing`. |

### Returns

`remove_channel_metadata()` resolves with an `AsyncioEnvelope` whose `result` is a `PNRemoveChannelMetadataResult` and whose `status` is a `PNStatus`.

#### PNRemoveChannelMetadataResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | None | Always `None`. |

### Examples

#### Syntax

```python
await pubnub.remove_channel_metadata(
    channel: str
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
envelope = await pubnub.remove_channel_metadata() \
    .channel("channel_id") \
    .future()
```

#### Basic usage (Named Arguments)

```python
envelope = await pubnub.remove_channel_metadata(channel="channel_id_named").future()
```

## Get channel memberships

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.get_memberships()` returns a page of the channel memberships of one user through a PubNub client for Python-Asyncio. A membership links the user to a channel and is not a subscription.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Optional | n/a | The ID of the user to get channel memberships for. When omitted, the SDK uses the `user_id` of the PubNub client. An empty string fails validation with the message `uuid missing or not a string`. |
| include | MembershipIncludes | Optional | n/a | The fields to add to the result, as a `MembershipIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each membership in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each membership in the response includes its `type` field. |
| > channel | bool | Optional | `False` | Whether each membership includes the metadata of its channel in the `channel` object, such as `name` and `description`. |
| > channel_custom | bool | Optional | `False` | Whether the `channel` object of each membership includes the `custom` object of the channel. |
| > channel_status | bool | Optional | `False` | Whether the `channel` object of each membership includes the `status` of the channel. The `status` option controls the `status` of the membership instead. |
| > channel_type | bool | Optional | `False` | Whether the `channel` object of each membership includes the `type` of the channel. The `type` option controls the `type` of the membership instead. |
| include_custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of memberships of the user. Without it, `total_count` is `None`. The `total_count` field of `MembershipIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the memberships that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts memberships. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of memberships to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

### Returns

`get_memberships()` resolves with an `AsyncioEnvelope` whose `result` is a `PNGetMembershipsResult` and whose `status` is a `PNStatus`.

#### PNGetMembershipsResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The memberships of the user on this page. |
| > channel | dict | The channel of the membership. With `include.channel` set to `True` it holds the channel metadata, including `id`, `name`, `description`, `updated`, and `eTag`. Otherwise it holds the `id` of the channel and the channel fields that the include object requests. |
| > status | str | The status of the membership. The key is present only when `include.status` is `True`. |
| > type | str | The type of the membership. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the membership. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the membership. |
| total_count | int | The number of memberships of the user, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.get_memberships(
    uuid: str,
    include: MembershipIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes
envelope = await pubnub.get_memberships() \
    .include(MembershipIncludes(custom=True, channel=True, channel_custom=True)) \
    .uuid("some_uuid").future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes

envelope = await pubnub.get_memberships(uuid="some_uuid",
                                        include=MembershipIncludes(custom=True, channel=True,
                                                                   channel_custom=True)) \
    .future()
```

## Set channel memberships

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.set_memberships()` sets channel memberships for one user through a PubNub client for Python-Asyncio and returns a page of the memberships of that user.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Optional | n/a | The ID of the user to set channel memberships for. When omitted, the SDK uses the `user_id` of the PubNub client. An empty string fails validation with the message `uuid missing or not a string`. |
| channel_memberships | List[PNChannelMembership] | Yes | n/a | The memberships to set for the user, as a list of `PNChannelMembership` objects. Build each one with `PNChannelMembership.channel()`, `PNChannelMembership.channel_with_custom()`, or the `PNChannelMembership` constructor. The call adds the memberships that you pass and keeps the other memberships of the user. |
| include | MembershipIncludes | Optional | n/a | The fields to add to the result, as a `MembershipIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each membership in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each membership in the response includes its `type` field. |
| > channel | bool | Optional | `False` | Whether each membership includes the metadata of its channel in the `channel` object, such as `name` and `description`. |
| > channel_custom | bool | Optional | `False` | Whether the `channel` object of each membership includes the `custom` object of the channel. |
| > channel_status | bool | Optional | `False` | Whether the `channel` object of each membership includes the `status` of the channel. The `status` option controls the `status` of the membership instead. |
| > channel_type | bool | Optional | `False` | Whether the `channel` object of each membership includes the `type` of the channel. The `type` option controls the `type` of the membership instead. |
| include_custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of memberships of the user. Without it, `total_count` is `None`. The `total_count` field of `MembershipIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the memberships that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts memberships. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of memberships to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

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

### Returns

`set_memberships()` resolves with an `AsyncioEnvelope` whose `result` is a `PNSetMembershipsResult` and whose `status` is a `PNStatus`. The `data` property lists the memberships of the user after the change.

#### PNSetMembershipsResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The memberships of the user on this page. |
| > channel | dict | The channel of the membership. With `include.channel` set to `True` it holds the channel metadata, including `id`, `name`, `description`, `updated`, and `eTag`. Otherwise it holds the `id` of the channel and the channel fields that the include object requests. |
| > status | str | The status of the membership. The key is present only when `include.status` is `True`. |
| > type | str | The type of the membership. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the membership. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the membership. |
| total_count | int | The number of memberships of the user, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.set_memberships(
    uuid: str,
    channel_memberships: List[PNChannelMembership],
    include: MembershipIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes
from pubnub.models.consumer.objects_v2.memberships import PNChannelMembership
some_channel = "somechannel"
some_channel_with_custom = "somechannel_with_custom"

await pubnub.set_channel_metadata() \
    .channel(some_channel) \
    .set_name("some name") \
    .future()

custom_1 = {
    "key3": "val1",
    "key4": "val2",
}

await pubnub.set_channel_metadata() \
    .channel(some_channel_with_custom) \
    .set_name("some name with custom") \
    .custom(custom_1) \
    .future()

custom_2 = {
    "key5": "val1",
    "key6": "val2",
}

channel_memberships_to_set = [
    PNChannelMembership.channel(some_channel),
    PNChannelMembership.channel_with_custom(some_channel_with_custom, custom_2),
]

envelope = await pubnub.set_memberships() \
    .uuid("some_uuid") \
    .channel_memberships(channel_memberships_to_set) \
    .include(MembershipIncludes(custom=True, channel=True, channel_custom=True)) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes
from pubnub.models.consumer.objects_v2.memberships import PNChannelMembership

some_channel = "somechannel"
some_channel_with_custom = "somechannel_with_custom"

await pubnub.set_channel_metadata(channel=some_channel, name="some name").future()

custom_1 = {
    "key3": "val1",
    "key4": "val2",
}

await pubnub.set_channel_metadata(channel=some_channel_with_custom,
                                  name="some name with custom",
                                  custom=custom_1) \
    .future()

custom_2 = {
    "key5": "val1",
    "key6": "val2",
}

channel_memberships_to_set = [
    PNChannelMembership.channel(some_channel),
    PNChannelMembership.channel_with_custom(some_channel_with_custom, custom_2),
]

envelope = await pubnub.set_memberships(uuid="some_uuid_named",
                                        channel_memberships=channel_memberships_to_set,
                                        include=MembershipIncludes(custom=True, channel=True,
                                                                   channel_custom=True)) \
    .future()
```

## Remove channel memberships

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.remove_memberships()` removes channel memberships from one user through a PubNub client for Python-Asyncio and returns a page of the remaining memberships of that user.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Optional | n/a | The ID of the user to remove channel memberships from. When omitted, the SDK uses the `user_id` of the PubNub client. An empty string fails validation with the message `uuid missing or not a string`. |
| channel_memberships | List[PNChannelMembership] | Yes | n/a | The memberships to remove from the memberships of the user, as a list of `PNChannelMembership` objects. Build each one with `PNChannelMembership.channel()`, `PNChannelMembership.channel_with_custom()`, or the `PNChannelMembership` constructor. |
| include | MembershipIncludes | Optional | n/a | The fields to add to the result, as a `MembershipIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each membership in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each membership in the response includes its `type` field. |
| > channel | bool | Optional | `False` | Whether each membership includes the metadata of its channel in the `channel` object, such as `name` and `description`. |
| > channel_custom | bool | Optional | `False` | Whether the `channel` object of each membership includes the `custom` object of the channel. |
| > channel_status | bool | Optional | `False` | Whether the `channel` object of each membership includes the `status` of the channel. The `status` option controls the `status` of the membership instead. |
| > channel_type | bool | Optional | `False` | Whether the `channel` object of each membership includes the `type` of the channel. The `type` option controls the `type` of the membership instead. |
| include_custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of memberships of the user. Without it, `total_count` is `None`. The `total_count` field of `MembershipIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the memberships that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts memberships. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of memberships to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

### Returns

`remove_memberships()` resolves with an `AsyncioEnvelope` whose `result` is a `PNRemoveMembershipsResult` and whose `status` is a `PNStatus`. The `data` property lists the memberships that remain for the user.

#### PNRemoveMembershipsResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The memberships of the user on this page. |
| > channel | dict | The channel of the membership. With `include.channel` set to `True` it holds the channel metadata, including `id`, `name`, `description`, `updated`, and `eTag`. Otherwise it holds the `id` of the channel and the channel fields that the include object requests. |
| > status | str | The status of the membership. The key is present only when `include.status` is `True`. |
| > type | str | The type of the membership. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the membership. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the membership. |
| total_count | int | The number of memberships of the user, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.remove_memberships(
    uuid: str,
    channel_memberships: List[PNChannelMembership],
    include: MembershipIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes
from pubnub.models.consumer.objects_v2.memberships import PNChannelMembership
some_channel = "somechannel"

envelope = await pubnub.remove_memberships() \
    .uuid("some_uuid") \
    .channel_memberships([PNChannelMembership.channel(some_channel)]) \
    .include(MembershipIncludes(custom=True, channel=True, channel_custom=True)) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes
from pubnub.models.consumer.objects_v2.memberships import PNChannelMembership

envelope = await pubnub.remove_memberships(uuid="some_uuid_named",
                                           channel_memberships=[PNChannelMembership.channel(some_channel)],
                                           include=MembershipIncludes(custom=True, channel=True,
                                                                      channel_custom=True)) \
    .future()
```

## Get channel members

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.get_channel_members()` returns a page of the members of one channel through a PubNub client for Python-Asyncio. A member is a user that has a membership in the channel.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel to get members for. A request without a channel fails validation with the message `Channel missing`. |
| include | MemberIncludes | Optional | n/a | The fields to add to the result, as a `MemberIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each member in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each member in the response includes its `type` field. |
| > user | bool | Optional | `False` | Whether each member includes the metadata of its user in the `uuid` object, such as `name` and `email`. |
| > user_custom | bool | Optional | `False` | Whether the `uuid` object of each member includes the `custom` object of the user. |
| > user_status | bool | Optional | `False` | Whether the `uuid` object of each member includes the `status` of the user. The `status` option controls the `status` of the member instead. |
| > user_type | bool | Optional | `False` | Whether the `uuid` object of each member includes the `type` of the user. The `type` option controls the `type` of the member instead. |
| include_custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of members of the channel. Without it, `total_count` is `None`. The `total_count` field of `MemberIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the members that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts members. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of members to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

### Returns

`get_channel_members()` resolves with an `AsyncioEnvelope` whose `result` is a `PNGetChannelMembersResult` and whose `status` is a `PNStatus`.

#### PNGetChannelMembersResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The members of the channel on this page. |
| > uuid | dict | The user of the member. With `include.user` set to `True` it holds the user metadata, including `id`, `name`, `email`, `updated`, and `eTag`. Otherwise it holds the `id` of the user and the user fields that the include object requests. |
| > status | str | The status of the member. The key is present only when `include.status` is `True`. |
| > type | str | The type of the member. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the member. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the member. |
| total_count | int | The number of members of the channel, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.get_channel_members(
    channel: str,
    include: MemberIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.common import MemberIncludes
envelope = await pubnub.get_channel_members() \
    .channel("channel_id") \
    .include(MemberIncludes(custom=True, user=True, user_custom=True)) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MemberIncludes

envelope = await pubnub.get_channel_members(channel="channel_id",
                                            include=MemberIncludes(custom=True, user=True,
                                                                   user_custom=True)) \
    .future()
```

## Set channel members

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.set_channel_members()` sets members for one channel through a PubNub client for Python-Asyncio and returns a page of the members of that channel.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel to set members for. A request without a channel fails validation with the message `Channel missing`. |
| uuids | List[PNUserMember] | Yes | n/a | The members to set for the channel, as a list of `PNUserMember` objects. The call adds the members that you pass and keeps the other members of the channel. |
| include | MemberIncludes | Optional | n/a | The fields to add to the result, as a `MemberIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each member in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each member in the response includes its `type` field. |
| > user | bool | Optional | `False` | Whether each member includes the metadata of its user in the `uuid` object, such as `name` and `email`. |
| > user_custom | bool | Optional | `False` | Whether the `uuid` object of each member includes the `custom` object of the user. |
| > user_status | bool | Optional | `False` | Whether the `uuid` object of each member includes the `status` of the user. The `status` option controls the `status` of the member instead. |
| > user_type | bool | Optional | `False` | Whether the `uuid` object of each member includes the `type` of the user. The `type` option controls the `type` of the member instead. |
| include_custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of members of the channel. Without it, `total_count` is `None`. The `total_count` field of `MemberIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the members that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts members. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of members to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

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

### Returns

`set_channel_members()` resolves with an `AsyncioEnvelope` whose `result` is a `PNSetChannelMembersResult` and whose `status` is a `PNStatus`. The `data` property lists the members of the channel after the change.

#### PNSetChannelMembersResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The members of the channel on this page. |
| > uuid | dict | The user of the member. With `include.user` set to `True` it holds the user metadata, including `id`, `name`, `email`, `updated`, and `eTag`. Otherwise it holds the `id` of the user and the user fields that the include object requests. |
| > status | str | The status of the member. The key is present only when `include.status` is `True`. |
| > type | str | The type of the member. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the member. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the member. |
| total_count | int | The number of members of the channel, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.set_channel_members(
    channel: str,
    uuids: List[PNUserMember],
    include: MemberIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.channel_members import PNUserMember
from pubnub.models.consumer.objects_v2.common import MemberIncludes
await pubnub.set_uuid_metadata() \
    .uuid("some_uuid") \
    .set_name("some name") \
    .future()

custom_1 = {
    "key3": "val1",
    "key4": "val2"
}

await pubnub.set_uuid_metadata() \
    .uuid("some_uuid_with_custom") \
    .set_name("some name with custom") \
    .custom(custom_1) \
    .future()

custom_2 = {
    "key5": "val1",
    "key6": "val2"
}

uuids_to_set = [
    PNUserMember(user_id="some_uuid"),
    PNUserMember(user_id="some_uuid_with_custom", custom=custom_2)
]

envelope = await pubnub.set_channel_members() \
    .channel("channel_id") \
    .uuids(uuids_to_set) \
    .include(MemberIncludes(custom=True, user=True, user_custom=True)) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MemberIncludes
from pubnub.models.consumer.objects_v2.channel_members import PNUserMember

await pubnub.set_uuid_metadata(uuid="some_uuid", name="some name").future()

custom_1 = {
    "key3": "val1",
    "key4": "val2"
}

await pubnub.set_uuid_metadata(uuid="some_uuid_with_custom",
                               name="some name with custom",
                               custom=custom_1) \
    .future()

custom_2 = {
    "key5": "val1",
    "key6": "val2"
}

uuids_to_set = [
    PNUserMember(user_id="some_uuid"),
    PNUserMember(user_id="some_uuid_with_custom", custom=custom_2)
]

envelope = await pubnub.set_channel_members(channel="channel_id_named",
                                            uuids=uuids_to_set,
                                            include=MemberIncludes(custom=True, user=True,
                                                                   user_custom=True)) \
    .future()
```

## Remove channel members

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.remove_channel_members()` removes members from one channel through a PubNub client for Python-Asyncio and returns a page of the remaining members of that channel.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel to remove members from. A request without a channel fails validation with the message `Channel missing`. |
| uuids | List[PNUserMember] | Yes | n/a | The members to remove from the members of the channel, as a list of `PNUserMember` objects. |
| include | MemberIncludes | Optional | n/a | The fields to add to the result, as a `MemberIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each member in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each member in the response includes its `type` field. |
| > user | bool | Optional | `False` | Whether each member includes the metadata of its user in the `uuid` object, such as `name` and `email`. |
| > user_custom | bool | Optional | `False` | Whether the `uuid` object of each member includes the `custom` object of the user. |
| > user_status | bool | Optional | `False` | Whether the `uuid` object of each member includes the `status` of the user. The `status` option controls the `status` of the member instead. |
| > user_type | bool | Optional | `False` | Whether the `uuid` object of each member includes the `type` of the user. The `type` option controls the `type` of the member instead. |
| include_custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of members of the channel. Without it, `total_count` is `None`. The `total_count` field of `MemberIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the members that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts members. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of members to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

### Returns

`remove_channel_members()` resolves with an `AsyncioEnvelope` whose `result` is a `PNRemoveChannelMembersResult` and whose `status` is a `PNStatus`. The `data` property lists the members that remain in the channel.

#### PNRemoveChannelMembersResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The members of the channel on this page. |
| > uuid | dict | The user of the member. With `include.user` set to `True` it holds the user metadata, including `id`, `name`, `email`, `updated`, and `eTag`. Otherwise it holds the `id` of the user and the user fields that the include object requests. |
| > status | str | The status of the member. The key is present only when `include.status` is `True`. |
| > type | str | The type of the member. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the member. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the member. |
| total_count | int | The number of members of the channel, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.remove_channel_members(
    channel: str,
    uuids: List[PNUserMember],
    include: MemberIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.common import MemberIncludes
from pubnub.models.consumer.objects_v2.channel_members import PNUserMember
envelope = await pubnub.remove_channel_members() \
    .channel("channel_id") \
    .uuids([PNUserMember(user_id="some_uuid")]) \
    .include(MemberIncludes(custom=True, user=True, user_custom=True)) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MemberIncludes
from pubnub.models.consumer.objects_v2.channel_members import PNUserMember

envelope = await pubnub.remove_channel_members(channel="channel_id_named",
                                               uuids=[PNUserMember(user_id="some_uuid")],
                                               include=MemberIncludes(custom=True, user=True,
                                                                      user_custom=True)) \
    .future()
```

## Manage channel memberships

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.manage_memberships()` sets and removes channel memberships of one user in one request through a PubNub client for Python-Asyncio.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Optional | n/a | The ID of the user to manage channel memberships for. When omitted, the SDK uses the `user_id` of the PubNub client. An empty string fails validation with the message `uuid missing or not a string`. |
| channel_memberships_to_set | List[PNChannelMembership] | Optional | n/a | The memberships to set for the user, as a list of `PNChannelMembership` objects. Build each one with `PNChannelMembership.channel()`, `PNChannelMembership.channel_with_custom()`, or the `PNChannelMembership` constructor. The call adds the memberships that you pass and keeps the other memberships of the user. The builder method is `set()`. |
| channel_memberships_to_remove | List[PNChannelMembership] | Optional | n/a | The memberships to remove from the memberships of the user, as a list of `PNChannelMembership` objects. Build each one with `PNChannelMembership.channel()`, `PNChannelMembership.channel_with_custom()`, or the `PNChannelMembership` constructor. The builder method is `remove()`. |
| include | MembershipIncludes | Optional | n/a | The fields to add to the result, as a `MembershipIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each membership in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each membership in the response includes its `type` field. |
| > channel | bool | Optional | `False` | Whether each membership includes the metadata of its channel in the `channel` object, such as `name` and `description`. |
| > channel_custom | bool | Optional | `False` | Whether the `channel` object of each membership includes the `custom` object of the channel. |
| > channel_status | bool | Optional | `False` | Whether the `channel` object of each membership includes the `status` of the channel. The `status` option controls the `status` of the membership instead. |
| > channel_type | bool | Optional | `False` | Whether the `channel` object of each membership includes the `type` of the channel. The `type` option controls the `type` of the membership instead. |
| include_custom | bool | Optional | `False` | Whether each membership in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of memberships of the user. Without it, `total_count` is `None`. The `total_count` field of `MembershipIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the memberships that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts memberships. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of memberships to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

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

### Returns

`manage_memberships()` resolves with an `AsyncioEnvelope` whose `result` is a `PNManageMembershipsResult` and whose `status` is a `PNStatus`. The `data` property lists the memberships of the user after the change.

#### PNManageMembershipsResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The memberships of the user on this page. |
| > channel | dict | The channel of the membership. With `include.channel` set to `True` it holds the channel metadata, including `id`, `name`, `description`, `updated`, and `eTag`. Otherwise it holds the `id` of the channel and the channel fields that the include object requests. |
| > status | str | The status of the membership. The key is present only when `include.status` is `True`. |
| > type | str | The type of the membership. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the membership. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the membership. |
| total_count | int | The number of memberships of the user, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.manage_memberships(
    uuid: str,
    channel_memberships_to_set: List[PNChannelMembership],
    channel_memberships_to_remove: List[PNChannelMembership],
    include: MembershipIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes
from pubnub.models.consumer.objects_v2.memberships import PNChannelMembership
some_channel = "somechannel"
some_channel_with_custom = "somechannel_with_custom"

envelope = await pubnub.manage_memberships() \
    .uuid("some_uuid") \
    .set([PNChannelMembership.channel(some_channel)]) \
    .remove([PNChannelMembership.channel(some_channel_with_custom)]) \
    .include(MembershipIncludes(custom=True, channel=True, channel_custom=True)) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MembershipIncludes
from pubnub.models.consumer.objects_v2.memberships import PNChannelMembership

envelope = await pubnub.manage_memberships(uuid="some_uuid_named",
                                           channel_memberships_to_set=[
                                               PNChannelMembership.channel(some_channel)],
                                           channel_memberships_to_remove=[
                                               PNChannelMembership.channel(some_channel_with_custom)],
                                           include=MembershipIncludes(custom=True, channel=True,
                                                                      channel_custom=True)) \
    .future()
```

## Manage channel members

This method requires that the App Context add-on is [enabled](https://www.pubnub.com/docs/faq/getting-started.md#how-do-i-enable-an-add-on-feature-on-my-keyset) for your key in the [Admin Portal](https://admin.pubnub.com/). Related: [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md).

`pubnub.manage_channel_members()` sets and removes members of one channel in one request through a PubNub client for Python-Asyncio.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel to manage members for. A request without a channel fails validation with the message `Channel missing`. |
| uuids_to_set | List[PNUserMember] | Optional | n/a | The members to set for the channel, as a list of `PNUserMember` objects. The call adds the members that you pass and keeps the other members of the channel. The builder method is `set()`. |
| uuids_to_remove | List[PNUserMember] | Optional | n/a | The members to remove from the members of the channel, as a list of `PNUserMember` objects. The builder method is `remove()`. |
| include | MemberIncludes | Optional | n/a | The fields to add to the result, as a `MemberIncludes` object. By default the result has none of them. The SDK ignores `include_custom` when you pass `include`. |
| > custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. |
| > status | bool | Optional | `False` | Whether each member in the response includes its `status` field. |
| > type | bool | Optional | `False` | Whether each member in the response includes its `type` field. |
| > user | bool | Optional | `False` | Whether each member includes the metadata of its user in the `uuid` object, such as `name` and `email`. |
| > user_custom | bool | Optional | `False` | Whether the `uuid` object of each member includes the `custom` object of the user. |
| > user_status | bool | Optional | `False` | Whether the `uuid` object of each member includes the `status` of the user. The `status` option controls the `status` of the member instead. |
| > user_type | bool | Optional | `False` | Whether the `uuid` object of each member includes the `type` of the user. The `type` option controls the `type` of the member instead. |
| include_custom | bool | Optional | `False` | Whether each member in the response includes its `custom` object. The SDK ignores it when you pass `include`. |
| include_total_count | bool | Optional | `False` | Whether the result includes `total_count`, the number of members of the channel. Without it, `total_count` is `None`. The `total_count` field of `MemberIncludes` requests the total count too. |
| filter | str | Optional | n/a | The filter expression. The response includes only the members that match it. See [filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). |
| sort_keys | List[PNSortKey] | Optional | n/a | The sort order of the result, as a list of `PNSortKey` objects. Build each one with `PNSortKey.asc()` or `PNSortKey.desc()` and a `PNSortKeyValue` of ID, NAME, or UPDATED. Only `PNSortKeyValue.UPDATED` sorts members. The other values make PubNub return HTTP status 400. The builder method is `sort()`, and it takes the keys as separate arguments. |
| limit | int | Optional | `100` | The maximum number of members to return in one response. The maximum value is `100`. |
| page | PNPage | Optional | n/a | The page to return, as a `Next` or `Previous` object from `pubnub.models.consumer.objects_v2.page`. Pass the `next` or `prev` property of an earlier result, which already has that type. |

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

### Returns

`manage_channel_members()` resolves with an `AsyncioEnvelope` whose `result` is a `PNManageChannelMembersResult` and whose `status` is a `PNStatus`. The `data` property lists the members of the channel after the change.

#### PNManageChannelMembersResult

| Property | Type | Description |
| --- | --- | --- |
| status | int | The HTTP status code of the response. |
| data | List[dict] | The members of the channel on this page. |
| > uuid | dict | The user of the member. With `include.user` set to `True` it holds the user metadata, including `id`, `name`, `email`, `updated`, and `eTag`. Otherwise it holds the `id` of the user and the user fields that the include object requests. |
| > status | str | The status of the member. The key is present only when `include.status` is `True`. |
| > type | str | The type of the member. The key is present only when `include.type` is `True`. |
| > custom | dict | The custom data of the member. The key is present only when `include_custom or include.custom` is `True`. |
| > updated | str | The date and time of the last update, in ISO 8601 format. |
| > eTag | str | The version hash of the member. |
| total_count | int | The number of members of the channel, or `None` when `include_total_count` is not `True`. |
| next | Next | A `Next` object for the next page, or `None` when there is no next page. |
| prev | Previous | A `Previous` object for the previous page, or `None` when there is no previous page. |

### Examples

#### Syntax

```python
await pubnub.manage_channel_members(
    channel: str,
    uuids_to_set: List[PNUserMember],
    uuids_to_remove: List[PNUserMember],
    include: MemberIncludes,
    include_custom: bool,
    include_total_count: bool,
    filter: str,
    sort_keys: List[PNSortKey],
    limit: int,
    page: PNPage
).future() -> AsyncioEnvelope
```

#### Basic usage (Builder Pattern)

```python
from pubnub.models.consumer.objects_v2.channel_members import PNUserMember
from pubnub.models.consumer.objects_v2.common import MemberIncludes
envelope = await pubnub.manage_channel_members() \
    .channel("channel_id") \
    .set([PNUserMember(user_id="some_uuid")]) \
    .remove([PNUserMember(user_id="some_uuid_with_custom")]) \
    .include(MemberIncludes(custom=True, user=True, user_custom=True)) \
    .future()
```

#### Basic usage (Named Arguments)

```python
from pubnub.models.consumer.objects_v2.common import MemberIncludes
from pubnub.models.consumer.objects_v2.channel_members import PNUserMember

envelope = await pubnub.manage_channel_members(channel="channel_id_named",
                                               uuids_to_set=[PNUserMember(user_id="some_uuid")],
                                               uuids_to_remove=[PNUserMember(user_id="some_uuid_with_custom")],
                                               include=MemberIncludes(custom=True, user=True,
                                                                      user_custom=True)) \
    .future()
```

## PNChannelMembership class

`PNChannelMembership` describes one channel membership that you pass to the membership methods of the Python-Asyncio SDK. The factory methods `PNChannelMembership.channel(channel)` and `PNChannelMembership.channel_with_custom(channel, custom)` build one without or with custom data, and the constructor also sets a status and a type.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channel | str | Yes | n/a | The ID of the channel. |
| custom | dict | Optional | n/a | The custom data of the membership. The factory method `channel_with_custom()` takes it as its second argument. |
| status | str | Optional | n/a | The status of the membership. |
| type | str | Optional | n/a | The type of the membership. |

### Examples for PNChannelMembership class

#### Syntax

```python
PNChannelMembership(
    channel: str,
    custom: dict,
    status: str,
    type: str
)
```

#### Basic usage

```python
from pubnub.models.consumer.objects_v2.memberships import PNChannelMembership
membership = PNChannelMembership.channel("somechannel")
membership_with_custom = PNChannelMembership.channel_with_custom("somechannel_with_custom",
                                                                 {"key5": "val1", "key6": "val2"})
```

## PNUserMember class

`PNUserMember` describes one member of a channel that you pass to the member methods of the Python-Asyncio SDK. It replaces the deprecated factory methods of `PNUUID`.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| user_id | str | Yes | n/a | The ID of the user. |
| type | str | Optional | n/a | The type of the member. |
| status | str | Optional | n/a | The status of the member. |
| custom | dict | Optional | n/a | The custom data of the member. |

### Examples for PNUserMember class

#### Syntax

```python
PNUserMember(
    user_id: str,
    type: str,
    status: str,
    custom: dict
)
```

## PNUUID class

`PNUUID` builds member objects in the Python-Asyncio SDK, and its factory methods are deprecated in favor of `PNUserMember`. The methods `PNUUID.uuid(uuid)` and `PNUUID.uuid_with_custom(uuid, custom)` issue a `DeprecationWarning` and still work.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| uuid | str | Yes | n/a | The ID of the user. |
| custom | dict | Yes | n/a | The custom data of the member. Only `uuid_with_custom()` takes it. |

### Examples for PNUUID class

#### Syntax

```python
PNUUID.uuid(
    uuid: str
) -> JustUUID

PNUUID.uuid_with_custom(
    uuid: str,
    custom: dict
) -> UUIDWithCustom
```

#### Basic usage

The sample builds the same members with `PNUserMember`, which replaces these methods.

```python
from pubnub.models.consumer.objects_v2.channel_members import PNUserMember
member = PNUserMember(user_id="some_uuid")
member_with_custom = PNUserMember(user_id="some_uuid_with_custom", custom={"key5": "val1", "key6": "val2"})
```

Last updated at: 2026-11-25T12:28:11.000Z
