Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Android
iOS
Web
Windows
Unity
Flutter
React Native

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 a push notification in a synchronous way

Sends a push notification to a user in a synchronous way. After sending a push notification, Agora server returns the push status in the HTTP response. If a third-party push service is used, the third-party push server will send the push result to the Agora server which will determine the push status based on the received push result.

For each App Key, the total call frequency limit of this method is 1 per second.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/push/sync/{target}

Path parameters

ParameterTypeDescriptionRequired
targetStringThe user ID of the push notification recipient. You can pass in only one user ID.Yes

For the descriptions of 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
strategyNumberThe push strategy:
  • 0: Use the third-party push service first. If the push attempt fails, use the Agora push service instead.
  • 1: Use Agora push service only. If the target user is online, Agora server sends the push message. If the user is offline, Agora retains the push message for a certain period (depending on the Chat package to which you subscribe) and will send it to the user as soon as he or she gets online. If the user remains offline until the retention period expires, the push message is dropped and the push attempt fails.
  • 2: (Default) Use the third-party push service only. If the target user is offline, whether to retain the push message and how long the message can be retained depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
  • 3: Use the Agora push service first. If the user is online, Agora server sends the notification. If the user is offline, the notification is delivered via a third-party push service. If the offline push attempt fails, the notification is sent via Agora server once the user gets online.
  • 4 Only use online push via Agora server. Push notifications are sent only via Agora server for the online user. If the user is offline, the push notifications are discarded.
No
pushMessageJSONThe push notification. For details, see Configure push notifications.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
dataObjectThe push result. The server determines the push status based on the push result.
data.pushStatusStringThe push status:
- SUCCESS: The push succeeds.
- FAIL: The push fails due to an error that is not caused by the server, like bad device token, indicating that the mobile device delivers an incorrect device token to the server and the server does not accept it.
- ERROR: The push exception occurs due to a server error, for example, connection timeout or read or write timeout.
data.dataObjectThe push result data returned by the push service used by the push notification recipient.
data.descStringThe description for the push failure.

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


_12
# Replace {YourAppToken} with the app token generated in your server.
_12
curl -X POST 'http://XXXX/XXXX/XXXX/push/sync/test1' \
_12
-H 'Authorization: Bearer <YourAppToken>' \
_12
-H 'Content-Type: application/json' \
_12
-d '{
_12
"strategy": 3,
_12
"pushMessage": {
_12
"title": "Agora push",
_12
"content": "Hello and welcome",
_12
"sub_title": "Agora"
_12
}
_12
}'

Response example

  1. The push succeeds:

_20
{
_20
"timestamp": 1689154498019,
_20
"data": [
_20
{
_20
"pushStatus": "SUCCESS",
_20
"data": {
_20
"code": 200,
_20
"data": {
_20
"expireTokens": [],
_20
"sendResult": true,
_20
"requestId": "104410638-fd96648b6bb4344bc4f5e29b158fdb07",
_20
"failTokens": [],
_20
"msgCode": 200
_20
},
_20
"message": "Success"
_20
}
_20
}
_20
],
_20
"duration": 2
_20
}

  1. When a third-party push service is used, the push fails because the push-related information (like the push token or certificate) is not bound with the device:

_10
{
_10
"timestamp": 1689154624797,
_10
"data": [
_10
{
_10
"pushStatus": "FAIL",
_10
"desc": "no push binding"
_10
}
_10
],
_10
"duration": 0
_10
}

  1. When a third-party push service is used, the push fails because the user ID of the push notification recipient does not exist:

_10
{
_10
"timestamp": 1689154534352,
_10
"data": [
_10
{
_10
"pushStatus": "FAIL",
_10
"desc": "appUser not exists"
_10
}
_10
],
_10
"duration": 0
_10
}

Send a push notification to users in an asynchronous way

Sends a push notification to one or more users in an asynchronous way.

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 user IDs of push notification recipients. You can pass in up to 100 user IDs each time.Yes
strategyNumberThe push strategy:
  • 0: Use the third-party push service first. If the push attempt fails, use the Agora push service instead.
  • 1: Use Agora push service only. If the target user is online, Agora server sends the push message. If the user is offline, Agora retains the push message for a certain period (depending on the Chat package to which you subscribe) and will send it to the user as soon as he or she gets online. If the user remains offline until the retention period expires, the push message is dropped and the push attempt fails.
  • 2: (Default) Use the third-party push service only. If the target user is offline, whether to retain the push message and how long the message can be retained depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
  • 3: Use the Agora push service first. If the user is online, Agora server sends the notification. If the user is offline, the notification is delivered via a third-party push service. If the offline push attempt fails, the notification is sent via Agora server once the user gets online.
  • 4 Only use online push via Agora server. Push notifications are sent only via Agora server for the online user. If the user is offline, the push notifications are discarded.
