---
source_url: https://www.pubnub.com/docs/chat/kotlin-chat-sdk/learn/chat-entities/membership
title: Membership object
updated_at: 2026-06-15T12:11:38.426Z
---

> 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


# Membership object

`Membership` represents a single user-channel relationship in a chat.

## Properties

The `Membership` interface has the following properties:

```kotlin
interface Membership {
    val chat: Chat
    val channel: Channel
    val user: User
    val custom: Map<String, Any?>?
    val updated: String?
    val eTag: String?
    val lastReadMessageTimetoken: Long?
    val status: String?
    val type: String?
    ...
}
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| chat | Chat | Optional |  | Reference to the main `Chat` object. |
| channel | Channel | Optional |  | [Channel object](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/learn/chat-entities/channel). |
| user | User | Optional |  | [User object](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/learn/chat-entities/user). |
| custom | Map<String, | Optional |  | Any custom properties or metadata associated with the user-channel relationship in the form of a map of key-value pairs. [App Context filtering language](https://www.pubnub.com/docs/general/metadata/filtering) doesn’t support filtering by custom properties. |
| updated | String | Optional |  | Last time the `Membership` object was changed. |
| eTag | String | Optional |  | Caching value that changes whenever the `Membership` object changes. |
| lastReadMessageTimetoken | Long | Optional |  | Timetoken of the last message a user read on a given channel. |
| status | String? | Optional |  | Current status of the membership, like `active` or `inactive`. |
| type | String? | Optional |  | Type of the membership, used to categorize the user-channel relationship. |

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

## Methods

The `Membership` object exposes the following methods and properties.

### Regular methods

* [delete()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#delete-membership)
* [getUnreadMessagesCount()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/unread#get-unread-messages-count-one-channel)
* [lastReadMessageTimetoken](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/unread#get-last-read-message)
* [setLastReadMessage()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/unread#mark-messages-as-read-one-channel)
* [setLastReadMessageTimetoken()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/unread#mark-messages-as-read-one-channel)
* [update()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#update)

### Event listeners

* [onDeleted()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#get-updates)
* [onUpdated()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#get-updates)
* streamUpdates() (deprecated)
* [streamUpdatesOn()](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#get-updates)

## Use case

`Membership` methods enable:

* [Updating](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#update) user-channel relationships and [getting updates](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#get-updates) on changes
* Receiving real-time [updates](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/channels/membership#get-updates) when memberships are modified or deleted
* Tracking the [last message read](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/unread#mark-messages-as-read-one-channel) by a user on a channel
* Getting the count of [unread messages](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/messages/unread#get-unread-messages-count-one-channel) for a user