---
source_url: https://www.pubnub.com/docs/data-storage/metadata/get-metadata-for-all-users
title: Get metadata for all users
updated_at: 2026-09-30T07:20:08.000Z
---

# Get metadata for all users

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

:::note Starting a new app? Use DataSync
[DataSync](https://www.pubnub.com/docs/data-storage/structured-data/overview.md) is the successor to App Context. It does everything App Context does for users, channels, and memberships, and adds typed schemas, partial updates with ETags, field-level access control, and per-class expiry. Refer to [How DataSync compares to App Context](https://www.pubnub.com/docs/data-storage/structured-data/overview.md) for a feature-by-feature comparison.
DataSync is currently available to new accounts and to accounts that are not actively using App Context. If your keysets already use App Context, keep using it for now. App Context remains fully supported and these pages stay accurate.
:::

This guide shows you how to retrieve [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md) metadata for every user on your keyset instead of one, page through the results, and sort or filter them. App Context must be enabled on the keyset before you call it, and new keysets don't enable it by default. To read, write, or remove one user's own record, refer to [Set, get, and remove user metadata](https://www.pubnub.com/docs/data-storage/metadata/manage-user-metadata.md) instead.

## Get all user metadata

Call `Get All UUID Metadata` with no User ID. Pass `include.customFields` to receive each user's `custom` object, and `include.totalCount` to receive the total number of users on the keyset alongside the page you asked for.

### JavaScript

```javascript
// Function to get all UUID metadata
// to get some data in response, add user metadata using setUUIDMetadata method
async function getAllUUIDMetadata() {
  try {
    const response = await pubnub.objects.getAllUUIDMetadata();
    console.log('getAllUUIDMetadata response:', response);
  } catch (error) {
    console.error(`Get all UUID metadata error: ${error}`);
  }
}

// Execute the function to get UUID metadata
getAllUUIDMetadata();
```

### Java

```java
import com.pubnub.api.PubNubException;
import com.pubnub.api.UserId;
import com.pubnub.api.java.PubNub;
import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey;
import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata;
import com.pubnub.api.java.v2.PNConfiguration;

import java.util.Arrays;
import java.util.List;

public class GetAllUUIDMetadataApp {
    public static void main(String[] args) throws PubNubException {
        // Configure PubNub instance
        PNConfiguration.Builder configBuilder = PNConfiguration.builder(new UserId("demoUserId"), "demo");
        configBuilder.publishKey("demo");
        configBuilder.secure(true);

        PubNub pubnub = PubNub.create(configBuilder.build());

        // Get all UUID Metadata
        pubnub.getAllUUIDMetadata()
                .limit(20)
                .sort(Arrays.asList(PNSortKey.asc(PNSortKey.Key.ID), PNSortKey.desc(PNSortKey.Key.UPDATED)))
                .includeTotalCount(true)
                .includeCustom(true)
                .async(result -> {
                    result.onSuccess(res -> {
                        System.out.println("Total Count: " + res.getTotalCount());
                        List<PNUUIDMetadata> uuidMetadataList = res.getData();
                        for (PNUUIDMetadata metadata : uuidMetadataList) {
                            System.out.println("UUID: " + metadata.getId());
                            System.out.println("Name: " + metadata.getName().getValue());
                            System.out.println("Email: " + metadata.getEmail().getValue());
                            System.out.println("Custom: " + metadata.getCustom().getValue());
                        }
                    }).onFailure(exception -> {
                        System.out.println("Error retrieving UUID metadata: " + exception.getMessage());
                    });
                });
    }
}
```

### C#

```csharp
using PubnubApi;

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

// Initialize PubNub
Pubnub pubnub = new Pubnub(pnConfiguration);
        
try
{
    PNResult<PNGetAllUuidMetadataResult> getAllUuidMetadataResponse = await pubnub.GetAllUuidMetadata()
        .IncludeCustom(true)
        .IncludeCount(true)
        .ExecuteAsync();
            
    PNGetAllUuidMetadataResult getAllUuidMetadataResult = getAllUuidMetadataResponse.Result;
    PNStatus status = getAllUuidMetadataResponse.Status;

    if (!status.Error && getAllUuidMetadataResult != null)
    {
        Console.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(getAllUuidMetadataResult));
    }
    else
    {
        Console.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(status));
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Request cannot be executed due to error: {ex.Message}");
}
```

### Go

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"
	"time"

	pubnub "github.com/pubnub/go/v10"
)

// Example_getAllUUIDMetadataWithIncludes demonstrates listing all users with all include options
func Example_getAllUUIDMetadataWithIncludes() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo"
	config.PublishKey = "demo"

	pn := pubnub.NewPubNub(config)

	// Create user with all fields
	pn.SetUUIDMetadata().
		UUID("user-all-list-1").
		Name("Full User").
		Custom(map[string]interface{}{"role": "admin"}).
		Status("active").
		Type("staff").
		Execute()

	// Get all users with all include options
	response, status, err := pn.GetAllUUIDMetadata().
		Include([]pubnub.PNUUIDMetadataInclude{
			pubnub.PNUUIDMetadataIncludeCustom, // Include custom fields
			pubnub.PNUUIDMetadataIncludeStatus, // Include status field
			pubnub.PNUUIDMetadataIncludeType,   // Include type field
		}).
		Limit(10).
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 && len(response.Data) > 0 {
		fmt.Println("Retrieved users with all metadata fields")
	}

	// Output:
	// Retrieved users with all metadata fields
}
```

### Swift

```swift
// Retrieve all user metadata
pubnub.allUserMetadata { result in
  switch result {
  case let .success(response):
    print("The user metadata objects: \(response.users)")
    print("The next page used for pagination: \(String(describing: response.next))")
  case let .failure(error):
    print("Fetch All request failed with error: \(error.localizedDescription)")
  }
}
```

### PHP

```php
$getAllUserMetadataResult = $pubnub->getAllUuidMetadata()
    ->includeFields(['customFields' => true, 'totalCount' => true])
    ->limit(10)
    ->sync();