No
pushMessageJSONThe push message. See Configure 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 user IDs of push notification recipients.
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://XXXX/XXXX/XXXX/push/single" -H "Authorization: Bearer <YourAppToken>" -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 a push notification by label

Sends a push notification 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. A maximum of three push tasks can be executed at the same time.

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 the push notification to all users under the label, or pass a maximum of five labels to send the push notification to the intersection of users under these labels.Yes
startDateStringThe start date of the push task. The date format is yyyy-MM-dd HH:mm:ss, for example, 2024-01-01 12:00:00.
  • 1. The scheduled time must be one hour later than the curren time or 30 days from the current time.
  • 2. By default, the scheduled time is in the time zone where the server resides. If you want to use a time in a different time zone, you must calculate that time according to your time zone.
No
strategyNumberThe push strategy:
  • 0: Use the third-party push service first. If the push attempt fails, use the Agora push service instead.
  • 1: Use Agora push service only. If the target user is online, Agora server sends the push message. If the user is offline, Agora retains the push message for a certain period (depending on the Chat package to which you subscribe) and will send it to the user as soon as he or she gets online. If the user remains offline until the retention period expires, the push message is dropped and the push attempt fails.
  • 2: (Default) Use the third-party push service only. If the target user is offline, whether to retain the push message and how long the message can be retained depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
  • 3: Use the Agora push service first. If the user is online, Agora server sends the notification. If the user is offline, the notification is delivered via a third-party push service. If the offline push attempt fails, the notification is sent via Agora server once the user gets online.
  • 4 Only use online push via Agora server. Push notifications are sent only via Agora server for the online user. If the user is offline, the push notifications are discarded.
No
pushMessageJSONThe push messages. See Configure 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://XXXX/XXXX/XXXX/push/list/label' \
_14
-H 'Authorization: Bearer <YourAppToken>' \
_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 a push notification to all users under the app

Sends a push notification 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. A maximum of three push tasks can be executed at the same time.

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
startDateStringThe start date of the push task. The date format is yyyy-MM-dd HH:mm:ss, for example, 2024-01-01 12:00:00.
  • 1. The scheduled time must be one hour later than the curren time or 30 days from the current time.
  • 2. By default, the scheduled time is in the time zone where the server resides. If you want to use a time in a different time zone, you must calculate that time according to your time zone.
No
strategyNumberThe push strategy:
  • 0: Use the third-party push service first. If the push attempt fails, use the Agora push service instead.
  • 1: Use Agora push service only. If the target user is online, Agora server sends the push message. If the user is offline, Agora retains the push message for a certain period (depending on the Chat package to which you subscribe) and will send it to the user as soon as he or she gets online. If the user remains offline until the retention period expires, the push message is dropped and the push attempt fails.
  • 2: (Default) Use the third-party push service only. If the target user is offline, whether to retain the push message and how long the message can be retained depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
  • 3: Use the Agora push service first. If the user is online, Agora server sends the notification. If the user is offline, the notification is delivered via a third-party push service. If the offline push attempt fails, the notification is sent via Agora server once the user gets online.
  • 4 Only use online push via Agora server. Push notifications are sent only via Agora server for the online user. If the user is offline, the push notifications are discarded.
No
pushMessageJSONThe push messages. See Configure 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://XXXX/XXXX/XXXX/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. For example, 1650859482843 indicates 2022-04-25 12:04:42. The timestamp is the current timestamp plus how long the notification stays open.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
interruptionLevelinterruption-level
liveActivityEventevent
timestamptimestamp
dismissalDatedismissal-date
staleDatestale-date
attributesTypeattributes-type
attributesattributes
contentStatecontent-state

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 'http://XXXX/XXXX/XXXX/push/label' \
_7
-H 'Authorization: Bearer <YourAppToken>' \
_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 'http://XXXX/XXXX/XXXX/push/label/90' \
_2
-H 'Authorization: Bearer <YourAppToken>'

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 'http://XXXX/XXXX/XXXX/push/label/post-90s' \
_2
-H 'Authorization: Bearer <YourAppToken>'

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 20,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 in a maximum of 100 user IDs each time.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 'http://XXXX/XXXX/XXXX/push/label/post-90s/user' \
_6
-H 'Authorization: Bearer <YourAppToken>' \
_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 'http://XXXX/XXXX/XXXX/push/label/post-90s/user/hx1' \
_2
-H 'Authorization: Bearer <YourAppToken>'

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 'http://XXXX/XXXX/XXXX/push/label/post-90s/user?limit=1' \
_2
-H 'Authorization: Bearer <YourAppToken>'

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
ParameterTypeDescriptionRequired
usernamesListThe 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 'http://XXXX/XXXX/XXXX/push/label/post-90s/user' \
_6
-H 'Authorization: Bearer <YourAppToken>' \
_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.

vundefined