Data storage
PubNub stores four kinds of data alongside real-time messaging: message history, structured application state, user and channel metadata, and files. Each storage system is independent, enabled per keyset, and priced separately.
| System | What it stores | Typical use | How you use it |
|---|---|---|---|
| Message Persistence | Published messages and message actions | Message history, catch-up after a disconnect, unread counts | Enable on your keyset in the Admin Portal. Your app reads history through an SDK. |
| Application state and sync (DataSync) | Entities, relationships, and custom classes with schemas | Structured application state synchronized to every connected client in real time | Define your data model once with the Admin API. Apps create and read records through the SDK at runtime. |
| User and channel metadata (App Context) | User profiles, channel metadata, and memberships | User and channel data for keysets that already use App Context, apps built on the Chat SDK, and SDKs without DataSync support | SDK calls or REST API. No keyset add-on required. |
| Files | Binary files uploaded to a channel | Images, documents, and other files shared alongside messages | Enable File Sharing on your keyset. Uploads and downloads go through the SDK. |
Message Persistence
Pub/Sub delivers a published message to connected subscribers without storing it. Message Persistence stores messages published to a channel as they arrive on the PubNub network. Enabling it on a keyset turns on storage for all channels in that keyset. Individual messages can opt out at publish time using the storeInHistory parameter.
PubNub indexes stored messages by the timetoken it assigns at publish. Your app uses timetokens to page through history, count unread messages, or replay messages missed during a disconnect.
Signals are never stored, regardless of keyset settings. A file upload creates a file event of message type 4. Message Persistence stores that event if it is enabled on the keyset.
Application state and sync (DataSync)
DataSync is the successor to App Context. It stores the same users, channels, and memberships. It adds entity and relationship classes you define, typed schemas validated on write, field-level access through projections, and two filtering tiers for queries.
As of 2026-09-21, DataSync is available to new accounts and accounts that are not actively using App Context. If your keysets already use App Context, keep using it. App Context remains fully supported and the two systems don't share data.
PubNub publishes change notifications as DataSync events, message type 5, on the channels your app already subscribes to. Every keyset with DataSync enabled must also have Access Manager enabled.
User and channel metadata (App Context)
App Context stores structured data about users, channels, and the relationships between them (memberships).
Use App Context on keysets that already use it, in apps built on the Chat SDK, and from SDKs that don't support DataSync. For which SDKs support DataSync, see DataSync SDK support.
The three App Context entity types are independent. User metadata, channel metadata, and memberships each have their own API, and you can use them in any combination.
All three types support custom fields. When you update an entity, PubNub fires a real-time App Context event to subscribed clients, so your app can react to changes without polling.
App Context stores data in a single region per keyset. You choose the region when you enable the feature. You can't change the region after you save it.
Files
Files stores binary content uploaded to a channel. When a client uploads a file, PubNub delivers a file event to subscribers on that channel with the file ID, name, and a download URL.
Files has its own retention setting, separate from Message Persistence retention. If your app links file uploads to messages in the same channel, align the two retention periods so neither expires before the other.
Other PubNub storage
PubNub also stores the channel lists of channel groups, mobile push device tokens, and key-value pairs in the Functions key-value store. Each feature's own section covers how that data is stored.