Request Headers (Applies to all methods)
POST
/api/apps/{appID}/users/{accountType}:{address}/topics/{topicID}/push/messages
Send a push message to the current topic.
A 400 status error with code INVALID_INPUT_DATA will be returned in the following scenarios:
- None of "fcm", "gcm", "apns", "jpush" and "mqtt" fields is provided in the request.
- None of "fcm.enabled", "gcm.enabled" or "apns.enabled" fields is provided in the request.
- "gcm.dryRun" and "apns.enabled" are both set to true.
- "data" contains nested JSONs or arrays.
- "fcm.data" or "gcm.data" contains values different from String.
- "apns.enabled" is true and "apns.data" contains nested JSONs or arrays.
- "gcm.enabled" is set to true and "data" or "gcm.data" contains a key
that starts with the prefix
"google." or is one of these values:
- from
- registration_ids
- collapse_key
- data
- delay_while_idle
- time_to_live
- restricted_package_name
- dry_run
- "fcm.enabled" is set to true and "data" or "fcm.data" contains a key
that starts with the prefixes
"google." or "gcm." or is one of these values:
- from
- message_type
- collapse_key
- priority
- ttl
- restricted_package_name
- notification
- fcm_options
- direct_boot_ok
- "fcm.enabled" is true and the payload for Android-FCM exceeds 4096 bytes.
- "gcm.enabled" is true and the payload for Android-GCM exceeds 4096 bytes.
- "apns.enabled" is true and the payload for iOS-APNS exceeds 2048 bytes.
If both GCM and FCM specific fields are enabled, the FCM push notification will be prioritized.
FCM-specific fields:
Field | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the FCM installations of the subscribed users. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to Android-FCM devices. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
notification |
JSON Object with the following format:
|
Notification template. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
android |
JSON Object with the following format:
|
Android specific options for messages. |
GCM-specific fields:
Field | Type | Description |
---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the GCM installations of the subscribed users. |
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to Android-GCM devices. |
notification | Notification payload. | We supports title, body, icon, sound, tag, color and clickAction fields in notification. Other fields are not supported yet. |
collapseKey | String. Not required. | If provided, it will be used as the GCM notification collapse_key |
delayWhileIdle | Boolean. Not required. | If provided, it will be used as the GCM notification delay_while_idle |
timeToLive | Integer. Not required. | If provided, it will be used as the GCM notification time_to_live |
restrictedPackageName | String. Not required. | If provided, it will be used as the GCM restricted_package_name |
dryRun | Boolean. Not required. If true, the only system that can be enabled is “GCM” - no other system will be accepted. | If provided, it will be used as the GCM dry_run |
iOS-APNS specific fields:
Field | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the APNS installations of the subscribed users. | ||||||||||||||||
data | JSON Object with only one-level of nesting, and only strings, integers, booleans or doubles in the values. | Dictionary with the data that will be sent only to iOS-APNS devices. | ||||||||||||||||
alert |
JSON Object with the format:
|
All the information related to the alert that will be shown when the notification is received while the app is turned off. See details in APNS documentation. | ||||||||||||||||
sound | String. Not required. | If provided, it will be used as the “sound” to be sent with the notification. See details in APNS documentation. | ||||||||||||||||
badge | Number. Not required. | If provided, it will be used as the “badge” to be sent with the notification. See details in APNS documentation. | ||||||||||||||||
contentAvailable | Boolean. Not required. | If provided and has "true" value, the value "1" will be set in the field "content-available" in the notification; otherwise the field will not be sent. See details in APNS documentation. | ||||||||||||||||
category | String. Not required. | If provided, it will be used as the “category” to be sent with the notification. See details in APNS documentation. | ||||||||||||||||
mutableContent | Boolean. Not required. | If provided and has "true" value, the value "1" will be set to the field "mutable-content" in the notification; otherwise the field will not be sent. See details in APNS documentation. |
JPUSH specific fields:
Field | Type | Description |
---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the JPUSH installations of the subscribed users. |
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to JPUSH devices. |
MQTT specific fields:
Field | Type | Description |
---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the MQTT installations of the subscribed users. |
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to MQTT devices. |
dryRun | Boolean. Not required, | Used for testing. If provided with "true" value, the message will not be sent to the device. Default is "false". |
retain | Boolean. Not required. | >Retain message. (currently always false) |
qos | Integer. Not required. | Quality of service for the message (default will be 0 - fire and forget) |
The administrator can execute this action. For other users, the permission to execute this action depends on the ACL of the topic.
Content-Type application/vnd.kii.SendPushMessageRequest+json
All the data to send the message.
{
"data": "[JSONObject]",
"sendToDevelopment": "[boolean]",
"sendToProduction": "[boolean]",
"pushMessageType": "[string]",
"sendSender": "[boolean]",
"sendWhen": "[boolean]",
"sendOrigin": "[boolean]",
"sendAppID": "[boolean]",
"sendObjectScope": "[boolean]",
"sendTopicID": "[boolean]",
"sendSourceURI": "[boolean]",
"sendSenderURI": "[boolean]",
"fcm": "[FCMType]",
"gcm": "[GCMType]",
"apns": "[APNSType]",
"jpush": "[JPUSHType]",
"mqtt": "[MQTTType]"
}
Content-Type application/vnd.kii.SendPushMessageResponse+json
Name | Type | Description |
---|---|---|
pushMessageID | string | The ID of the sent message |
Content-Type application/vnd.kii.UserNotFoundException+json
Name | Type | Description |
---|---|---|
errorCode | string | Error code "USER_NOT_FOUND". |
message | string | The error message. |
field | string | The field used for searching the user. This can be the userID or address field. |
value | string | The field value used for searching the user. |
appID | string | The ID of the application. |
Content-Type application/vnd.kii.TopicNotFoundException+json
Name | Type | Description |
---|---|---|
errorCode | string | Error code "TOPIC_NOT_FOUND". |
message | string | The error message. |
topicID | string | The ID of the topic that is not found |
objectScope | ObjectScope | The scope of the topic |
appID | string | The ID of the application. |
userID | string | The ID of the user. Only provided for a user-scope bucket. |
groupID | string | The ID of the group. Only provided for a group-scope bucket. |
thingID | string | The ID of the thing. Only provided for a thing-scope bucket. |
type | string | One of "APP", "APP_AND_USER", "APP_AND_GROUP", or "APP_AND_THING". |
Content-Type application/vnd.kii.ValidationException+json
- "gcm" or "apns" fields are not provided in the request.
- "gcm.enabled" or "apns.enabled" fields are not provided in the request.
- "gcm.dryRun" is true and at least one of "apns.enabled", "jpush.enabled" or "mqtt.enabled" is also true.
- "mqtt.dryRun" is true and at least one of "apns.enabled", "jpush.enabled" or "gcm.enabled" is also true.
- "data" contains nested JSONs or arrays.
- "gcm.enabled" is true and "gcm.data" contains values different from String.
- "apns.enabled" is true and "apns.data" contains nested JSONs or arrays.
- "jpush.enabled" is true and "jpush.data" contains nested JSONs or arrays.
- "mqtt.enabled" is true and "mqtt.data" contains nested JSONs or arrays.
- "gcm.enabled" is set to true and "data" or "gcm.data" contain a key that starts with the prefix
"google." or is one of these values:
- from
- registration_ids
- collapse_key
- data
- delay_while_idle
- time_to_live
- restricted_package_name
- dry_run
- "fcm.enabled" is set to true and "data" or "fcm.data" contains a key
that starts with the prefixes
"google." or "gcm." or is one of these values:
- from
- message_type
- collapse_key
- priority
- ttl
- restricted_package_name
- notification
- fcm_options
- direct_boot_ok
- "apns.enabled" is set to true and "data" or "apns.data" contains a key with value "aps"
- "mqtt.enabled" is set to true and "data" or "mqtt.data" contain a key that starts with the prefix
"kii." or is one of these values:
- from
- installationIds
- data
- retain
- dry_run
- "gcm.enabled" is true and the payload for Android-GCM exceeds 4096 bytes.
- "apns.enabled" is true and the payload for iOS-APNS exceeds 2048 bytes.
- "jpush.enabled" is true and the payload for JPUSH exceeds 986 bytes.
- "mqtt.enabled" is true and the payload for MQTT exceeds 4096 bytes.
Name | Type | Description |
---|---|---|
errorCode | string | Error code "INVALID_INPUT_DATA". |
message | string | The error message. |
Content-Type application/vnd.kii.UnauthorizedAccessException+json
Name | Type | Description |
---|---|---|
errorCode | string | Error code "UNAUTHORIZED". |
message | string | The error message. |
authenticatedAppID | string | The authenticated appID. |
authenticatedPrincipalID | string | The authenticated principal ID (userID or thingID). |