---
source_url: https://www.pubnub.com/docs/sdks/kotlin/entities/channel
title: Channel Entity
updated_at: 2026-06-12T11:25:46.391Z
sdk_name: PubNub Kotlin SDK
sdk_version: 13.4.0
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Channel Entity

PubNub Kotlin SDK, use the latest version: 13.4.0

Install:

```bash
Add PubNub dependency to your build@13.4.0
```

As of version 9.0.0, the Kotlin software development kit (SDK) supports entities. Entities are SDK objects that bundle operations for a specific resource type and simplify working with PubNub application programming interfaces (APIs).

Use entities to perform common tasks without manually wiring requests. Some PubNub APIs are exposed via entities. Other operations remain available on the `pubnub` object.

## Create a Channel

Use this factory method to return a local `Channel` entity for a single channel. A Channel entity centralizes common operations—such as subscribing and publishing—so you can prototype and build faster.

```kotlin
pubnub.channel(name: String): Channel
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| name | String | Yes |  | Name of the [channel](https://www.pubnub.com/docs/general/channels/overview) for which to create the entity. |

#### Sample code

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

```kotlin
import com.pubnub.api.PubNub
import com.pubnub.api.UserId
import com.pubnub.api.v2.PNConfiguration

fun main() {
    println("PubNub Channel Entity Example")
    println("============================")

    // 1. Configure PubNub
    val userId = UserId("channel-entity-demo-user")
    val config = PNConfiguration.builder(userId, "demo").apply {
        publishKey = "demo"
        subscribeKey = "demo"
    }.build()

    // 2. Create PubNub instance
    val pubnub = PubNub.create(config)

    // 3. Create a channel entity
    val channelName = "demo-entity-channel"
    val channel = pubnub.channel(channelName)
    println("Created Channel entity for: $channelName.")

    // 4. Publish a message via the channel entity
    println("\nPublishing message via Channel entity...")
    channel.publish(
        message = mapOf(
            "text" to "Hello from Channel entity!",
            "sender" to "channel-entity-demo-user",
            "timestamp" to System.currentTimeMillis()
        )
    ).async { result ->
        result.onSuccess { response ->
            println("SUCCESS: Message published via Channel entity")
            println("Timetoken: ${response.timetoken}")
        }.onFailure { exception ->
            println("ERROR: Failed to publish message")
            println("Error details: ${exception.message}")
        }
    }

    // Wait for the publish operation to complete
    Thread.sleep(2000)

    // Clean up
    pubnub.destroy()
    println("\nPubNub connection closed")
}
```

## Available operations

The `Channel` entity provides operations for PubNub [channels](https://www.pubnub.com/docs/general/channels/overview).

| Operation (click for more information) | Description |
| --- | --- |
| [subscription(subscriptionOptions)](https://www.pubnub.com/docs/sdks/kotlin/api-reference/publish-and-subscribe#subscribe) | Returns a local channel [subscription object](https://www.pubnub.com/docs/general/channels/subscribe#subscription-types) with [optional parameters](https://www.pubnub.com/docs/general/channels/subscribe#subscription-options). You can then subscribe to receive real-time updates for that channel. |
| [publish(message, shouldStore, meta, queryParam, usePost, ttl)](https://www.pubnub.com/docs/sdks/kotlin/api-reference/publish-and-subscribe#publish) | Sends a message to all channel subscribers. |
| [fire(message, meta, usePost)](https://www.pubnub.com/docs/sdks/kotlin/api-reference/publish-and-subscribe#fire) | Sends a message to [Illuminate](https://www.pubnub.com/docs/illuminate/business-objects/external-data-sources) and [Functions](https://www.pubnub.com/docs/serverless/functions/overview#on-request-functions) event handlers registered on the channel and triggers their execution. |
| [signal(message, meta, usePost)](https://www.pubnub.com/docs/sdks/kotlin/api-reference/publish-and-subscribe#signal) | Sends a signal to all subscribers of the channel. |

## Terms in this document

* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
* **Channel pattern** - A way to group and analyze channel data to track performance metrics like message counts and user engagement over time with PubNub Insights.
* **Signal** - A non-persistent message limited to 64 bytes designed for high-volume usecases where the the most recent data is relevant, like GPS location updates.