App Context API for PHP SDK

This page describes App Context (formerly Objects v2). To upgrade from Objects v1, refer to the migration guide.

App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context to store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.

PubNub also triggers events when object data is changed: set, updated, or removed from the database. Making a request to set the same data that already exists doesn't trigger an event. Clients can receive these events in real time and update their front-end application accordingly.

User

Manage UUID metadata: list, fetch, set, and remove. Include only the fields you need to reduce payload size.

Get metadata for all users

Get a paginated list of UUID metadata. Use filters and sorting to narrow results.

Commonly used to list chat users, build user directories, populate dropdowns for user selection, or display member profiles with names, emails, and custom data. Retrieves users whose profile information has been stored in App Context.

Method(s)

To Get All UUID Metadata you can use the following method(s) in the PHP SDK:

getAllUUIDMetadata()
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync()
* required
ParameterDescription
includeFields()
Type: Array[String => Boolean]
Default:
n/a
Whether to include additional fields. Set customFields to include the Custom object. Set totalCount to include the total count in the paginated response (default is false).
filter()
Type: String
Default:
n/a
Filter expression. Only matching objects are returned. See filtering.
sort()
Type: String or Array[String]
Default:
n/a
Sort by id, name, updated with asc/desc for sort direction (for example, name:asc).
limit()
Type: integer
Default:
100
Number of objects to return. Default/Max: 100.
page()
Type: Array[String => String]
Default:
n/a
Cursor-based pagination. Use prev and next tokens returned by the server.

Sample code

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.

Response

The getAllUUIDMetadata() operation returns a PNGetAllUUIDMetadataResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNGetUUIDMetadataResult]
List of uuid metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNGetUUIDMetadataResult which contains the following fields:

ParameterDescription
getId()
Type: String
Unique user identifier
getName()
Type: String
Display name for the user
getExternalId()
Type: String
User's identifier in an external system
getProfileUrl()
Type: String
The URL of the user's profile picture
getEmail()
Type: String
The user's email address
getCustom()
Type: stdClass
Object containing your custom fields

Get user metadata

Fetch metadata for a single UUID. Include the Custom object if you need custom fields.

Method(s)

To Get UUID Metadata you can use the following method(s) in the PHP SDK:

getUUIDMetadata()
->uuid(String)
->sync()
* required
ParameterDescription
uuid() *
Type: String
Default:
n/a
UUID

Sample code


Response

The getUUIDMetadata() operation returns a PNGetUUIDMetadataResult which contains the following fields:

ParameterDescription
getId()
Type: String
Unique user identifier
getName()
Type: String
Display name for the user
getExternalId()
Type: String
User's identifier in an external system
getProfileUrl()
Type: String
The URL of the user's profile picture
getEmail()
Type: String
The user's email address
getCustom()
Type: stdClass
Object containing your custom fields

Set user metadata

Create or update metadata for a UUID. Use the eTag to avoid overwriting concurrent updates.

Unsupported partial updates of custom metadata

The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:

  1. Get the existing metadata and store it locally.
  2. Append the new custom metadata to the existing one.
  3. Set the entire updated custom object.

Set metadata for a UUID in the database, including the Custom object.

Method(s)

To Set UUID Metadata you can use the following method(s) in the PHP SDK:

setUUIDMetadata()
->uuid(String)
->meta(Array | StdClass)
->ifMatchesEtag(String)
->sync()
* required
ParameterDescription
uuid() *
Type: String
Default:
n/a
UUID
meta() *
Type: Array or StdClass
Default:
n/a
UUID metadata to set.
ifMatchesEtag
Type: String
Default:
n/a
Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412.

UUID metadata contains the following fields:

FieldTypeRequiredDescription
name
String
Optional
Display name for the user.
externalId
String
Optional
User's identifier in an external system.
profileUrl
String
Optional
The URL of the user's profile picture.
email
String
Optional
The user's email address.
custom
Array or StdClass
Optional
Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported.
API limits

To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.

Sample code


Response

The setUUIDMetadata() operation returns a PNSetUUIDMetadataResult which contains the following fields:

ParameterDescription
getId()
Type: String
Unique user identifier
getName()
Type: String
Display name for the user
getExternalId()
Type: String
User's identifier in an external system
getProfileUrl()
Type: String
The URL of the user's profile picture
getEmail()
Type: String
The user's email address
getCustom()
Type: stdClass
Object containing your custom fields

Remove user metadata

Delete metadata for the specified UUID.

Method(s)

To Remove UUID Metadata you can use the following method(s) in the PHP SDK:

