Skip to main content

Push notification management

Push notifications allow you to broadcast app-wide announcements to all or selected users. This page explains how to use Chat RESTful APIs to send and configure push notifications.

Authorization

Chat RESTful APIs require Bearer HTTP authentication. Every time an HTTP request is sent, the following Authorization field must be filled in the request header:


_1
Authorization: Bearer ${YourAppToken}

In order to improve the security of the project, Agora uses a token (dynamic key) to authenticate users before they log in to the chat system. Chat RESTful APIs only support authenticating users using app tokens. For details, see Authentication using App Token.

Send push notifications

Common parameters

The following table lists common request and response parameters of the Chat RESTful APIs:

Request parameters

ParameterTypeDescriptionRequired
hostStringThe domain name assigned by the Chat service to access RESTful APIs. For how to get the domain name, see Get the information of your project.Yes
org_nameStringThe unique identifier assigned to each company (organization) by the Chat service. For how to get the organization name, see Get the information of the Chat project.Yes
app_nameStringThe unique identifier assigned to each app by the Chat service. For how to get the app name, see Get the information of the Chat project.Yes
usernameStringThe unique login account of the user.Yes

Response parameters

ParameterTypeDescription
timestampNumberThe Unix timestamp (ms) of the HTTP response.
durationNumberThe duration (ms) from when the HTTP request is sent to the time the response is received.

Send push notifications by users

Sends push notifications to one or more users by specifying user IDs.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/push/single

Path parameters

For the descriptions of path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
Content-TypeStringThe content type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes
Request body
ParameterTypeDescriptionRequired
targetsListThe targeting user IDs. You can pass one user at most for synchronous push and a maximum of 100 users for asynchronous push.Yes
asyncBooleanWhether to implement a synchronous or asynchronous push:
  • true: (Default) Push asynchronously to a maximum of 100 users.
  • false: Push synchronously to one user at most.
You can send push notifications to multiple users (set targets to more than one user ID) only if you set async to true.
No
strategyNumberThe push strategies.
  • 0: Use third-party push service first. When the pushing attempt fails, use Agora push service instead.
  • 1: Use Agora push service only. If the target user is offline, Agora retains the push message for a certain period, depending on the Chat package to which you subscribe. After the retention period, the push message is dropped and the push attempt fails.
  • 2: (Default) Use third-party push service only. If the target user is offline, whether to retain the push message and the retention period of the push message depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
  • 3: Use Agora push service first. When the pushing attempt fails, use third-party push service instead.
No
pushMessageJSONThe push messages. See Set push notifications for details.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSONThe push result.
idStringThe targeting user ID.
pushStatusStringThe push status:
  • SUCCESS: The push succeeds.
  • FAIL: The push fails due to non-server errors. For example, an invalid token is passed.
  • ERROR: The push fails due to server errors. For example, the request times out.
  • ASYNC_SUCCESS: The asynchronous push succeeds.
descStringThe result description.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_13
curl -X POST "http://localhost:8099/agora-demo/testy/push/single" -H "Authorization: Bearer YWMtOzQVjJ3mEeuJQv1qXhB5QAAAAAAAAAAAAAAAAAAAAAFDtjwasNNKD6W3CET2O3RNAQMAAAF41YIKUABPGgDuIZeu5IMVC_M9G5JlTjUsZeYVSg5o8BwshLgWveZxjA" -H "Content-Type: application/json" --data-raw "{
_13
\"targets\": [
_13
\"test2\"
_13
],
_13
\"pushMessage\": {
_13
\"title\": \"Hello\",
_13
\"subTitle\": \"Hello\",
_13
\"content\": \"Hello\",
_13
\"vivo\": {
_13
_13
}
_13
}
_13
}"

Response example

_11
{
_11
"timestamp": 1619506344007,
_11
"data": [
_11
{
_11
"id": "test2",
_11
"pushStatus": "ASYNC_SUCCESS",
_11
"desc": "async success."
_11
}
_11
],
_11
"duration": 14
_11
}

Send push notifications by labels

Sends push notifications to all users under one label, or the intersection of users under multiple labels.

A push task is automatically created per request, and the ID of the push task is returned for data statistics.

See Set push labels for configuring labels.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/push/list/label

Path parameter

