---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/list
title: List all users
updated_at: 2026-06-19T11:35:23.410Z
---

> 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


# List all users

`GetUsers()` returns a paginated list of all users with their metadata.

:::note Requires App Context
Enable [App Context](https://youtu.be/9UEoSlngpYI) in the [Admin Portal](https://admin.pubnub.com/) to store user data. If using [Access Manager](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/permissions), uncheck `Disallow Get All User Metadata` in the [App Context configuration](https://www.pubnub.com/docs/general/metadata/basics#configuration).
:::

### Method signature

This method takes the following parameters:

```csharp
chat.GetUsers(
    string filter = "",
    string sort = "",
    int limit = 0,
    PNPageObject page = null
)
```

#### Input

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| filter | string | Optional | `empty string` | Expression used to filter the results. Returns only these memberships whose properties satisfy the given expression. The filter language is [defined here](https://www.pubnub.com/docs/general/metadata/filtering). |
| sort | string | Optional | `empty string` | Key-value pair of a property to sort by, and a sort direction. Available options are `id`, `name`, and `updated`. Use `asc` or `desc` to specify the sorting direction, or specify `null` to take the default sorting direction (ascending). For example: `{name: "asc"}`. By default, the items are sorted by the last updated date. |
| limit | int | Optional | `0` | Number of objects to return in response. |
| page | PNPageObject | Optional | `null` | Object used for pagination to define which previous or next result page you want to fetch. |

#### Output

| Type | Description |
| --- | --- |
| `Task<UsersResponseWrapper>` | An awaitable `Task` with an object containing the filtered, sorted, and paginated list of users. |

### Sample code

Fetch all existing user IDs.

```csharp
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// fetch all existing users
var usersWrapper = await chat.GetUsers();

// check if users were successfully fetched
if (!usersWrapper.Error)
{
    Debug.Log("Existing user IDs:");

    // loop through the users and print their IDs
    foreach (var user in usersWrapper.Result.Users)
    {
        Debug.Log(user.Id);
    }
}
else
{
    Debug.Log("No users found or unable to fetch users.");
}
```

### Other examples

#### Pagination

Get the total number of 25 users and then specify that you want to fetch the results from the next page using a string that was previously returned from the PubNub server.

```csharp
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// fetch the initial 25 users
var initialUsers = await chat.GetUsers(limit: 25);
if (initialUsers.Error)
{
    Debug.Log("Couldn't fetch initial users!");
    return;
}

Debug.Log("Initial 25 users:");
foreach (var user in initialUsers.Result.Users)
{
    Debug.Log($"Id: {user.Id}, UserName: {user.UserName}, Status: {user.Status}");
}

// fetch the next set of users using the pagination token
var nextUsers = await chat.GetUsers(limit: 25, page: initialUsers.Result.Page);
if (nextUsers.Error)
{
    Debug.Log("Couldn't fetch next users!");
    return;
}
        
Debug.Log("\nNext users:");
foreach (var user in nextUsers.Result.Users)
{
    Debug.Log($"Id: {user.Id}, UserName: {user.UserName}, Status: {user.Status}");
}
```

#### Deleted users

Return all users with the `deleted` status.

```csharp
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
var deletedUsers = await chat.GetUsers(filter: "Status='deleted'");
if (deletedUsers.Error)
{
    Debug.Log("Couldn't fetch deleted users!");
    return;
}

foreach (var user in deletedUsers.Result.Users)
{
    Debug.Log($"Id: {user.Id}, UserName: {user.UserName}, Status: {user.Status}");
}
```