removeUUIDMetadata()
->uuid(String)
->sync()
* required
ParameterDescription
uuid() *
Type: String
Default:
n/a
UUID

Sample code


Response

Returns a boolean, true for success otherwise false

Channel

Manage channel metadata: list, fetch, set, and remove.

Get metadata for all channels

Get a paginated list of channel metadata. Use filters and sorting to narrow results.

Method(s)

To Get All Channel Metadata you can use the following method(s) in the PHP SDK:

getAllChannelMetadata()
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync()
* required
ParameterDescription
includeFields()
Type: Array[String => Boolean]
Default:
n/a
Whether to include additional fields. Set customFields to include the Custom object. Set totalCount to include the total count in the paginated response (default is false).
filter()
Type: String
Default:
n/a
Filter expression. Only matching objects are returned. See filtering.
sort()
Type: String or Array[String]
Default:
n/a
Sort by id, name, updated with asc/desc for sort direction (for example, name:asc).
limit()
Type: integer
Default:
100
Number of objects to return. Default/Max: 100.
page()
Type: Array[String => String]
Default:
n/a
Cursor-based pagination. Use prev and next tokens returned by the server.

Sample code


Response

The getAllChannelMetadata() operation returns a PNGetAllChannelMetadataResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNGetChannelMetadataResult]
List of channel metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNGetChannelMetadataResult which contains the following fields:

ParameterDescription
getId()
Type: String
Unique channel identifier
getName()
Type: String
Display name for the channel
getDescription()
Type: String
Description of a channel
getCustom()
Type: stdClass
Object containing your custom fields

Get channel metadata

Fetch metadata for a single channel. Include the Custom object if you need custom fields.

Method(s)

To Get Channel Metadata you can use the following method(s) in the PHP SDK:

getChannelMetadata()
->channel(String)
->sync()
* required
ParameterDescription
channel() *
Type: String
Default:
n/a
Unique channel identifier

Sample code


Response

The getChannelMetadata() operation returns a PNGetChannelMetadataResult which contains the following fields:

ParameterDescription
getId()
Type: String
Unique channel identifier
getName()
Type: String
Display name for the channel
getDescription()
Type: String
Description of a channel
getCustom()
Type: stdClass
Object containing your custom fields

Set channel metadata

Create or update metadata for a channel. Use the eTag to avoid overwriting concurrent updates.

Unsupported partial updates of custom metadata

The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:

  1. Get the existing metadata and store it locally.
  2. Append the new custom metadata to the existing one.
  3. Set the entire updated custom object.

Set metadata for a channel in the database, including the Custom object.

Method(s)

To Set Channel Metadata you can use the following method(s) in the PHP SDK:

setChannelMetadata()
->channel(String)
->meta(Array | StdClass)
->ifMatchesEtag(String)
->sync()
* required
ParameterDescription
channel() *
Type: String
Default:
n/a
Unique channel identifier
meta() *
Type: Array or StdClass
Default:
n/a
Channel metadata to set.
ifMatchesEtag
Type: String
Default:
n/a
Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412.

Channel metadata contains the following fields

FieldTypeRequiredDescription
name
String
Optional
Display name for the channel.
description
String
Optional
Description of a channel.
custom
Array or StdClass
Optional
Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported.
API limits

To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.

Sample code


Response

The setChannelMetadata() operation returns a PNSetChannelMetadataResult which contains the following fields:

ParameterDescription
getId()
Type: String
Unique channel identifier
getName()
Type: String
Display name for the channels
getDescription()
Type: String
Description of a channel
getCustom()
Type: stdClass
Object containing your custom fields

Other examples

    // Writing the updated object back to the server
$pubnub->setChannelMetadata()
->channel($channel)
->meta([
"name" => $response->getName(),
"description" => $response->getDescription(),
"custom" => $custom,
])
->sync();
print("Object has been updated.\n");
Update existing channel metadata

This example shows how to update existing channel metadata by modifying the name, description, and custom fields.


Remove channel metadata

Delete metadata for the specified channel.

Method(s)

To Remove Channel Metadata you can use the following method(s) in the PHP SDK:

removeChannelMetadata()
->channel(String)
->sync()
* required
ParameterDescription
channel() *
Type: String
Default:
n/a
Unique channel identifier

Sample code


Response

Returns a boolean, true for success otherwise false

Channel memberships

Manage the channels a UUID belongs to: list, set, remove, and manage in bulk.

Get channel memberships

List channel memberships for a UUID. This doesn't return subscriptions.