For the descriptions of path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
Content-TypeStringThe content type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes
Request body
ParameterTypeDescriptionRequired
targetsListThe targeting label names. You can either pass one label to send push notifications to all users under the label, or pass a maximum of three labels to send push notifications to the intersection of users under these labels.Yes
strategyNumberThe push strategies.
  • 0: Use third-party push service first. When the pushing attempt fails, use Agora push service instead.
  • 1: Use Agora push service only. If the target user is offline, Agora retains the push message for a certain period, depending on the Chat package to which you subscribe. After the retention period, the push message is dropped and the push attempt fails.
  • 2: (Default) Use third-party push service only. If the target user is offline, whether to retain the push message and the retention period of the push message depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
  • 3: Use Agora push service first. When the pushing attempt fails, use third-party push service instead.
No
pushMessageJSONThe push messages. See Set push notifications for details.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSONThe detailed information of the push task.
taskIdNumberThe ID of the push task.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_14
curl -L -X POST 'http://a1-hsb.agora.com/agora-demo/easeim/push/list/label' \
_14
-H 'Authorization: Bearer YWMtIPBHKsOyEeAAAAAAAAAAAExCXvf5bRGAJBgXNYFJVQ9AQMAAAGAWu67KQBPGgBOV9ghkGKbtt9H9b1' \
_14
-H 'Content-Type: application/json' \
_14
--data-raw '{
_14
"targets": [
_14
"post-90s"
_14
],
_14
"strategy": 2,
_14
"pushMessage": {
_14
"title": "Agora PUSH",
_14
"content": "Welcome to Agora Push Service",
_14
"sub_title": "Agora"
_14
}
_14
}'

Response example

_7
{
_7
"timestamp": 1650859482843,
_7
"data": {
_7
"taskId": 968120369184112182
_7
},
_7
"duration": 0
_7
}

Send push notifications to all users under the app

Sends push notifications to all users under the app.

A push task is automatically created per request, and the ID of the push task is returned for data statistics.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/push/task

Path parameter

For the descriptions of path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
Content-TypeStringThe content type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes
Request body
ParameterTypeDescriptionRequired
strategyNumberThe push strategies.
  • 0: Use third-party push service first. When the pushing attempt fails, use Agora push service instead.
  • 1: Use Agora push service only. If the target user is offline, Agora retains the push message for a certain period, depending on the Chat package to which you subscribe. After the retention period, the push message is dropped and the push attempt fails.
  • 2: (Default) Use third-party push service only. If the target user is offline, whether to retain the push message and the retention period of the push message depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
  • 3: Use Agora push service first. When the pushing attempt fails, use third-party push service instead.
No
pushMessageJSONThe push messages. See Set push notifications for details.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataNumberThe ID of the push task.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_8
curl -X POST "http://a1-hsb.agora.com/agora-demo/testy/push/task" -H "Content-Type: application/json" --data-raw "{
_8
\"pushMessage\": {
_8
\"title\": \"Hello1234\",
_8
\"subTitle\": \"Hello\",
_8
\"content\": \"Hello\",
_8
\"vivo\": {}
_8
}
_8
}"

Response example

_5
{
_5
"timestamp": 1618817591755,
_5
"data": 968120369184112182,
_5
"duration": 1
_5
}

Status codes

For details, see HTTP Status Codes.

Configure push notifications

Chat not only provides basic configurations that are adaptive to all, but also supports advanced configurations varied by service providers. You can choose the service provider and configure the notification fields based on your business requirements.

A push notification example is as follows:


_23
{
_23
// Basic configurations available to all
_23
"title": "You have a message",
_23
"subTitle": "",
_23
"content": "Check the message",
_23
"ext": {},
_23
"config": {
_23
"clickAction": {
_23
"url":"",
_23
"action":"",
_23
"activity":""
_23
},
_23
"badge": {
_23
"addNum": 0,
_23
"setNum": 0
_23
}
_23
},
_23
_23
// Advanced configurations varied by service providers
_23
"agora":{},
_23
"apns": {},
_23
"fcm": {}
_23
}

Basic configurations

The following table lists basic configuration fields available to all:

