{"_id":"56ea8f3e0252fb17008804ac","category":{"_id":"56e5362775eb791700a9c4d2","__v":6,"project":"56cecbdb44c5700b0095c03a","pages":["56e590ae69d7890e000ec286","56e590fa3c29b117008dae50","56e6f058d66be417007d2364","56e7eaa8f0fafd36008faf59","56ea8db9ed3ad20e004e5a02","56ea8f3e0252fb17008804ac"],"version":"56cecbdc44c5700b0095c03d","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-03-13T09:43:03.596Z","from_sync":false,"order":7,"slug":"remote-api","title":"Server API"},"user":"56cecbb2e50c9c1b008303eb","editedParams2":true,"parentDoc":null,"project":"56cecbdb44c5700b0095c03a","__v":9,"version":{"_id":"56cecbdc44c5700b0095c03d","project":"56cecbdb44c5700b0095c03a","__v":10,"createdAt":"2016-02-25T09:39:40.121Z","releaseDate":"2016-02-25T09:39:40.121Z","categories":["56cecbdc44c5700b0095c03e","56d1d2c05ad7ad0b00b7e809","56d1d2fa5ad7ad0b00b7e80a","56d369331660770b00081159","56d3693d1660770b0008115a","56e5361e7990160e002e3fbc","56e5362775eb791700a9c4d2","57a9030947f2f419009188d4","57b4705ee9e4c60e00f6f4c3","5828f5b04774ab0f005179a2"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"editedParams":true,"githubsync":"","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-03-17T11:04:30.478Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"code":"{\n   \"platforms\" : [\"android\" , \"ios\", \"web\" , \"fb_messenger\"],\n   \"campaign_id\": \"SNzWoen2\",\n   \"text\": \"hello world\",\n   \"url\": \"https://www.pushapps.mobi\",\n   \"image_url\": \"https://www.pushapps.mobi/assets/img/modules/features3.png\",\n   \"custom_json_key\": \"d\",\n   \"custom_json_value\": {\n       \"key\": \"value\"\n   },\n   \"android_settings\": {\n       \"title\": \"some title\",\n       \"sound\": \"filename\"\n   },\n   \"ios_settings\": {\n       \"sound\": \"default\",\n       \"badge\": 1\n   },\n  \"facebook_messenger_settings\": {\n        \"view_button\": \"View\"\n    },\n    \"web_push_settings\": {\n        \"actions\": [\n            {\n                \"action\": \"like\",\n                \"title\": \"Like\",\n                \"icon\": \"https: //example.com/like.png\",\n                \"url\" : \"https://example.com/like.html\"\n            },\n            {\n                \"action\": \"reply\",\n                \"title\": \"Reply\",\n                \"icon\": \"https: //example.com/reply.png\",\n                \"url\" : \"https://example.com/reply.html\"\n            }\n        ]\n    }\n}","language":"json","name":"Simple Notification"},{"language":"json","name":"Specific JSON Payloads","code":"{\n   \"platforms\": [\"android\", \"ios\"],\n   \"text\": \"hello world\",\n   \"android_json\": {\n       \"message\": \"hello world\",\n       \"title\" : \"some title\"\n   },\n   \"ios_json\": {\n       \"aps\": {\n           \"sound\": \"default\",\n           \"badge\": 1,\n           \"alert\": \"hello world\",\n           \"content-available\": 0\n       }\n   }\n}"},{"code":"{\n   \"platforms\": [\"android\", \"ios\"],\n   \"android_settings\": {\n       \"title\": \"Your App Name\"\n   },\n   \"ios_settings\": {\n       \"sound\": \"default\",\n       \"badge\": 1\n   },\n   \"poll\": {\n       \"layout_id\": \"poll_images\",\n       \"text\": \"Who will win El clasico?\",\n       \"image_url\": \"http://www.footballwood.com/wp-content/uploads/2013/10/El-Clasico-history1.jpg\",\n       \"answers\": [\n           {\n               \"image_url\": \"https://upload.wikimedia.org/wikipedia/en/thumb/4/47/FC_Barcelona_%28crest%29.svg/142px-FC_Barcelona_%28crest%29.svg.png\",\n               \"text\": \"Barcelona\"\n           },\n           {\n               \"image_url\": \"https://upload.wikimedia.org/wikipedia/en/thumb/5/56/Real_Madrid_CF.svg/732px-Real_Madrid_CF.svg.png\",\n               \"text\": \"Real Madrid\"\n           }\n       ]\n   }\n}","language":"json","name":"Poll Notification"},{"code":"{\n   \"android_device_ids\": [\"639e21fd64c0cde7\", \"639e21fd64c0cde8\"],\n   \"ios_device_ids\": [\"8E84C3A7-0D7A-4A94-88DF-F444784E0FDB\", \"8E84C3A7-0D7A-4A94-88DF-F444784E0FDC\"],\n   \"campaign_id\": \"SNzWoen2\",\n   \"text\": \"hello world\",\n   \"url\": \"https://www.pushapps.mobi\",\n   \"image_url\": \"https://www.pushapps.mobi/assets/img/modules/features3.png\",\n   \"custom_json_key\": \"d\",\n   \"custom_json_value\": {\n       \"key\": \"value\"\n   },\n   \"android_settings\": {\n       \"title\": \"some title\",\n       \"sound\": \"filename\"\n   },\n   \"ios_settings\": {\n       \"sound\": \"default\",\n       \"badge\": 1\n   }\n}","name":"Specific Devices","language":"json"}]},"method":"post","results":{"codes":[{"language":"json","code":"{\n  \"id\" : \"djsnKhsnO\"\n}","name":"","status":200}]},"settings":"","auth":"required","params":[{"_id":"56ead0fd44ed5e0e00ae0456","ref":"","in":"body","required":false,"desc":"the main text of the notification. **Required** if the notification is not a poll notification","default":"","type":"string","name":"text"},{"_id":"56ead063d25d831700006aac","ref":"","in":"body","required":true,"desc":"the audience of the notification. need to contain at least of the following values :   `android`, `ios`, `web`, `fb-messenger`, `whatsapp`","default":"","type":"array_string","name":"platforms"},{"_id":"57b2e64cc9a4551700b9689d","ref":"","in":"body","required":false,"desc":"specific android device ids that will be the audience of this notification. no more than 1,000 devices per request. If used, ```platforms``` will be ignored. the id if the device can be taken form the PushApps SDK","default":"","type":"array_string","name":"android_device_ids"},{"_id":"57b2e64cc9a4551700b9689c","ref":"","in":"body","required":false,"desc":"specific ios device ids that will be the audience of this notification. no more than 1,000 devices per request. If used, ```platforms``` will be ignored. the id if the device can be taken form the PushApps SDK","default":"","type":"array_string","name":"ios_device_ids"},{"_id":"57730df08b417c2b003712b3","ref":"","in":"body","required":false,"desc":"only devices that have those tags set to ```true``` will receive this notification. currently we support 1 tag in the array","default":"","type":"array_string","name":"tags"},{"_id":"5763e9ab11b88b0e009c0e67","ref":"","in":"body","required":false,"desc":"the url for deep linking","default":"","type":"string","name":"url"},{"_id":"5763e9ab11b88b0e009c0e66","ref":"","in":"body","required":false,"desc":"the url of the image to be shown in the notification layout","default":"","type":"string","name":"image_url"},{"_id":"56ead0fd44ed5e0e00ae0455","ref":"","in":"body","required":false,"desc":"id of the PushApps campaign you wish to attach for the notification","default":"","type":"string","name":"campaign_id"},{"_id":"56ead0fd44ed5e0e00ae0454","ref":"","in":"body","required":false,"desc":"the key of the extra JSON object","default":"","type":"string","name":"custom_json_key"},{"_id":"56ead0fd44ed5e0e00ae0453","ref":"","in":"body","required":false,"desc":"the JSON value of the extra JSON object","default":"","type":"object","name":"custom_json_value"},{"_id":"56ead0fd44ed5e0e00ae0452","ref":"","in":"body","required":false,"desc":"JSON object to be used as the notification's payload ( will be sent as the `data` key ). if used. it will override any other settings of the notification","default":"","type":"object","name":"android_json"},{"_id":"56ead0fd44ed5e0e00ae0451","ref":"","in":"body","required":false,"desc":"JSON object to be used as the notification's payload if used. it will override any other settings of the notification. must contain `aps` key with `alert` , `badge` and `sound`","default":"","type":"object","name":"ios_json"},{"_id":"56ead0fd44ed5e0e00ae0450","ref":"","in":"body","required":false,"desc":"an object of type [AndroidSettings](doc:objects#section-androidsettings)","default":"","type":"object","name":"android_settings"},{"_id":"56ead0fd44ed5e0e00ae044f","ref":"","in":"body","required":false,"desc":"an object of type [IOSSettings](doc:objects#section-iossettings)","default":"","type":"object","name":"ios_settings"},{"_id":"580f5c1f3898430f00c9af6f","ref":"","in":"body","required":false,"desc":"an object of type [WebPushSettings](doc:objects#section-webpushsettings)","default":"","type":"object","name":"web_push_settings"},{"_id":"580f5c1f3898430f00c9af6e","ref":"","in":"body","required":false,"desc":"an object of type [FacebookMessengerSettings](doc:objects#section-facebookmessengersettings)","default":"","type":"object","name":"facebook_messenger_settings"},{"_id":"56ead0fd44ed5e0e00ae044e","ref":"","in":"body","required":false,"desc":"an object of type [Poll](doc:objects#section-poll) . if used all other settings but topics will be ignored, and this will be a poll notification","default":"","type":"object","name":"poll"}],"url":"/v1/notifications"},"isReference":false,"order":3,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Code Examples:\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?PHP\\n$params = array(\\n'text' => 'hello world',\\n'url' => 'https://www.pushapps.mobi',\\n'image_url' => 'https://www.pushapps.mobi/assets/img/modules/features2.png',\\n'platforms' => array('android', 'ios'),\\n'ios_settings' => array('sound' => 'default', 'badge' => 1),\\n'android_settings' => array('sound' => 'default', 'title' => 'My Cool App Name'),\\n'web_push_settings' => array('actions' =>\\narray('title' => 'Like' , 'url' => 'https://example.com/like.html' , 'icon' => 'https: //example.com/like.png', 'action' => 'like'),\\narray('title' => 'Reply' , 'url' => 'https://example.com/reply.html' , 'icon' => 'https: //example.com/reply.png', 'action' => 'reply')),\\n'fb_messenger_settings' => array('view_button' => 'View')\\n);\\n\\n$params = json_encode($params);\\nprint(\\\"\\\\nJSON payload:\\\\n\\\\n\\\");\\nprint($params);\\n\\n$ch = curl_init();\\ncurl_setopt($ch, CURLOPT_URL, \\\"https://api.pushapps.mobi/v1/notifications\\\");\\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));\\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Api-Key: <Your API Key>'));\\ncurl_setopt($ch, CURLOPT_HEADER, FALSE);\\ncurl_setopt($ch, CURLOPT_POST, TRUE);\\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $params);\\n\\n\\n$response = curl_exec($ch);\\ncurl_close($ch);\\n\\n#$return[\\\"allresponses\\\"] = $response;\\n$response = json_encode( $response);\\n\\nprint(\\\"\\\\nresponse:\\\\n\\\");\\nprint($response);\\nprint(\\\"\\\\n\\\");\\n\\n?>\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"notifications-create-notification","type":"endpoint","title":"/notifications - create notification"}

post/notifications - create notification


Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

text:
string
the main text of the notification. **Required** if the notification is not a poll notification
platforms:
required
array of strings
the audience of the notification. need to contain at least of the following values : `android`, `ios`, `web`, `fb-messenger`, `whatsapp`
android_device_ids:
array of strings
specific android device ids that will be the audience of this notification. no more than 1,000 devices per request. If used, ```platforms``` will be ignored. the id if the device can be taken form the PushApps SDK
ios_device_ids:
array of strings
specific ios device ids that will be the audience of this notification. no more than 1,000 devices per request. If used, ```platforms``` will be ignored. the id if the device can be taken form the PushApps SDK
tags:
array of strings
only devices that have those tags set to ```true``` will receive this notification. currently we support 1 tag in the array
url:
string
the url for deep linking
image_url:
string
the url of the image to be shown in the notification layout
campaign_id:
string
id of the PushApps campaign you wish to attach for the notification
custom_json_key:
string
the key of the extra JSON object
custom_json_value:
object
the JSON value of the extra JSON object
android_json:
object
JSON object to be used as the notification's payload ( will be sent as the `data` key ). if used. it will override any other settings of the notification
ios_json:
object
JSON object to be used as the notification's payload if used. it will override any other settings of the notification. must contain `aps` key with `alert` , `badge` and `sound`
android_settings:
object
an object of type [AndroidSettings](doc:objects#section-androidsettings)
ios_settings:
object
an object of type [IOSSettings](doc:objects#section-iossettings)
web_push_settings:
object
an object of type [WebPushSettings](doc:objects#section-webpushsettings)
facebook_messenger_settings:
object
an object of type [FacebookMessengerSettings](doc:objects#section-facebookmessengersettings)
poll:
object
an object of type [Poll](doc:objects#section-poll) . if used all other settings but topics will be ignored, and this will be a poll notification

Examples


Result Format


Documentation

[block:api-header] { "type": "basic", "title": "Code Examples:" } [/block] [block:code] { "codes": [ { "code": "<?PHP\n$params = array(\n'text' => 'hello world',\n'url' => 'https://www.pushapps.mobi',\n'image_url' => 'https://www.pushapps.mobi/assets/img/modules/features2.png',\n'platforms' => array('android', 'ios'),\n'ios_settings' => array('sound' => 'default', 'badge' => 1),\n'android_settings' => array('sound' => 'default', 'title' => 'My Cool App Name'),\n'web_push_settings' => array('actions' =>\narray('title' => 'Like' , 'url' => 'https://example.com/like.html' , 'icon' => 'https: //example.com/like.png', 'action' => 'like'),\narray('title' => 'Reply' , 'url' => 'https://example.com/reply.html' , 'icon' => 'https: //example.com/reply.png', 'action' => 'reply')),\n'fb_messenger_settings' => array('view_button' => 'View')\n);\n\n$params = json_encode($params);\nprint(\"\\nJSON payload:\\n\\n\");\nprint($params);\n\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, \"https://api.pushapps.mobi/v1/notifications\");\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Api-Key: <Your API Key>'));\ncurl_setopt($ch, CURLOPT_HEADER, FALSE);\ncurl_setopt($ch, CURLOPT_POST, TRUE);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $params);\n\n\n$response = curl_exec($ch);\ncurl_close($ch);\n\n#$return[\"allresponses\"] = $response;\n$response = json_encode( $response);\n\nprint(\"\\nresponse:\\n\");\nprint($response);\nprint(\"\\n\");\n\n?>", "language": "php" } ] } [/block]