Comment on page
REST API Push
You can easily register-unregister devices, send notifications, get notification and device info by using REST API.
Following request is the minimal required parameters to send push notification.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"message" : {
"title" : "Push title",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text!!"
},
"target" : {
"sendToAll" : true
}
}' \
https://restapi.netmera.com/rest/3.0/sendBulkNotification
Parameters title (Required) : Name of the campaign. It helps you to find notifications on panel. platforms (Required) : Platforms to send push. text (Required) : Push notification message which will be shown to user. target (Required) : Target to send push notification. If you set sendToAll value as true, notification will be sent to all selected platform users. Advanced targeting can be found below.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H
"Content-Type: application/json" \
-d '{
"message" : {
"title" : "campaign name in panel",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text!!",
"ios": {
"title": "title here for push notification",
},
"android": {
"title": "title here for push notification",
}
},
"target" : {
"sendToAll" : true
}
}' \
https://restapi.netmera.com/rest/3.0/sendBulkNotification
Parameters title parameter inside message block, gives the campaign name in the panel title parameter inside ios and android block, returns the title of the push notification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H
"Content-Type: application/json" \
-d '{
"message" : {
"title" : "Push title",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text!!",
"labels" : "Apple",
"ios": {
"title": "title here",
"subtitle": "subtitle here"
},
"android": {
"title": "title here",
"subtitle": "subtitle here"
}
},
"target" : {
"sendToAll" : true
}
}'
\
https://restapi.netmera.com/rest/3.0/sendBulkNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"platforms": [
"ANDROID",
"IOS"
],
"text": "Caousel ",
"message": "Test",
"title": "Carousel Test",
"click": {
"url": "https://www.google.com"
},
"ios": {
"title": "ios tests ",
"carousel": [
{
"title": "test",
"content": "test",
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px",
"clickAction": {
"action": "DEEP_LINK",
"url": "htps://www.google.com",
"deeplinkType": "URL",
"deepLinkUrl": "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg"
}
},
{
"title": "test",
"content": "test",
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png"
}
]
},
"android": {
"title": "Android",
"carousel": [
{
"title": "test",
"content": "test",
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png"
},
{
"title": "test",
"content": "test",
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png",
"clickAction": {
"action": "DEEP_LINK",
"url": "htps://www.google.com",
"deeplinkType": "URL",
"deepLinkUrl": "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg"
}
}
]
}
}'
\
​
https://restapi.netmera.com/rest/3.0/sendBulkNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"platforms": [
"ANDROID",
"IOS"
],
"text": "Slider Test ",
"message": "Slider Test",
"title": "Slider Test",
"click": {
"deeplink": "https://www.google.com"
},
"ios": {
"title": "Ios tests ",
"slider": [
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png",
"clickAction": {
"url": "htps://www.google.com"
}
},
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png"
}
]
},
"android": {
"title": "Android Test 1 ",
"slider": [
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png",
"clickAction": {
"url": "htps://www.google.com"
}
},
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png"
}
]
}
}'
https://restapi.netmera.com/rest/3.0/sendBulkNotification
info Given: I create a push to be sent via the Send bulk notification service via Postman. I add label information to When: message. Then: I send the push. And: I see that the label field appears in the push report created on the panel.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"message" : {
"title" : "Push title",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text",
"customJson" : {
"key1" : "value1"
},
"click" : {
"deeplink" : "https://www.google.com"
}
},
"languages": {
"English": {
"title": "title",
"text": "text",
"click": {
"deeplink": "https://www.google.com"
}
},
"Turkish": {
"title": "başlık",
"text": "metin",
"click": {
"deeplink": "https://www.google.com"
}
}
},
"target" : {
"sendToAll" : true
}
}' \
https://restapi.netmera.com/rest/3.0/sendBulkNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"message": {
"title": "Message Title",
"platforms": [
"CHROME",
"MACOS",
"FIREFOX"
],
"text": "Message Text",
// If platforms contains Chrome or Firefox then iconUrl must exist
"wpChromeImage": "<image-url>",
"interactionRequired" : true,
"click": {
"url": "htps://www.google.com"
},
"iconUrl" : "<icon-url>"
},
"target": {
"sendToAll": true
}
}' \
https://restapi.netmera.com/rest/3.0/sendBulkNotification
Parameters title (Required) : Name of the campaign. It helps you to find notifications on panel. text (Required) : Push notification message which will be shown to user. wpChromeImage : Image push will be shown on notification. Url must be start with https. (Windows Chrome & Firefox Only) iconUrl : If platforms contains Chrome or Firefox then iconUrl must exist interactionRequired : Boolean indicating that a notification should remain active until the user clicks or dismisses it, rather than closing automatically. Default value is false.
$BUTTON_SET_ID
: This is the identifier for the button set you want to use.$BUTTON_NAME
: This is the name of the button within the button set.$ACTION_URL
: This is the URL that will be executed when the button is clicked.
Warning:
- 1.Buttons should be created initially within the panel under Settings > Button Sets
- 2.The "Button Name" is not mandatory.
- 3.For platform-specific deliveries, please specify separately for the desired browsers, which can include FIREFOX, EDGE, MACOS, CHROME.
curl -X POST \
​
-H "X-netmera-api-key: your_rest_api_key" \
​
-H "Content-Type: application/json" \
​
-d '{
​
"message" : {
​
"title" : "rest api button set",
​
"platforms" : ["CHROME"],
​
"text" : "push text!!",
​
"iconUrl":"https://netmera.com/img/cropped_logo.png",
​
"buttonSet":{"id":$BUTTON_SET_ID,"$BUTTON_NAME":"$ACTION_URL" ,"$BUTTON_NAME":"$ACTION_URL" }
​
},
​
"target" : {
​
"sendToAll" : true
​
}
​
}' \
​
https://restapi.netmera.com/rest/3.0/sendBulkNotification
$BUTTON_SET_ID
: This is the identifier for the button set you want to use.$BUTTON_NAME
: This is the name of the button within the button set.$ACTION_URL
: This is the URL that will be executed when the button is clicked.
Warning:
- 1.Buttons should be created initially within the panel under Settings > Button Sets
- 2.The "Button Name" is not mandatory.
- 3.For platform-specific deliveries, please specify separately for the desired browsers, which can include IOS, ANDROID.
-H "X-netmera-api-key: your_rest_api_key" \
​
-H "Content-Type: application/json" \
​
-d '{
​
"message" : {
​
"title" : "rest api button set",
​
"platforms" : ["ANDROID"],
​
"text" : "push text!!",
​
"buttonSet":{"id":$BUTTON_SET_ID,"$BUTTON_NAME":"$ACTION_URL" ,"$BUTTON_NAME":"$ACTION_URL" }
​
},
​
"target" : {
​
"sendToAll" : true
​
}
​
}' \
​
https://restapi.netmera.com/rest/3.0/sendBulkNotification
Transactional notifications are previously configured messages(from panel) which can be sent to specific user.
Maximum 1000 Unique External IDs or Device Tokens in a Single REST API Request:
When making a request, you can include up to 1000 unique external IDs or Device Tokens for processing. This limitation is in place to ensure the efficiency and proper handling of requests. If you need to include more than 1000 different external IDs or Device Tokens, you would need to split them across multiple requests. This helps maintain the performance and reliability of the API.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"notificationKey": "106",
"message": {
"params": {
"name": "John"
}
},
"target": {
"extId": "id_in_your_system"
}
}' \
https://restapi.netmera.com/rest/3.0/sendNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"notificationKey": "106",
"message": {
"params": {
"name": "John"
}
},
"target": {
"deviceToken": "APAaxpo02......12pxa"
}
}' \
https://restapi.netmera.com/rest/3.0/sendNotification
Parameters notificationKey (Required) : This is the key of notification which you want send to a user. Notification key is created and can be grabbed from panel. target (Required) : Target user to send notification. For transactional notifications, it can be extId which is an id in your system previously associated to a specific user. message.params (Optional) : Custom parameters of a notification for a specific. Transactional message texts can be changed for each user. If you want to send a message as Hello John, Hello Mary etc., you configure your message as Hello @{name} and add name parameter to your transactional notification request.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '[
{
"notificationKey": "106",
"message": {
"params": {
"name": "John"
}
},
"target" : {
"extId": "id_in_your_system_1"
}
},
{
"notificationKey": "107",
"message": {
"params": {
"price": 25
}
},
"target": {
"extId": "id_in_your_system_2"
}
}
]' \
https://restapi.netmera.com/rest/3.0/sendNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '[
{
"notificationKey": "106",
"message": {
"params": {
"name": "John"
}
},
"target" : {
"deviceToken": "APAaxpo02......12pxa"
}
},
{
"notificationKey": "107",
"message": {
"params": {
"price": 25
}
},
"target": {
"deviceToken": "APAaxpo02......21kde"
}
}
]' \
https://restapi.netmera.com/rest/3.0/sendNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"notificationKey": "106",
"message" : {
"params": {
"name": "John"
}
},
"target" : {
"extId": ["id_in_your_system_1", "id_in_your_system_2"]
}
}' \
https://restapi.netmera.com/rest/3.0/sendNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"notificationKey": "106",
"message" : {
"params": {
"name": "John"
}
},
"target" : {
"deviceToken": ["APAaxpo02......21kde", "APAaxpo02......32coa"]
}
}' \
https://restapi.netmera.com/rest/3.0/sendNotification
While you can create transactional notification definition from Netmera Panel, you can also create a new definition with the following request.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"title": "campaign name in panel",
"message": "message here ",
"personalizedMessage": "personalized message here : @{message} ",
"inbox": false,
"platforms": [
"IOS",
"ANDROID"
],
"click": {
"deeplink": "https://www.google.com"
},
"ios": {
"mediaUrl": "media url here",
"title": "title here for push notification",
"subtitle": "subtitle here",
"sound": "ios_sound",
"thumbnailUrl" : "<thumbnail-url>"
},
"android": {
"mediaUrl": "media url here",
"title": "title here for push notification",
"subtitle": "subtitle here",
"sound": "android_sound",
"vibration": true,
"bigText" : "bigText",
"thumbnailUrl" : "<thumbnail-url>"
},
"hook" : {
"name": "hook_name",
"params": {
"key1" : "val1",
"key2" : "val2"
}
}
}' \
https://restapi.netmera.com/rest/3.0/createNotificationDefinition
Parameters title parameter inside message block, gives the campaign name in the panel title parameter inside ios and android block, returns the title of the push notification
Parameters title (Required) : Name of the campaign. message (Required) : Default push notification message. If personalized message is not used, this message will be sent to users. inbox (Optional) : Boolean value which determines to show push in inbox or not. platforms (Required) : Platforms which are able to receive this notification. personalizedMessage (Optional) : If user specific message will be sent, use @{xxxx} placeholder. Placeholders can be profile attributes or sent by transactional message call. click (Optional) : Default push click action. Can be overridden by transactional message call. ios (Optional) : Optional iOS specific parameters. android (Optional) : Optional Android specific parameters. hook (Optional) : Optional hook parameters. If you don't want to attach any hook, don't include hook block.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"title": "title here",
"message": "message here ",
"personalizedMessage": "personalized message here : @{message} ",
"inbox": false,
"labels" : "Apple",
"platforms": [
"IOS",
"ANDROID"
],
"click": {
"deeplink": "https://www.google.com"
},
"ios": {
"mediaUrl": "media url here",
"title": "title here",
"subtitle": "subtitle here",
"sound": "ios_sound",
"thumbnailUrl" : "<thumbnail-url>"
},
"android": {
"mediaUrl": "media url here",
"title": "title here",
"subtitle": "subtitle here",
"sound": "android_sound",
"vibration": true,
"bigText" : "bigText",
"thumbnailUrl" : "<thumbnail-url>"
},
"hook" : {
"name": "hook_name",
"params": {
"key1" : "val1",
"key2" : "val2"
}
}
}' \
https://restapi.netmera.com/rest/3.0/createNotificationDefinition
Parameters Given: I create a push for users of the Create new notification service. I add label information to When: message. Then: I send the push. And: I see that the label field appears in the push report created on the panel.
{
"notificationKey": 96
}
notificationKey : This will identify your message definition. Use this notification key in your transactional message call.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json"
-d '{
"platforms": [
"ANDROID",
"IOS"
],
"text": "Slider Test ",
"message": "Slider Test",
"title": "Slider Test",
"click": {
"deeplink": "https://www.google.com"
},
"ios": {
"title": "Ios tests ",
"slider": [
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png",
"clickAction": {
"url": "htps://www.google.com"
}
},
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png"
}
]
},
"android": {
"title": "Android Test 1 ",
"slider": [
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png",
"clickAction": {
"url": "htps://www.google.com"
}
},
{
"itemImageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png"
}
]
}
}'
https://restapi.netmera.com/rest/3.0/createNotificationDefinition
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H
"Content-Type: application/json"
-d {
"message": {
"platforms": [
"ANDROID",
"IOS"
],
"text": "message text here ",
"message": "Message Here",
"title": "Title Here",
"click": {
"deeplink": "https://www.google.com"
},
"ios": {
"title": "Message title here",
"slider": [
{
"itemImageUrl": " item image url here ",
"clickAction": {
"url": " item click url here "
}
},
{
"itemImageUrl": " item image url here "
}
]
},
"android": {
"title": "Message title here ",
"slider": [
{
"itemImageUrl": " item image url here ",
"clickAction": {
"url": " item click url here "
}
},
{
"itemImageUrl": " item image url here "
}
]
}
}
}
https://restapi.netmera.com/rest/3.0/createNotificationDefinition
With the following request, you can reach the stats of a notification.
curl -X GET \
-H "X-netmera-api-key: your_rest_api_key" \
-G \
--data-urlencode notificationKey=234 \
'https://restapi.netmera.com/rest/3.0/getPushStats'
Parameters notificationKey (Required) : Notification key of a message to get stats.
{
"notificationKey": 234,
"status": "FINISHED",
"startDate": 1504790916883,
"endDate": 1504790916917,
"stats": [
{
"platform": "IOS",
"sent": 100,
"failed": 5,
"clicked": 35
},
{
"platform": "ANDROID",
"sent": 300,
"failed": 25,
"clicked": 98
},
{
"platform": "WP",
"sent": 30,
"failed": 1,
"clicked": 23
}
]
}
With the following request, you can reach the stats of a notification.
curl -X GET \
-H "X-netmera-api-key: your_rest_api_key" \
-G \
--data-urlencode start=1501132423424 \
--data-urlencode end=150122342432 \
​
'https://restapi.netmera.com/rest/3.0/getPushStats'
Parameters start (Required) : Start date in milliseconds. end (Required) : End date in milliseconds.
{
"messages": [
{
"status": "FINISHED",
"stats": [
{
"platform": "IOS",
"sent": 6,
"failed": 0,
"clicked": 0
},
{
"platform": "ANDROID",
"sent": 0,
"failed": 0,
"clicked": 0
}
],
"startDate": 1504790916883,
"endDate": 1504790916917,
"notificationKey": 749
},
{
"status": "SENDING",
"stats": [
{
"platform": "IOS",
"sent": 1,
"failed": 0,
"clicked": 1
},
{
"platform": "ANDROID",
"sent": 0,
"failed": 0,
"clicked": 0
}
],
"startDate": 1504790402907,
"endDate": 1504790402909,
"notificationKey": 748
}
]
}
With the following request, you can get users' push result(ie. success, failed)
If start and end date not specified, last 2 week will be return
Paremeters start (Optional) : Start date in milliseconds. end (Optional) : End date in milliseconds. notificationKey (Optional) : Notification ID on panel extId (Optional) : External ID for getting message results of specific user token (Optional) : Device token for getting message results of specific device
curl -X GET \
-H "X-netmera-api-key: your_rest_api_key" \
-G \
--data-urlencode max=10 \
--data-urlencode notificationKey=106 \
--data-urlencode extId=B4A92950-B0FD-43E6-B312-C3EE088890BD \
--data-urlencode start=1557892331000 \
--data-urlencode end=1557892431000 \
--data-urlencode token=cKuWDH0ZOw4:APA91bEduwC4_FWB5i-isvsSbNO5Dglxg7Wstd8dOI8k8MgP-M2IryebG0PRctVzJ5vkkhDLh3QDEorv6-CfYvvO-rmCMjoUOI_unL3kvQOfi9op_JBzBzwNXGGzwfMLpVSAdYi6xNwn \
'https://restapi.netmera.com/rest/3.0/getPushResult'
{
"nextPage": "https://restapi.netmera.com/rest/3.0/getPushResult?offset=hJbolUuHucJ9dd&max=10",
"list": [
...
{
"platform": "IOS",
"status": "FAILED",
"errorCode": "8",
"installationId": "C2Ii2ztdEaok0",
"errorMsg": "INVALID_TOKEN",
"timeStamp": 1557819194426,
"msgTitle": "Awesome Title",
"msgText": "How is going Jon ?"
},
{
"platform": "ANDROID",
"status": "SUCCESS",
"installationId": "U7IwgcM8phSmv",
"extId": "B4A92950-B0FD-43E6-B312-C3EE088890BD",
"timeStamp" : 1557819194426,
"msgTitle" : "Awesome Title",
"msgText" : "How is going Jon ?"
}
....
]
}
Parameters notificationKey (Required) : Notification key of a message to get users' response. max (Optional) : Default value is 10. Maximum number of result info to fetch per page. {.is-info} You need to send request to nextPage value to fetch next page as:
curl -X GET \
-H "X-netmera-api-key: your_rest_api_key" \
'https://restapi.netmera.com/rest/3.0/getPushResult?offset=hJbolUuHucJ9dd&max=10'
You can send notification to specific group of people(tag, segment, location or by some profile attribute)
Note that you cannot leave target empty. If you want to send notification to all users, you need to set sendToAll attribute as true.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"message" : {
"title" : "Push title",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text!!"
},
"target" : {
"tag" : "Sport"
}
}' \
https://restapi.netmera.com/rest/3.0/sendBulkNotification
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"message" : {
"title" : "Push title",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text!!"
},
"target" : {
"tag" : ["Sport", "Casual"]
}
}' \
https://restapi.netmera.com/rest/3.0/sendBulkNotification
Users with any of the given tags will receive notification.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"message" : {
"title" : "Push title",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text!!"
},
"target" : {
"tag" : {"$or" : ["Sport", "Casual"]}
}
}' \
https://restapi.netmera.com/rest/3.0/sendBulkNotification
If you use $and instead of $or, users with all of the given tags will receive notification.
curl -X POST \
-H "X-netmera-api-key: your_rest_api_key" \
-H "Content-Type: application/json" \
-d '{
"message" : {
"title" : "Push title",
"platforms" : ["IOS", "ANDROID"],
"text" : "push text!!"
},
"target" : {
"tag" : {"$and"