---
source_url: https://www.pubnub.com/docs/general/metadata/basics
title: PubNub App Context
updated_at: 2026-05-21T15:45:26.243Z
---

> 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


# PubNub App Context

App Context lets you store and manage data (also called metadata) for users, channels, and their relationships (memberships) directly on the PubNub platform.

You deliver personalized, context‑rich experiences in real time without adding external databases. This improves user experience and keeps data secure and compliant.

## Configuration

Enable and configure App Context on a keyset in the [Admin Portal](https://admin.pubnub.com/).

:::tip Public Admin Portal demo
Want to browse through the Admin Portal without creating an account? Explore it through the [Public Demo](https://demo-admin.pubnub.com/) that shows examples of most PubNub features for transport and logistics use case.
:::

By default, the Admin Portal prompts you to enable App Context on every new keyset (unless you choose **Choose later** for **Region** during keyset creation).

Testing keysets default to the `US East` region for storing user, channel, and membership data.

![Admin Portal showing App Context settings (Bucket Region and event toggles)](https://www.pubnub.com/assets/images/app-context-0a1fcf08006cdc64c75ae3c5feb420f3.png)

| Option | Description |
| --- | --- |
| **Bucket Region** | The geographic region where your App Context data is stored and managed. Choose a region close to your users to reduce latency and improve performance. After you save, you cannot change the region. |
| **User Metadata Events** | Turns on events when user metadata is created, updated, or deleted. Apps can subscribe to these events and react in real time. See [Real-time updates](https://www.pubnub.com/docs/general/metadata/basics#real-time-updates) to learn event types and how to receive them. |
| **Channel Metadata Events** | Turns on events when channel metadata is created, updated, or deleted. Apps can subscribe and update UI based on channel property changes. See [Real-time updates](https://www.pubnub.com/docs/general/metadata/basics#real-time-updates) to learn event types and how to receive them. |
| **Membership Events** | Turns on events for memberships (associations between users and channels). This helps you manage and respond to who belongs to which channels. Subscribe to receive and handle these events. See [Real-time updates](https://www.pubnub.com/docs/general/metadata/basics#real-time-updates) to learn event types and how to receive them. |
| **Disallow Get All Channel Metadata** | Restricts access to all channel metadata in apps with Access Manager enabled. If you enable Access Manager and leave this unchecked, you can `get` all channel metadata without listing it in the token’s permission schema. |
| **Disallow Get All User Metadata** | Restricts access to all user metadata in apps with Access Manager enabled. If you enable Access Manager and leave this unchecked, you can `get` all user metadata without listing it in the token’s permission schema. |
| **Enforce referential integrity for memberships** | When enabled: you can create a membership only if the specified user ID and channel ID exist as standalone metadata entities. Deleting a user or channel automatically deletes its child membership associations. When disabled: you can create memberships even if the user or channel entity doesn’t exist. Deleting a user or channel doesn’t delete associated memberships. |

## Functional components

App Context includes three metadata types:

* Channel metadata: Manage channel data (names, descriptions, custom attributes) that support how each channel works in your app.
* User metadata: Store and manage user data (name, email, custom attributes) using App Context’s serverless storage.
* Membership metadata: Manage relationships between users and channels to add, update, or remove users from channels and vice versa.

## Data management

You can manage App Context data using SDK methods, REST API endpoints, or the BizOps Workspace GUI. Choose the method that fits your workflow.

### SDKs

SDKs are best for real‑time, in‑app interactions. PubNub provides SDKs for many languages and platforms so you can manage App Context programmatically.

In each [SDK](https://www.pubnub.com/docs/sdks), the left navigation includes an **App Context** section with methods. For reference, see [JavaScript](https://www.pubnub.com/docs/sdks/javascript/api-reference/objects).

### REST API

Use the REST API for server‑to‑server interactions or when an SDK isn’t available.

PubNub’s [REST API](https://www.pubnub.com/docs/sdks/rest-api) lets you manage App Context server‑side or from any platform that can make HTTP requests.

* [Users API](https://www.pubnub.com/docs/sdks/rest-api/app-context-user-introduction)
* [Channels API](https://www.pubnub.com/docs/sdks/rest-api/app-context-channel-introduction)
* [Memberships API](https://www.pubnub.com/docs/sdks/rest-api/app-context-membership-introduction)

### BizOps Workspace

[BizOps Workspace](https://www.pubnub.com/docs/bizops-workspace/basics) is ideal for operational teams that prefer a GUI to manage users, channels, and memberships.

BizOps Workspace in the Admin Portal includes these views:

* [User management](https://www.pubnub.com/docs/bizops-workspace/user-management) — Create, update, and delete user and membership data.
* [Channel management](https://www.pubnub.com/docs/bizops-workspace/channel-management) — Create, update, and delete channel and membership data.

## Real-time updates

PubNub generates events when user, channel, or membership metadata changes (create, update, delete). Clients can subscribe to these events to react in real time and update the UI.

### App Context events

PubNub defines the following App Context events:

| Event | Type | When it's fired |
| --- | --- | --- |
| **User Metadata Set** | User | Metadata is set for a user |
| **User Metadata Deleted** | User | Metadata is deleted for a user |
| **Channel Metadata Set** | Channel | Metadata is set for a channel |
| **Channel Metadata Deleted** | Channel | Metadata is deleted for a channel |
| **User Added to Channel** | Membership | A membership record is created or updated between a user and a channel |
| **User Removed from Channel** | Membership | A membership record is removed between a user and a channel |

All App Context events use the following format:

```json
{
  "channel": "sample-channel",
  // event payload
  "message": {
    // API from which data is originating
     "source": "objects",
     // event structure version
     "version": "2.0",
     // type of occurring event, e.g. "set" or "delete"
     "event": "sample-event",
     // category of data, e.g. "membership" or "channel"
     "type": "sample-type",
     // specific event-related data
     "data": {
      // e.g. "type": {member.Type},
      "key1": "sample-value1",
      "key2": "sample-value2"
     }
  },
  // a group of channels or a single channel you subscribed to, e.g. "stock-price-updates"
  "subscription": "sample-subscription",
  // timetoken representing when the message was sent, e.g. 137696160600000001
  "timetoken": "sample-timetoken"
}
```

The fields are defined as follows:

* **event** — What happened (`set` or `delete`).
* **type** — Where it happened (`uuid` for user, `channel`, or `membership`).
* **data** — Event‑specific information.

:::note User metadata event notifications
When the [User Metadata Events](#configuration) option is enabled on a keyset, any modification to a user entity (`set` and `delete`) sends notifications to that user and to any channels the user belongs to. For example, if a user with User ID `test-user-1` is a member of channels `test-channel-1` and `test-channel-2`, and that user entity is modified, a `set` event for type `uuid` is published to three channels: `test-user-1` (user‑associated channel), `test-channel-1`, and `test-channel-2`. A `delete` event is published to those three channels if that User ID is deleted.
:::

### Subscribe to App Context events

To receive App Context events, use an SDK to listen for real‑time metadata changes to users, channels, or memberships.

Detailed steps live in each [SDK](https://www.pubnub.com/docs/sdks). In general:

1. Initialize PubNub — Set up your instance with your publish and subscribe keys.
2. Add a listener — Implement an event listener to handle App Context events (user, channel, memberships). See Receive.
3. Subscribe to channels — Choose channels or patterns that receive App Context events and subscribe. You can subscribe to a channel (to receive all membership info from that channel) or to a user (to receive changes to that user or their memberships). Subscribing to a user means subscribing to that user’s user‑ID channel.

You can also use [PubNub Functions](https://www.pubnub.com/docs/serverless/functions/overview) to consume, modify, and analyze messages or events in real time with JavaScript that runs on the PubNub network.

###### Handle App Context events with your message listener

App Context events flow through the same [event listener](https://www.pubnub.com/docs/general/messages/receive#add-an-event-handler) infrastructure as messages, signals, and presence events. Your existing subscription and listener setup already supports these events through the Objects handler without additional configuration.

## API limits

PubNub applies soft and hard limits for App Context (record sizes, field lengths, and recommended maximums for memberships and members). For details, see [API Limits](https://www.pubnub.com/docs/general/setup/limits#app-context).

###### Secure metadata operations with Access Manager

When Access Manager is enabled, App Context operations require permissions on two resource types. User metadata operations (`get`, `update`, `delete`) are controlled by UUID-level permissions. Channel metadata operations (`get`, `update`, `delete`) and membership management (`manage`, `join`) are controlled by channel-level permissions. The Admin Portal also provides options to allow or restrict "Get All" operations independently of per-resource grants. See the [App Context permissions table](https://www.pubnub.com/docs/general/security/access-control#app-context) for the full mapping.

## Terms in this document

* **Access Manager** - A cryptographic, token-based permission administrator that allows you to regulate clients' access to PubNub resources, such as channels, channel groups, and user IDs.
* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
* **Listener** - A function or objectthat reacts to events or messages, like new chat messages or connection updates, letting your app respond in real-time.
* **PubNub** - PubNub is a real-time messaging platform that provides APIs and SDKs for building scalable applications. It handles the complex infrastructure of real-time communication, including: Message delivery and persistence, Presence detection, Access control, Push notifications, File sharing, Serverless processing with Functions and Events & Actions, Analytics and monitoring with BizOps Workspace, AI-powered insights with Illuminate.
* **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.