FieldTypeDescriptionSupported platformsRequired
titleStringThe title of the notification. The value of this field is "You have a message" by default. The length of this field cannot exceed 32 characters.Android & iOSYes
subTitleStringThe subtitle of the notification that provides additional information. The length of this field cannot exceed 10 characters.iOSNo
contentStringThe body text of the notification. The value of this field is "Check the message" by default. The length of this field cannot exceed 100 characters.Android & iOSYes
extJSONThe custom extension of the notification stored in key-value pairs. The number of key-value pairs can be a maximum of 10, and the total length of key-value pairs can be 1024 characters at most.Android & iOSNo
configJSONThe configuration of click action and badge value in the notifications center.Android & iOSNo
config.clickActionJSONThe action triggered by a user click on the notification, which contains the following fields:
  • url: Direct to a URL. Specify a custom URL; otherwise, the user click on notifications cannot work as expected.
  • action: Open a specific page in the app. Specify the address of an in-app page.
  • Open a package or an Activity component. Specify a package name or component path.
AndroidNo
config.badgeJSONThe value of the badge displayed on the app’s icon, which contains the following fields (Int):
  • addNum: The new notification adds on the badge number.
  • setNum: The new notification resets the badge number.
iOS & Android

Advanced configurations

If the basic configuration fields stated above cannot meet your business requirements, Chat allows you to implement advanced configurations provided by the following push services. All messages can be pushed via the three channels, regardless of whether users are online or offline. For how to choose to use the three push services, see the strategy parameter in Send push notifications.

FieldTypeDescriptionRequired
agoraJSONThe Agora push service.No
apnsJSONApple Push Notification service (APNs).No
fcmJSONFirebase Cloud Messaging (FCM).No

Advanced configurations overwrite the basic ones by default.

Agora push service

An Agora push notification example is as follows:


_28
{
_28
"title": "The title of the notification",
_28
"content": "The body text of the notification",
_28
"subTitle": "The subtitle of the notification",
_28
"iconUrl": "https://web-cdn.agora.io/docs-files/1676966850073",
_28
"needNotification": true,
_28
"badge": {
_28
"setNum": 0,
_28
"addNum": 1,
_28
"activity": "com.hyphenate.chat.section.me.activity.AboutHxActivity"
_28
},
_28
"operation": {
_28
"type": "2",
_28
"openUrl": "https://www.baidu.com/",
_28
"openAction": "com.hyphenate.chat.section.me.activity.OfflinePushSettingsActivity"
_28
},
_28
"channelId": "chat",
_28
"channelName": "message",
_28
"channelLevel": 3,
_28
"autoCancel": 1,
_28
"expiresTime": 3600000,
_28
"sound": 0,
_28
"vibrate": 0,
_28
"style": 2,
_28
"bigTxt": "Big text content",
_28
"bigPicture": "https://web-cdn.agora.io/docs-files/1676966850073",
_28
"id": 056734579
_28
}

The following table lists advanced configuration fields provided by Agora:

FieldTypeDescriptionSupported platforms
titleStringThe title of the notification.iOS & Android
contentStringThe body text of the notification.iOS & Android
subTitleStringThe subtitle of the notification that provides additional information.iOS
iconUrlStringThe URL of the app icon.iOS & Android
needNotificationBooleanWether a notification pops out:
  • true: (Default) Yes.
  • false: No.
iOS & Android
badgeJSONThe value of the badge displayed on the app’s icon, which contains the following fields:
  • addNum: The new notification adds on the badge number.
  • setNum: The new notification resets the badge number.
iOS & Android
operationJSONThe action triggered by a user click on the notification.iOS & Android
operation.typeNumberThe type of the action.
  • 0: (Default) Launch the app.
  • 1: Direct to a URL. Set operation.openUrl to a custom URL; otherwise, the user click on notifications cannot work as expected.
  • 2: Open a specific page in the app. Set operation.openAction to the address of the in-app page, and set operation.openActivity to the package name or component path; otherwise, the user click on notifications cannot work as expected.
iOS & Android
channelIdStringThe channel ID of the notification. The default value is chat. If this parameter is not specified or does not exist, a channel ID is automatically created using channelName and channelLevel.Android
channelNameStringThe name of the channel. The default value is message. This parameter is used to generate the channel ID.Android
channelLevelNumberThe level of the channel.
  • 0: Low.
  • 3: (Default) Medium.
  • 4: High.
This parameter is used to generate the channel ID.
Android
autoCancelNumberWhether the notification center is automatically closed after the user click on notifications.
  • 0: No
  • 1: (Default) Yes
