---
source_url: https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/invite
title: Invite users to channels
updated_at: 2026-06-01T12:01:18.277Z
---

> 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


# Invite users to channels

:::note Requires App Context
Enable [App Context](https://youtu.be/9UEoSlngpYI) for your keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

Invite users to private or group conversations, creating their channel [membership](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/membership). Invitations trigger an [invite event](https://www.pubnub.com/docs/chat/chat-sdk/build/features/custom-events#events-for-channel-initations) that you can [listen to](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/invite#listen-to-invite-events) and notify invited users.

To send notifications on invitations, implement custom logic to:

* [Create and send custom events](https://www.pubnub.com/docs/chat/chat-sdk/build/features/custom-events#create-and-send-events) when invitations are sent
* Let invited users [receive these events](https://www.pubnub.com/docs/chat/chat-sdk/build/features/custom-events#receive-current-events)

## Invite one user

Request a user to join a channel with `invite()`.

##### Under the hood

`invite()` calls App Context API and the JavaScript SDK [setMemberships()](https://www.pubnub.com/docs/sdks/javascript/api-reference/objects#set-channel-memberships) method.

### Method signature

This method takes the following parameters:

```ts
channel.invite(user: User): Promise<Membership>
```

#### Input

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| user | User | Yes |  | User that you want to invite. |

#### Output

| Type | Description |
| --- | --- |
| `Promise<Membership>` | Returned (modified) object containing the membership data. |

### Sample code

Invite `support-agent-15` to join the `high-prio-incidents` channel.

```ts
// reference "support-agent-15"
const user = await chat.getUser("support_agent_15")

// reference the "high-prio-incidents" channel
const channel = await chat.getChannel("high-prio-incidents")

// invite the agent to join the channel
await channel.invite(user)
```

## Invite multiple users

Request multiple users to join a channel with `inviteMultiple()`. Maximum 100 users per call.

##### Under the hood

`inviteMultiple()` calls App Context API and the JavaScript SDK [setChannelMembers()](https://www.pubnub.com/docs/sdks/javascript/api-reference/objects#set-channel-members) method that sets a maximum limit of `100` to a number of user-channel memberships that can be updated in one call.

### Method signature

This method takes the following parameters:

```ts
channel.inviteMultiple(users: User[]): Promise<Membership[]>
```

#### Input

| Parameter | Description |
| --- | --- |
| `users` *Type: `User[]`Default: n/a | List of users you want to invite to the group channel. You can invite up to 100 users in one call. |

#### Output

| Type | Description |
| --- | --- |
| `Promise<Membership[]>` | Returned (modified) list of objects containing the membership data. |

### Sample code

Invite `support-agent-15` and `support-agent-16` to join the `high-prio-incidents` channel.

```ts
// reference both agents
const user1 = await chat.getUser("support_agent_15")
const user2 = await chat.getUser("support_agent_16")

// reference the "high-prio-incidents" channel
const channel = await chat.getChannel("high-prio-incidents")

// invite both agents to join the channel
await channel.inviteMultiple([
  user1,
  user2
])
```

## Get invitees

`getInvitees()` returns the list of channel members whose membership status is "pending" (invited but not yet joined).

##### Under the hood

`getInvitees()` calls App Context API and the JavaScript SDK [getChannelMembers()](https://www.pubnub.com/docs/sdks/javascript/api-reference/objects#get-channel-members) method, filtering results to members with a pending status.

### Method signature

This method takes the following parameters:

```ts
channel.getInvitees(params?: Omit<AppContext.GetMembersParameters, "channel" | "include">): Promise<{
    page: {
        next: string | undefined;
        prev: string | undefined;
    };
    total: number | undefined;
    status: number;
    members: Membership[];
}>
```

#### Input

| Parameter | Description |
| --- | --- |
| `params`Type: `object`Default: n/a | Optional pagination and filtering parameters. Same shape as [getMembers()](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/membership#get-channel-members). |
| `params.limit`Type: `number`Default: `100` | Number of objects to return in response. The default (and maximum) value is `100`. |
| `params.page`Type: `object`Default: n/a | Object used for pagination (`next`/`prev` cursors). |
| `params.filter`Type: `string`Default: n/a | Expression used to filter the results. This filter is combined with the pending status filter. |
| `params.sort`Type: `object`Default: n/a | Key-value pairs for result sorting. |

#### Output

| Type | Description |
| --- | --- |
| `Promise<{page, total, status, members}>` | Object containing only pending (invited) members. Has the same structure as the response from [getMembers()](https://www.pubnub.com/docs/chat/chat-sdk/build/features/channels/membership#get-channel-members). |

### Sample code

Get all pending invitees for the `high-prio-incidents` channel.

```ts
// reference the "high-prio-incidents" channel
const channel = await chat.getChannel("high-prio-incidents")

// get members with pending (invited) status
const { members } = await channel.getInvitees()

members.forEach((membership) => {
    console.log("Pending invitee:", membership.user.id)
})
```

## Listen to invite events

Monitor invitation events with `onInvited()` on the `User` object. This replaces the deprecated `listenForEvents()` approach with a typed callback.

:::warning Deprecated method
`listenForEvents({ type: "invite" })` is deprecated. Use `user.onInvited()` instead, which provides a typed `Invite` object with richer data.
:::

### Method signature

```ts
user.onInvited(callback: (invite: Invite) => void): () => void
```

#### Input

| Parameter | Description |
| --- | --- |
| `callback` *Type: `(invite: Invite) => void`Default: n/a | Function invoked with an `Invite` event whenever the user receives a channel invitation. |

The `Invite` object contains:

| Property | Description |
| --- | --- |
| `channelId`Type: `string` | The channel the user is invited to. |
| `channelType`Type: `ChannelType` | Type of the channel (direct, group, etc.). |
| `invitedByUserId`Type: `string` | User ID of who sent the invitation. |
| `invitationTimetoken`Type: `string` | Timetoken of the invitation. |

#### Output

| Type | Description |
| --- | --- |
| `() => void` | Function you can call to stop receiving invitation events. |

### Sample code

```ts
const user = chat.currentUser

const stopListening = user.onInvited((invite) => {
    console.log(`Invited to channel ${invite.channelId} (${invite.channelType}) by ${invite.invitedByUserId}`)
})

// stop listening:
// stopListening()
```