App Context API limits
Starting a new app? Use DataSync
DataSync 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 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.
App Context enforces size, count, and field-length limits on every user, channel, and membership metadata record. This reference lists:
- the maximum size of one metadata record, and the record and membership counts PubNub recommends per keyset
- the maximum length of each field on a user, channel, and membership record
- what happens when a write would exceed one of these limits
These limits apply the same way whether you write through an SDK, the REST API, or BizOps Workspace, since all three call the same underlying App Context API.
Record and count limits
| Item | Limit | Notes |
|---|---|---|
| Metadata record size | One user, channel, or membership metadata record can hold up to 32 KiB, counting every field including custom. | This is a storage limit on the record, separate from the publish message-size limit. |
| User and channel metadata records | 1 million each (recommended) | Recommended maximum per keyset when using the App Context API. |
| Memberships and channel members | Platform limits apply: up to 50,000 memberships per user and up to 5,000 members per channel. | |
| Members or memberships per write | 20 per request | Maximum number added or removed in a single App Context call. |
For the maximum length of individual fields such as name, externalId, email, type, and status, see the REST API reference for setting user metadata, channel metadata, a user's channel memberships, and a channel's members. If a custom field holds an integer, such as a timetoken, send it as a string when the value can exceed 9007199254740991, the largest integer JSON can represent without losing precision.
Field-length limits
Each field on a user, channel, or membership record has its own maximum length, separate from the record's overall size limit. A record can exceed that ceiling even when every field is within its own maximum.
Text fields
A name, externalId, profileUrl, or description field holds up to 2,048 characters.
| Field | Entity | Also requires |
|---|---|---|
name | User, Channel | Can't be empty or contain only whitespace |
externalId | User | |
profileUrl | User | Valid URI syntax (RFC 3986) |
description | Channel |
The email field
An email field holds up to 320 characters. It must use RFC 5322/RFC 6532 address syntax, without a display name. It exists on users only.
The type and status fields
The type and status fields hold up to 50 characters and accept only letters, digits, and the period (.) character. The same rule applies on users, channels, and memberships. A membership call and a members call read and write the same underlying record from opposite directions, so the limit is identical no matter which direction you use.
The custom field
On every entity above, custom accepts only scalar string, number, or boolean values. Arrays and nested objects aren't supported. For the integer precision limit on a numeric custom value, refer to the note under Record and count limits.
Where to set these fields
- Set, get, and remove user metadata, or the REST API's Set user metadata endpoint.
- Set, get, and remove channel metadata, or the REST API's Set channel metadata endpoint.
- Set, get, and remove memberships and Set, get, and remove members, or the REST API's Set membership metadata and Set channel members' metadata endpoints.
Identifier length limits
The name limits above apply to the display name stored inside a metadata record, not to the record's own identifier. A User ID and a channel name each have their own, shorter length limit that applies everywhere on the platform, not only in App Context:
- A User ID cannot exceed 92 UTF-8 characters.
- Channel names cannot exceed 92 UTF-8 characters.
Refer to API limits for the full identifier reference.
What happens when you exceed a limit
-
A write that would push an App Context record, or a single field on it, past its length limit fails with a
400 Bad Requesterror. - An unrecognized property name in an App Context
setcall doesn't fail the request, because PubNub silently ignores it instead. Check your request for a typo if a field doesn't appear in the response. - The App Context record-count and membership-count limits are recommended maximums rather than enforced ceilings, so PubNub returns no error for exceeding them. Design your application to stay within them anyway.
Next steps
- App Context. The three entity types, how to turn on App Context, and where these limits apply.
- Set, get, and remove user metadata. Apply the user metadata field limits.
- Set, get, and remove channel metadata. Apply the channel metadata field limits.
- Set, get, and remove memberships. Apply the membership field limits from a user's perspective.
- Set, get, and remove members. Apply the membership field limits from a channel's perspective.
- App Context filtering. Query App Context data without paging through every record.
- API limits. Limits across every PubNub API, including Publish, Subscribe, and Presence.