Android
expiresTimeNumberThe Unix timestamp (ms) when the notification expires and disappears from the notification center.iOS & Android
soundNumberWhether a sound plays when the device receives notifications.
  • 0: (Default) No
  • 1: Yes
iOS & Android
vibrateNumberWhether a vibration occurs when the device receive notifications.
  • 0: (Default) No
  • 1: Yes
iOS & Android
styleNumberThe style of the notification.
  • 0: (Default) Normal style.
  • 1: Big test style.
  • 2: Big image style.
iOS & Android
bigTxtStringThe text content. This field is required when style is set to 1.iOS & Android
bigPictureStringThe image URL. This field is required when style is set to 2.Android
idNumberThe ID of the notification. A random number assigned by the Chat service. Chat automatically assigns a random number for each notification by default. If you manually specify this parameter to a value same as a previous ID, the previous notification is overwritten by the new one.iOS & Android

APNs

The mapping of field names between Chat and APNs is as follows:

ChatAPNs
invalidationTimeapns-expiration
priorityapns-priority
pushTypeapns-push-type
collapseIdapns-collapse-id
apnsIdapns-id
badgebadge
soundsound
mutableContentmutable-content
contentAvailablecontent-available
categoryNamecategory
threadIdthread-id
titletitle
subTitlesubtitle
contentbody
titleLocKeytitle-loc-key
titleLocArgstitle-loc-args
subTitleLocKeysubtitle-loc-key
subTitleLocArgssubtitle-loc-args
bodyLocKeylocalizedAlertKey
bodyLocArgsloc-key
extloc-args
launchImagelaunch-image

For descriptions of these fields, see APNs official documentation below:

FCM

The mapping of field names between Chat and FCM is as follows:

ChatFCM
conditioncondition
collapseKeycollapse_key
prioritypriority
timeToLivetime_to_live
dryRundry_run
restrictedPackageNamerestricted_package_name
datadata
notificationnotification
notification.titlenotification.title
notification.bodynotification.body
notification.androidChannelIdnotification.android_channel_id
notification.soundnotification.sound
notification.tagnotification.tag
notification.colornotification.color
notification.clickActionnotification.click_action
notification.titleLocKeynotification.title_loc_key
notification.titleLocArgsnotification.title_loc_args
notification.bodyLocKeynotification.body_loc_key
notification.bodyLocArgsnotification.body_loc_args

For descriptions of these fields, see FCM official documentation: Firebase Cloud Messaging HTTP protocol.

Set push labels

The push service allows you to group targeting users by configuring labels. Each label marks a user group that has similar habits, hobbies, or characteristics. When sending notifications, you can implement a bespoke push by specifying relevant labels, and the messages can then be sent to the users under the labels. For example, you can label a group of users as fashion trendsetters, and push related information about domestic and foreign trend brands to that user group on a regular basis.

You can manage the labels through RESTful API. The relationship between users and labels is many to many, that is, one user can have multiple labels and one label can also have multiple users. You can update the labels without any delay and change user labels by first removing users from their current label and then adding them to a new one.

Before calling the following methods, ensure that you understand the call frequency limit of the Chat RESTful APIs as described in Limitations.

Common parameters

The following table lists common request and response parameters of the Chat RESTful APIs:

Request parameters

ParameterTypeDescriptionRequired
hostStringThe domain name assigned by the Chat service to access RESTful APIs. For how to get the domain name, see Get the information of your project.Yes
org_nameStringThe unique identifier assigned to each company (organization) by the Chat service. For how to get the organization name, see Get the information of the Chat project.Yes
app_nameStringThe unique identifier assigned to each app by the Chat service. For how to get the app name, see Get the information of the Chat project.Yes
usernameStringThe unique login account of the user.Yes

Response parameters

ParameterTypeDescription
timestampNumberThe Unix timestamp (ms) of the HTTP response.
durationNumberThe duration (ms) from when the HTTP request is sent to the time the response is received.

Create a push label

Creates a push label.

You can create a maximum of 100 push labels. To lift the upper limit, contact support@agora.io.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/push/label

Path parameter

