---
source_url: https://www.pubnub.com/docs/general/metadata/users-metadata
title: User Metadata
updated_at: 2026-06-19T11:35:57.867Z
---

> 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


# User Metadata

:::tip Manage user data with BizOps Workspace
You can create, edit, or delete users and their data using [BizOps Workspace](https://www.pubnub.com/docs/bizops-workspace/user-management) on Admin Portal. It provides a preview of all users available on your apps' keysets.
:::

App Context provides easy-to-use, serverless storage for user metadata, channel metadata, channel memberships, and channel members. You don’t need to manage external infrastructure.

You can store user metadata to drive client features and enhance your application. Use predefined properties for a user, such as `name`, `email`, `profileURL`, and `externalId`. Use the `custom` object to store your own attributes, such as `nickname` or `color`.

:::note User ID / UUID
User ID is also referred to as **UUID/uuid** in some APIs and server responses but **holds the value** of the **userId** parameter you [set during initialization](https://www.pubnub.com/docs/general/setup/users-and-devices#set-the-user-id).
:::

###### Connect user metadata to your User ID strategy

Each user metadata record is keyed to a [User ID](https://www.pubnub.com/docs/general/setup/users-and-devices) set during initialization. The User ID that creates or updates metadata becomes the record's identifier. Access Manager can grant per-User-ID `get`, `update`, and `delete` [permissions](https://www.pubnub.com/docs/general/security/access-control#permissions) to control who can read or modify each user's stored profile.

PubNub also generates events when the metadata associated with a particular user is set or deleted. Your application can receive these events in real-time and dynamically react to data changes. You can enable these events from the [Admin Portal](https://admin.pubnub.com/).

PubNub publishes each user’s events to a channel named for that user. For example, to receive events for the user with User ID `chat-user-9A7X8`, you would subscribe to the channel named `chat-user-9A7X8`.

###### Analyze user metadata with Illuminate and Insights

[Illuminate](https://www.pubnub.com/docs/illuminate/business-objects/basics#data-mapping) can capture App Context user data by mapping fields from the `user` category in Business Objects. Use this to build real-time metrics and trigger [Decisions](https://www.pubnub.com/docs/illuminate/decisions/basics) based on user attributes. To protect privacy, avoid placing PII in custom fields that you map to Illuminate. [Insights](https://www.pubnub.com/docs/pubnub-insights/dashboards/users) separately tracks per-user activity (messages published, channels subscribed) and lets you [export top users to BizOps](https://www.pubnub.com/docs/pubnub-insights/dashboards/users#export-data) for metadata enrichment.

## Set user metadata

You can set predefined and custom user metadata by providing key-value pairs.

:::tip API limits
To learn about the maximum length of parameters used to set user metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-user-metadata).
:::

The example below adds the `name`, `email`, and a custom `nickname` to the current user.

###### JavaScript

```javascript
pubnub.objects.setUUIDMetadata({
    data: {
        name: "John Doe",
        email: "johndoe@pubnub.com",
        custom: {
            "nickname": "Mr. Mysterious"
        }
    }
});
```

###### Objective-C

```objectivec
self.client.objects().setUUIDMetadata()
    .uuid(@"uuid")
    .name(@"John Doe")
    .custom(@{ @"nickname": @("Mr. Mysterious") })
    .email(@"johndoe@pubnub.com")
    .includeFields(PNUUIDCustomField)
    .performWithCompletion(^(PNSetUUIDMetadataStatus *status) {
        if (!status.isError) {
            /**
             * User ID metadata successfully has been set.
             * User ID metadata information available here: status.data.metadata
             */
        } else {
            /**
             * Handle User ID metadata set error. Check 'category' property to find out possible issue
             * because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });
```

###### Java

```java
Map<String, Object> custom = new HashMap<>();
custom.put("nickname", "Mr. Mysterious");
pubnub.setUUIDMetadata()
    .name("John Doe")
    .email("johndoe@pubnub.com")
    .custom(custom)
    .includeCustom(true)
    .async(result -> { /* check result */ });
```

###### C#

```csharp
PNResult<PNSetUuidMetadataResult> setUuidMetadataResponse = await pubnub.SetUuidMetadata()
        .Uuid(config.Uuid)
        .Name("John Doe")
        .Email("johndoe@pubnub.com")
        .Custom(new Dictionary<string, object>() { { "nickname", "Mr. Mysterious" } })
        .ExecuteAsync();
PNSetUuidMetadataResult setUuidMetadataResult = setUuidMetadataResponse.Result;
PNStatus status = setUuidMetadataResponse.Status;
```

On success, the SDK returns the user’s metadata with HTTP 200. It will also fire a `User Metadata Set` event that can be consumed by other clients. Refer to the [Receive Messages](https://www.pubnub.com/docs/general/messages/receive) section to learn more.

## Get user metadata

Retrieve the current user’s metadata. The following example returns all metadata for the current user.

### JavaScript

```javascript
pubnub.objects.getUUIDMetadata();
```

### Objective-C

```objectivec
self.client.objects().uuidMetadata()
    .uuid(@"uuid")
    .includeFields(PNUUIDCustomField)
    .performWithCompletion(^(PNFetchUUIDMetadataResult *result, PNErrorStatus *status) {
      if (!status.isError) {
          /**
           * User ID metadata successfully fetched.
           * Fetched User ID metadata information available here: result.data.metadata
           */
      } else {
          /**
           * Handle User ID metadata fetch error. Check 'category' property to find out possible issue
           * because of which request did fail.
           *
           * Request can be resent using: [status retry]
           */
      }
    });
```

### Java

```java
pubnub.getUUIDMetadata().async(result -> { /* check result */ });
```

### C#

```csharp
// Get Metadata for the current user
PNResult<PNGetUuidMetadataResult> getUuidMetadataResponse = await pubnub.GetUuidMetadata()
    .ExecuteAsync();
PNGetUuidMetadataResult getUuidMetadataResult = getUuidMetadataResponse.Result;
PNStatus status = getUuidMetadataResponse.Status;

// Get Metadata for a specific user
PNResult<PNGetUuidMetadataResult> getUuidMetadataResponse = await pubnub.GetUuidMetadata()
    .Uuid("my-uuid")
    .ExecuteAsync();
PNGetUuidMetadataResult getUuidMetadataResult = getUuidMetadataResponse.Result;
PNStatus status = getUuidMetadataResponse.Status;
```

On success, the SDK returns all metadata for the user with HTTP 200.

## Get metadata for all users

You can retrieve metadata for all users. To include custom metadata, set the optional flag in your request. The code below returns all predefined and custom metadata for all users:

:::warning Required keyset configuration
To get all channel and user metadata, you must uncheck the
Disallow Get All Channel Metadata
and
Disallow Get All User Metadata
checkboxes in the App Context section of your keyset configuration in the
[Admin Portal](https://admin.pubnub.com)
.
:::

###### JavaScript

```javascript
pubnub.objects.getAllUUIDMetadata();
```

###### Objective-C

```objectivec
self.client.objects().allUUIDMetadata()
    .start(@"<next from previous request>")
    .includeFields(PNUUIDCustomField)
    .performWithCompletion(^(PNFetchAllUUIDMetadataResult *result, PNErrorStatus *status) {
        if (!status.isError) {
            /**
             * UUID metadata successfully fetched.
             * Result object has following information:
             *   result.data.metadata - List of fetched UUID metadata.
             *   result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
             *   result.data.prev - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
             *   result.data.totalCount - Total number of created UUID metadata.
             */
        } else {
            /**
             * Handle UUID metadata fetch error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });
```

###### Java

```java
pubnub.getAllUUIDMetadata()
    .includeTotalCount(true)
    .includeCustom(true)
    .async(result -> { /* check result */ });
```

###### C#

```csharp
PNResult<PNGetAllUuidMetadataResult> getAllUuidMetadataResponse = await pubnub.GetAllUuidMetadata()
    .IncludeCustom(true)
    .IncludeCount(true)
    .ExecuteAsync();
PNGetAllUuidMetadataResult getAllUuidMetadataResult = getAllUuidMetadataResponse.Result;
PNStatus status = getAllUuidMetadataResponse.Status;
```

On success, the SDK returns all user metadata associated with the API key with HTTP 200.

## Remove user metadata

Remove all metadata for a single user. The following example removes all metadata of the current user.

:::note Cascading deletes
Enable [referential integrity](https://www.pubnub.com/docs/general/metadata/basics#configuration) on your app’s keyset in the Admin Portal to automatically delete memberships when you delete a user. If you keep it disabled, delete related memberships manually.
:::

###### JavaScript

```javascript
pubnub.objects.removeUUIDMetadata();
```

###### Objective-C

```objectivec
self.client.objects().removeUUIDMetadata()
    .uuid(@"uuid")
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
             // User successfully deleted.
        } else {
            /**
             * Handle user delete error. Check 'category' property to find out possible issue
             * because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });
```

###### Java

```java
pubnub.removeUUIDMetadata()
    .async(result -> { /* check result */ });
```

###### C#

```csharp
PNResult<PNRemoveUuidMetadataResult> removeUuidMetadataResponse = await pubnub.RemoveUuidMetadata()
    .ExecuteAsync();
PNRemoveUuidMetadataResult removeUuidMetadataResult = removeUuidMetadataResponse.Result;
PNStatus status = removeUuidMetadataResponse.Status;
```

On completion, the SDK emits an `object` -> `uuid` -> `delete` event that can be consumed by other clients. Refer to the [Receive Messages](https://www.pubnub.com/docs/general/messages/receive) document to learn more.

## Terms in this document

* **User** - An individual or entity that interacts with a system, application, or service. In PubNub, a user typically refers to someone who sends or receives messages through the platform, identified by a unique user ID or username.
* **User ID** - UTF-8 encoded, unique string of up to 92 characters used to identify a single client (end user, device, or server) that connects to PubNub.