assert(count($getAllUserMetadataResult->getData()) >= 2);
assert($getAllUserMetadataResult->getTotalCount() >= 2);
assert(isInstanceOf($getAllUserMetadataResult->getData()[0], PNGetUUIDMetadataResult::class));
```

Most other SDKs, including Kotlin and Unity, document the same call in the App Context section of their API reference. Check [Available SDKs](https://www.pubnub.com/docs/sdks.md) for your platform.

If [Access Manager](https://www.pubnub.com/docs/security/access-control/overview.md) is enabled, the option for this call is **Disallow Get All User Metadata**. An App Context "get all" call needs no per-resource permission grant unless you've turned on the matching **Disallow Get All** option, in which case the token needs an explicit grant for that operation. Refer to [App Context and access control](https://www.pubnub.com/docs/data-storage/metadata/overview.md#app-context-and-access-control) for the full permission model.

## Page through the list

Every paginated App Context call takes the same three parameters. `limit` caps how many records come back in one call. It defaults to 100, and 100 is also the maximum. `page.next` and `page.prev` are opaque cursor strings copied from a previous response: pass the one you want to continue from, and PubNub returns the adjacent page in that direction. If you supply both, PubNub uses `next` and ignores `prev`.

To retrieve every user, keep calling `Get All UUID Metadata` with `page.next` set to the `next` value from the previous response. Stop when a response returns no `next` value. That's the last page.

## Sort the list

Pass `sort` to order the results by `id`, `name`, or `updated`, each with an ascending or descending direction, for example `{name: 'asc'}`. Without a `sort` parameter, the order isn't guaranteed to stay stable between calls. Check your platform's API reference in [Available SDKs](https://www.pubnub.com/docs/sdks.md) for the exact parameter shape.

The following example, in PHP, sorts both a user list and a channel list by name:

```php
// Sort users by name ascending
$sortedUsersAscResult = $pubnub->getAllUuidMetadata()
    ->sort(['name' => 'asc'])
    ->limit(5)
    ->sync();

echo "Users sorted by name (ascending): " . count($sortedUsersAscResult->getData()) . "\n";
foreach ($sortedUsersAscResult->getData() as $user) {
    echo "  - " . ($user->getName() ?: $user->getId()) . "\n";
}

// Sort users by updated time descending
$sortedUsersDescResult = $pubnub->getAllUuidMetadata()
    ->sort(['updated' => 'desc'])
    ->limit(3)
    ->sync();

echo "Users sorted by updated time (descending): " . count($sortedUsersDescResult->getData()) . "\n";

// Sort channels by name
$sortedChannelsResult = $pubnub->getAllChannelMetadata()
    ->sort(['name' => 'asc'])
    ->limit(5)
    ->sync();

echo "Channels sorted by name: " . count($sortedChannelsResult->getData()) . "\n";
```

## Filter the list

Pass `filter` to receive only the users matching a filter expression, such as `status == "active"` or `name LIKE "*Team"`, instead of paging through every user and filtering client-side. Refer to [App Context filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md) for the full field list, operators, and syntax.

```php
// Filter users by custom field (note: filtering by custom properties may have limitations)
$filteredUsersResult = $pubnub->getAllUuidMetadata()
    ->includeFields(['customFields' => true])
    ->filter("name LIKE '*Alice*'")
    ->sync();

echo "Filtered users (name contains 'Alice'): " . count($filteredUsersResult->getData()) . "\n";

// Filter channels by name
$filteredChannelsResult = $pubnub->getAllChannelMetadata()
    ->includeFields(['customFields' => true])
    ->filter("name LIKE '*General*'")
    ->sync();

echo "Filtered channels (name contains 'General'): " . count($filteredChannelsResult->getData()) . "\n";
```

## List users without code

[BizOps Workspace](https://www.pubnub.com/docs/data-storage/metadata/overview.md)'s **User Management** module lists every user on your keyset with the same filter and sort options, with no SDK call required. Refer to [User Management filters](https://www.pubnub.com/docs/data-storage/metadata/manage-user-metadata.md) for the quick search box, the **Filters** button, and advanced filtering with the same expression language as `filter`.

## Related tasks

* [App Context](https://www.pubnub.com/docs/data-storage/metadata/overview.md). The three entity types and how App Context relates to messages and [Presence](https://www.pubnub.com/docs/presence/overview.md).
* [Set, get, and remove user metadata](https://www.pubnub.com/docs/data-storage/metadata/manage-user-metadata.md). Read, write, or remove one user's own record.
* [App Context filtering](https://www.pubnub.com/docs/data-storage/metadata/filtering.md). The full filter field list, operators, and syntax.
* [App Context API limits](https://www.pubnub.com/docs/data-storage/metadata/api-limits.md). Recommended maximum user metadata records per keyset.

Last updated at: 2026-09-30T07:20:08.000Z