For the descriptions of path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
Content-TypeStringThe content type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes
Request body
ParameterTypeDescriptionRequired
nameStringThe name of the push label. The length of each label name cannot exceed 64 characters, and the following character sets are supported:
  • 26 lowercase English letters (a-z)
  • 26 uppercase English letters (A-Z)
  • 10 numbers (0-9)
  • "_", "-", "."
  • The label name is case insensitive, so "Aa" and "aa" are the same label.
  • Ensure that each label name under the same app is unique.
Yes
descriptionStringThe description of the push label. The length of the label description cannot exceed 255 characters.No

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSONThe detailed information of the push label.
nameStringThe label name.
descriptionStringThe label description.
createdAtNumberThe Unix timestamp (ms) when the push label was created.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_7
curl -L -X POST 'localhost/hx/hxdemo/push/label' \
_7
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' \
_7
-H 'Content-Type: application/json' \
_7
--data-raw '{
_7
"name":"post-90s",
_7
"description":"hah"
_7
}'

Response example

_9
{
_9
"timestamp": 1648720341157,
_9
"data": {
_9
"name": "post-90s",
_9
"description": "hah",
_9
"createdAt": 1648720341118
_9
},
_9
"duration": 13
_9
}

Query the detailed information of a push label

Retrieves the detailed information of the specified push label.

HTTP request


_1
GET https://{host}/{org_name}/{app_name}/push/label/{labelname}

Path parameter
ParameterTypeDescriptionRequired
labelnameStringThe name of the push label.Yes

For the descriptions of other path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSONThe detailed information of the push label.
nameStringThe label name.
descriptionStringThe label description.
countNumberThe number of the users added to the push label.
createdAtNumberThe Unix timestamp (ms) when the push label was created.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_2
curl -L -X GET 'localhost/hx/hxdemo/push/label/90' \
_2
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A'

Response example

_10
{
_10
"timestamp": 1648720562644,
_10
"data": {
_10
"name": "90",
_10
"description": "hah",
_10
"count": 0,
_10
"createdAt": 1648720341118
_10
},
_10
"duration": 0
_10
}

Query the detailed information of push labels by page

Retrieves the detailed information of multiple push labels by page.

HTTP request


_1
GET https://{host}/{org_name}/{app_name}/push/label

Path parameter

For the descriptions of the other path parameters, see Common parameters.

Query parameters
ParameterTypeDescriptionRequired
limitNumberThe number of push labels displayed per page. The range is [1,100]. The default value is 100.No
cursorStringThe start position for the next query.No
Request header
ParameterTypeDescriptionRequired
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSON ArrayThe detailed information of the push label.
nameStringThe label name.
descriptionStringThe label description.
countNumberThe number of the users added to the push label.
createdAtNumberThe Unix timestamp (ms) when the push label was created.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_2
curl -L -X GET 'localhost/hx/hxdemo/push/label' \
_2
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A'

Response example

_18
{
_18
"timestamp": 1648720425599,
_18
"data": [
_18
{
_18
"name": "post-90s",
_18
"description": "hah",
_18
"count": 0,
_18
"createdAt": 1648720341118
_18
},
_18
{
_18
"name": "post-80s",
_18
"description": "post-80s generation",
_18
"count": 0,
_18
"createdAt": 1647512525642
_18
}
_18
],
_18
"duration": 1
_18
}

Delete a push label

Deletes the specified push label. You can delete one push label at each call.

HTTP request


_1
DELETE https://{host}/{org_name}/{app_name}/push/label/{labelname}

Path parameter
ParameterTypeDescriptionRequired
labelnameStringThe name of the push label.Yes

For the descriptions of the other path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataStringThe request result. success indicates that the delete operation proceeds properly.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_2
curl -L -X DELETE 'localhost/hx/hxdemo/push/label/post-90s' \
_2
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A'

Response example

_5
{
_5
"timestamp": 1648721097405,
_5
"data": "success",
_5
"duration": 0
_5
}

Add users to a push label

Adds one or more users to the specified push label. A maximum of 200,000 users can be added to a push label. To lift the upper limit, contact support@agora.io.

You can add a maximum of 100 users at each call.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/push/label/{labelname}/user

Path parameter
ParameterTypeDescriptionRequired
labelnameStringThe name of the push label.Yes

