---
source_url: https://www.pubnub.com/docs/sdks/java/entities/user-metadata
title: UserMetadata Entity
updated_at: 2026-06-22T14:39:48.130Z
sdk_name: PubNub Java SDK
sdk_version: 6.4.5
---

> 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


# UserMetadata Entity

PubNub Java SDK, use the latest version: 6.4.5

Install:

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

As of version 9.0.0, the Java 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 UserMetadata

Use this factory method to return a local `UserMetadata` entity for a single user metadata object. A `UserMetadata` entity centralizes operations related to App Context user metadata.

```java
pubnub.userMetadata(String userId)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| userId | String | Yes |  | Identifier of the user metadata object to manage. |

#### 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.
:::

```java
import com.pubnub.api.PubNubException;
import com.pubnub.api.java.PubNub;
import com.pubnub.api.java.v2.PNConfiguration;
import com.pubnub.api.UserId;
import com.pubnub.api.java.v2.entities.UserMetadata;

public class UserMetadataApp {
    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());

        // Create a UserMetadata entity
        UserMetadata userMetadata = pubnub.userMetadata("userId1");

        System.out.println("User Metadata created for user ID: " + userMetadata.getId());
    }
}
```

## Available operations

The `UserMetadata` entity provides operations for PubNub App Context [user metadata](https://www.pubnub.com/docs/general/metadata/users-metadata).

| Operation (click for more information) | Description |
| --- | --- |
| [subscription(subscriptionOptions)](https://www.pubnub.com/docs/sdks/java/api-reference/publish-and-subscribe#subscribe) | Returns a local user metadata [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 user metadata. |