Method(s)

To Get Memberships you can use the following method(s) in the PHP SDK:

getMemberships()
->uuid(String)
->include(PNMembershipIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
uuid() *
Type: String
Default:
n/a
UUID
include()
Type: PNMembershipIncludes
Default:
n/a
Whether to include additional fields.
 → custom
Type: Boolean
Default:
False
Whether to include the Custom object in the response.
 → status
Type: Boolean
Default:
False
Whether to include the status field.
 → type
Type: Boolean
Default:
False
Whether to include the type field.
 → total_count
Type: Boolean
Default:
False
Whether to include the total count in the paginated response.
 → channel
Type: Boolean
Default:
False
Whether to include channel fields.
 → channelCustom
Type: Boolean
Default:
False
Whether to include the channel Custom object.
 → channelType
Type: Boolean
Default:
False
Whether to include the channel type field.
 → channelStatus
Type: Boolean
Default:
False
Whether to include the channel status field.
filter()
Type: String
Default:
n/a
Filter expression. Only matching objects are returned. See filtering.
sort()
Type: String or Array[String]
Default:
n/a
Sort by id, name, updated with asc/desc for sort direction (for example, name:asc).
limit()
Type: integer
Default:
100
Number of objects to return. Default/Max: 100.
page()
Type: Array[String => String]
Default:
n/a
Cursor-based pagination. Use prev and next tokens returned by the server.

Sample code


Response

The getMemberships() operation returns a PNMembershipsResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembershipsResultItem]
List of membership metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembershipsResultItem which contains the following fields:

ParameterDescription
getChannel()
Type: PNMembership
Channel metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMembership which contains the following fields:

ParameterDescription
getId()
Type: String
Unique channel identifier
getName()
Type: String
Display name for the channel
getDescription()
Type: String
Description of a channel
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Set channel memberships

Replace or add memberships for a UUID. Provide channels (optionally with custom data).

Method(s)

To Set Memberships you can use the following method(s) in the PHP SDK:

setMemberships()
->uuid(String)
->memberships(Array[PNChannelMembership])
->custom(Array | StdClass)
->include(PNMembershipIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
uuid() *
Type: String
Default:
n/a
UUID
memberships() *
Type: Array[PNChannelMembership]
Default:
n/a
Array of memberships to set.
custom() *
Type: Array or StdClass
Default:
n/a
Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported.
include()
Type: PNMembershipIncludes
Default:
n/a
Whether to include additional fields.
 → custom
Type: Boolean
Default:
False
Whether to include the Custom object in the response.
 → status
Type: Boolean
Default:
False
Whether to include the status field.
 → type
Type: Boolean
Default:
False
Whether to include the type field.
 → total_count
Type: Boolean
Default:
False
Whether to include the total count in the paginated response.
 → channel
Type: Boolean
Default:
False
Whether to include channel fields.
 → channelCustom
Type: Boolean
Default:
False
Whether to include the channel Custom object.
 → channelType
Type: Boolean
Default:
False
Whether to include the channel type field.
 → channelStatus
Type: Boolean
Default:
False
Whether to include the channel status field.
filter()
Type: String
Default:
n/a
Filter expression. Only matching objects are returned. See filtering.
sort()
Type: String or Array[String]
Default:
n/a
Sort by id, name, updated with asc/desc for sort direction (for example, name:asc).
limit()
Type: integer
Default:
100
Number of objects to return. Default/Max: 100.
page()
Type: Array[String => String]
Default:
n/a
Cursor-based pagination. Use prev and next tokens returned by the server.
channels() *
Type: Array[String or Array]
Default:
n/a
Array of channels to add to membership. Array can contain strings (channel-name only) or objects (which can include custom data).
API limits

To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.

Sample code


Response

The setMemberships() operation returns a PNMembershipsResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembershipsResultItem]
List of membership metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembershipsResultItem which contains the following fields:

ParameterDescription
getChannel()
Type: PNMembership
Channel metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMembership which contains the following fields:

ParameterDescription
getId()
Type: String
Unique channel identifier
getName()
Type: String
Display name for the channel
getDescription()
Type: String
Description of a channel
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Remove channel memberships

Remove memberships for a UUID. Provide the channels to remove.

Method(s)

To Remove Memberships you can use the following method(s) in the PHP SDK:

removeMemberships()
->uuid(String)
->memberships(Array[PNChannelMembership])
->include(PNMembershipIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
uuid() *
Type: String
Default:
n/a
UUID.
memberships() *
Type: Array[PNChannelMembership]
Default:
n/a
Array of memberships to remove.
include()
Type: PNMembershipIncludes
Default:
n/a
Whether to include additional fields.
 → custom
Type: Boolean
Default:
False
Whether to include the Custom object in the response.
 → status
Type: Boolean
Default:
False
Whether to include the status field.
 → type
Type: Boolean
Default:
False
Whether to include the type field.
 → total_count
Type: Boolean
Default:
False
Whether to include the total count in the paginated response.
 → channel
Type: Boolean
Default:
False
Whether to include channel fields.
 → channelCustom
Type: Boolean
Default:
False
Whether to include the channel Custom object.
 → channelType
Type: Boolean
Default:
False
Whether to include the channel type field.
 → channelStatus
Type: Boolean
Default:
False
Whether to include the channel status field.
filter()
Type: String
Default:
n/a
Filter expression. Only matching objects are returned. See filtering.
sort()
Type: String or Array[String]
Default:
n/a
Sort by id, name, updated with asc/desc for sort direction (for example, name:asc).
limit()
Type: integer
Default:
100
Number of objects to return. Default/Max: 100.
page()
Type: Array[String => String]
Default:
n/a
Cursor-based pagination. Use prev and next tokens returned by the server.
channels() *
Type: Array[String]
Default:
n/a
Array of channels to remove from membership.

Sample code


Response

The removeMemberships() operation returns a PNMembershipsResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembershipsResultItem]
List of membership metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembershipsResultItem which contains the following fields:

ParameterDescription
getChannel()
Type: PNMembership
Channel metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMembership which contains the following fields:

ParameterDescription
getId()
Type: String
Unique channel identifier
getName()
Type: String
Display name for the channel
getDescription()
Type: String
Description of a channel
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Manage channel memberships

Add and remove memberships for a UUID in one request.

To Manage Channel Memberships you can use the following method(s) in the PHP SDK:

manageMemberships()
->uuid(String)
->setMemberships(Array[PNChannelMembership])
->removeMemberships(Array[PNChannelMembership])
->include(PNMembershipIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
uuid() *
Type: String
Default:
n/a
Unique user identifier whose memberships to manage
setMemberships()
Type: Array[PNChannelMembership]
Default:
n/a
Array of PNChannelMembership objects to add to the user's memberships.
removeMemberships()
Type: Array[PNChannelMembership]
Default:
n/a
Array of PNChannelMembership objects to remove from the user's memberships.
include()
Type: PNMembershipIncludes
Default:
n/a
The additional information to include in the membership response.
 → custom
Type: Boolean
Default:
False
Indicates whether custom data should be included in the response.
 → status
Type: Boolean
Default:
False
Indicates whether the status should be included in the response.
 → type
Type: Boolean
Default:
False
Indicates whether the type should be included in the response.
 → total_count
Type: Boolean
Default:
False
Indicates whether the total count should be included in the response.
 → channel
Type: Boolean
Default:
False
Indicates whether the channel ID information should be included in the response.
 → channelCustom
Type: Boolean
Default:
False
Indicates whether custom data for the channel should be included in the response.
 → channelType
Type: Boolean
Default:
False
Indicates whether the type of the channel should be included in the response.
 → channelStatus
Type: Boolean
Default:
False
Indicates whether the status of the channel should be included in the response.
filter()
Type: String
Default:
n/a
Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()
Type: String or Array[String]
Default:
n/a
String or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()
Type: integer
Default:
100
Number of objects to return in response. Default is 100, which is also the maximum value.
page()
Type: Array[String => String]
Default:
n/a
Use for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Sample code


Response

The manageMemberships() operation returns a PNMembershipsResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembershipsResultItem]
List of membership metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembershipsResultItem which contains the following fields:

ParameterDescription
getChannel()
Type: PNMembership
Channel metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMembership which contains the following fields:

ParameterDescription
getId()
Type: String
Unique channel identifier
getName()
Type: String
Display name for the channel
getDescription()
Type: String
Description of a channel
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel members

Manage the users in a channel: list, set, remove, and manage in bulk.

Get channel members

List users in a channel. Include user metadata if needed.

Method(s)

To Get Channel Members you can use the following method(s) in the PHP SDK:

getMembers()
->channel(String)
->include(PNMemberIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
channel() *
Type: String
Default:
n/a
Unique channel identifier
include()
Type: PNMemberIncludes
Default:
n/a
The additional information to include in the member response.
 → custom
Type: Boolean
Default:
False
Indicates whether custom data should be included in the response.
 → status
Type: Boolean
Default:
False
Indicates whether the status should be included in the response.
 → type
Type: Boolean
Default:
False
Indicates whether the type should be included in the response.
 → total_count
Type: Boolean
Default:
False
Indicates whether the total count should be included in the response.
 → user
Type: Boolean
Default:
False
Indicates whether the user ID information should be included in the response.
 → userCustom
Type: Boolean
Default:
False
Indicates whether custom data for the user should be included in the response.
 → userType
Type: Boolean
Default:
False
Indicates whether the type of the user should be included in the response.
 → userStatus
Type: Boolean
Default:
False
Indicates whether the status of the user should be included in the response.
filter()
Type: String
Default:
n/a
Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()
Type: String or Array[String]
Default:
n/a
String or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()
Type: integer
Default:
100
Number of objects to return in response. Default is 100, which is also the maximum value.
page()
Type: Array[String => String]
Default:
n/a
Use for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Sample code


Response

The getMembers() operation returns a PNMembersResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembersResultItem]
List of member metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembersResultItem which contains the following fields:

ParameterDescription
getUUID()
Type: PNMember
UUID metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMember which contains the following fields:

ParameterDescription
getId()
Type: String
Unique user identifier
getName()
Type: String
Display name for the user
getExternalId()
Type: String
User's identifier in an external system
getProfileUrl()
Type: String
The URL of the user's profile picture
getEmail()
Type: String
The user's email address
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Set channel members

Set users in a channel. Provide UUIDs (optionally with custom data).

Method(s)

To Set Channel Members you can use the following method(s) in the PHP SDK:

setMembers()
->channel(String)
->uuids(Array[String | Array])
->custom(Array | StdClass)
->include(PNMemberIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
channel() *
Type: String
Default:
n/a
Unique channel identifier
uuids() *
Type: Array[String or Array]
Default:
n/a
Array of members to add to the channel. Array can contain strings (uuid only) or arrays/objects (which can include custom data).
custom() *
Type: Array or StdClass
Default:
n/a
Object of key-value pairs with supported data types.
include()
Type: PNMemberIncludes
Default:
n/a
The additional information to include in the member response.
 → custom
Type: Boolean
Default:
False
Indicates whether custom data should be included in the response.
 → status
Type: Boolean
Default:
False
Indicates whether the status should be included in the response.
 → type
Type: Boolean
Default:
False
Indicates whether the type should be included in the response.
 → total_count
Type: Boolean
Default:
False
Indicates whether the total count should be included in the response.
 → user
Type: Boolean
Default:
False
Indicates whether the user ID information should be included in the response.
 → userCustom
Type: Boolean
Default:
False
Indicates whether custom data for the user should be included in the response.
 → userType
Type: Boolean
Default:
False
Indicates whether the type of the user should be included in the response.
 → userStatus
Type: Boolean
Default:
False
Indicates whether the status of the user should be included in the response.
filter()
Type: String
Default:
n/a
Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()
Type: String or Array[String]
Default:
n/a
String or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()
Type: integer
Default:
100
Number of objects to return in response. Default is 100, which is also the maximum value.
page()
Type: Array[String => String]
Default:
n/a
Use for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.
API limits

To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.

Sample code


Response

The setMembers() operation returns a PNMembersResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembersResultItem]
List of member metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembersResultItem which contains the following fields:

ParameterDescription
getUUID()
Type: PNMember
UUID metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMember which contains the following fields:

ParameterDescription
getId()
Type: String
Unique user identifier
getName()
Type: String
Display name for the user
getExternalId()
Type: String
User's identifier in an external system
getProfileUrl()
Type: String
The URL of the user's profile picture
getEmail()
Type: String
The user's email address
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Remove channel members

Remove users from a channel. Provide the UUIDs to remove.

Method(s)

To Remove Channel Members you can use the following method(s) in the PHP SDK:

removeMembers()
->channel(String)
->members(PNChannelMember[])
->include(PNMemberIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
channel() *
Type: String
Default:
n/a
Unique channel identifier
members() *
Type: PNChannelMember[]
Default:
n/a
Array of members to remove from the channel
include()
Type: PNMemberIncludes
Default:
n/a
Whether to include additional fields.
 → custom
Type: Boolean
Default:
False
Whether to include the Custom object in the response.
 → status
Type: Boolean
Default:
False
Whether to include the status field.
 → type
Type: Boolean
Default:
False
Whether to include the type field.
 → total_count
Type: Boolean
Default:
False
Whether to include the total count in the paginated response.
 → user
Type: Boolean
Default:
False
Whether to include user fields.
 → userCustom
Type: Boolean
Default:
False
Whether to include the user Custom object.
 → userType
Type: Boolean
Default:
False
Whether to include the user type field.
 → userStatus
Type: Boolean
Default:
False
Whether to include the user status field.
filter()
Type: String
Default:
n/a
Filter expression. Only matching objects are returned. See filtering.
sort()
Type: String or Array[String]
Default:
n/a
Sort by id, name, updated with asc/desc for sort direction (for example, name:asc).
limit()
Type: integer
Default:
100
Number of objects to return. Default/Max: 100.
page()
Type: Array[String => String]
Default:
n/a
Cursor-based pagination. Use prev and next tokens returned by the server.

Sample code


Response

The removeMembers() operation returns a PNMembersResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembersResultItem]
List of member metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembersResultItem which contains the following fields:

ParameterDescription
getUUID()
Type: PNMember
UUID metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMember which contains the following fields:

ParameterDescription
getId()
Type: String
Unique user identifier
getName()
Type: String
Display name for the user
getExternalId()
Type: String
User's identifier in an external system
getProfileUrl()
Type: String
The URL of the user's profile picture
getEmail()
Type: String
The user's email address
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Manage channel members

Add and remove users in a channel in one request.

To Manage Channel Members you can use the following method(s) in the PHP SDK:

manageMembers()
->channel(String)
->setUuids(Array[String])
->removeUuids(Array[String])
->setMembers(Array[PNChannelMember])
->removeMembers(Array[PNChannelMember])
->custom(Array | StdClass)
->include(PNMemberIncludes)
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
* required
ParameterDescription
channel() *
Type: String
Default:
n/a
Unique channel identifier
channel() *
Type: String
Default:
n/a
Unique channel identifier
setUuids() *
Type: Array[String]
Default:
n/a
Array of UUIDs to add to the channel.
removeUuids() *
Type: Array[String]
Default:
n/a
Array of UUIDs to remove from the channel.
setMembers() *
Type: Array[PNChannelMember]
Default:
n/a
Array of PNChannelMember objects to add to the channel.
removeMembers() *
Type: Array[PNChannelMember]
Default:
n/a
Array of PNChannelMember objects to remove from the channel.
custom() *
Type: Array or StdClass
Default:
n/a
Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported.
include()
Type: PNMemberIncludes
Default:
n/a
Whether to include additional fields.
 → custom
Type: Boolean
Default:
False
Whether to include the Custom object in the response.
 → status
Type: Boolean
Default:
False
Whether to include the status field.
 → type
Type: Boolean
Default:
False
Whether to include the type field.
 → total_count
Type: Boolean
Default:
False
Whether to include the total count in the paginated response.
 → user
Type: Boolean
Default:
False
Whether to include user fields.
 → userCustom
Type: Boolean
Default:
False
Whether to include the user Custom object.
 → userType
Type: Boolean
Default:
False
Whether to include the user type field.
 → userStatus
Type: Boolean
Default:
False
Whether to include the user status field.
filter()
Type: String
Default:
n/a
Filter expression. Only matching objects are returned. See filtering.
sort()
Type: String or Array[String]
Default:
n/a
Sort by id, name, updated with asc/desc for sort direction (for example, name:asc).
limit()
Type: integer
Default:
100
Number of objects to return. Default/Max: 100.
page()
Type: Array[String => String]
Default:
n/a
Cursor-based pagination. Use prev and next tokens returned by the server.

Sample code


Response

The manageMembers() operation returns a PNMembersResult which contains the following fields:

ParameterDescription
getData()
Type: Array[PNMembersResultItem]
List of member metadata results
getTotalCount()
Type: Integer
Number of items returned in the data
getPrev()
Type: String
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.
getNext()
Type: String
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.

Data is an array of PNMembersResultItem which contains the following fields:

ParameterDescription
getUUID()
Type: PNMember
UUID metadata
getCustom()
Type: String
stdClass object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag

Channel is a PNMember which contains the following fields:

ParameterDescription
getId()
Type: String
Unique user identifier
getName()
Type: String
Display name for the user
getExternalId()
Type: String
User's identifier in an external system
getProfileUrl()
Type: String
The URL of the user's profile picture
getEmail()
Type: String
The user's email address
getCustom()
Type: stdClass
Object containing your custom fields
getUpdated()
Type: String
The last updated date and time
getETag()
Type: String
The entity tag
Last updated on