For the descriptions of the other path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
Content-TypeStringThe content type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes
Request body
ParameterTypeDescriptionRequired
usernamesListThe IDs of the users to be added to the push label. You can pass a maximum of 100 users for each request.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSONThe request result.
successListThe user IDs properly added to the push label.
failJSONIf add operations fail, the user IDs failed to be added and the corresponding failure reasons are returned in key-value pairs.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_6
curl -L -X POST 'localhost/hx/hxdemo/push/label/post-90s/user' \
_6
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' \
_6
-H 'Content-Type: application/json' \
_6
--data-raw '{
_6
"usernames":["hx1","hx2"]
_6
}'

Response example

_11
{
_11
"timestamp": 1648721496345,
_11
"data": {
_11
"success": [
_11
"hx1",
_11
"hx2"
_11
],
_11
"fail": {}
_11
},
_11
"duration": 18
_11
}

Query the specified user under the specified push label

Retrieves the detailed information of the specified user under the specified push label.

HTTP request


_1
GET https://{host}/{org_name}/{app_name}/push/label/{labelname}/user/{member}

Path parameter
ParameterTypeDescriptionRequired
labelnameStringThe name of the push label.Yes
memberStringThe ID of the user.Yes

For the descriptions of the other path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSONThe detailed information of the user.
usernameStringThe user ID.
createdNumberThe Unix timestamp (ms) when the user was added to the push label.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_2
curl -L -X GET 'localhost/hx/hxdemo/push/label/post-90s/user/hx1' \
_2
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A'

Response example

_8
{
_8
"timestamp": 1648721589676,
_8
"data": {
_8
"username": "hx1",
_8
"created": 1648721496324
_8
},
_8
"duration": 1
_8
}

Query the detailed information of users under the specified push label by page

Retrieves the detailed information of one or more users under the specified push label by page.

HTTP request


_1
GET https://{host}/{org_name}/{app_name}/push/label/{labelname}/user

Path parameter
ParameterTypeDescriptionRequired
labelnameStringThe name of the push label.Yes

For the descriptions of the other path parameters, see Common parameters.

Query parameters
ParameterTypeDescriptionRequired
limitStringThe number of the users displayed per page. The range is [1,100]. The default value is 100.No
cursorStringThe start position for the next query.No
Request header
ParameterTypeDescriptionRequired
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
cursorStringThe start position for the next query.
dataJSON ArrayThe detailed information of the users.
usernameStringThe user ID.
createdNumberThe Unix timestamp (ms) when the user was added to the push label.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_2
curl -L -X GET 'localhost/hx/hxdemo/push/label/post-90s/user?limit=1' \
_2
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A'

Response example

_11
{
_11
"timestamp": 1648721736670,
_11
"cursor": "ZWFzZW1vYjpwdXNoOmxhYmVsOmN1cnNvcjo5NTkxNTMwMDM4ODQxMzgwMjc",
_11
"data": [
_11
{
_11
"username": "hx1",
_11
"created": 1648721496324
_11
}
_11
],
_11
"duration": 1
_11
}

Remove users from a push label

Removes one or more users from the specified push label. You can remove a maximum of 100 users at each call.

HTTP request


_1
DELETE https://{host}/{org_name}/{app_name}/push/label/{labelname}/user

Path parameter
ParameterTypeDescriptionRequired
labelnameStringThe name of the push label.Yes

For the descriptions of the other path parameters, see Common parameters.

Request header
ParameterTypeDescriptionRequired
Content-TypeStringThe content type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${YourAppToken}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes
Request body

| usernames | List | The IDs of the users to be removed from the push label. You can pass a maximum of 100 users for each request. | Yes |

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

ParameterTypeDescription
dataJSONThe request result.
successListThe user IDs properly removed from the push label.
failJSONIf remove operations fail, the user IDs failed to be removed and the corresponding failure reasons are returned in key-value pairs.

For other fields and detailed descriptions, see Common parameters.

If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

Example

Request example

_6
curl -L -X DELETE 'localhost/hx/hxdemo/push/label/post-90s/user' \
_6
-H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' \
_6
-H 'Content-Type: application/json' \
_6
--data-raw '{
_6
"usernames":["hx1","hx2"]
_6
}'

Response example

_11
{
_11
"timestamp": 1648722018636,
_11
"data": {
_11
"success": [
_11
"hx1",
_11
"hx2"
_11
],
_11
"fail": {}
_11
},
_11
"duration": 1
_11
}

Status codes

For details, see HTTP Status Codes.