{"__v":22,"_id":"551ef4f04986f62b00a72069","category":{"__v":4,"_id":"551ef4ef4986f62b00a72038","pages":["551ef4f04986f62b00a7205d","551ef4f04986f62b00a7205e","551ef4f04986f62b00a7205f","551ef4f04986f62b00a72060","551ef4f04986f62b00a72061","551ef4f04986f62b00a72062","551ef4f04986f62b00a72063","551ef4f04986f62b00a72064","551ef4f04986f62b00a72065","551ef4f04986f62b00a72066","551ef4f04986f62b00a72067","551ef4f04986f62b00a72068","551ef4f04986f62b00a72069","551ef4f04986f62b00a7206a","551ef4f04986f62b00a7206b","551ef4f04986f62b00a7206c","5523150ae20da719000e78c2","5641731cb0dc090d00f88398","56c2761847394f0d00e2285e"],"project":"542b6018044e1e2200413772","version":"551ef4ef4986f62b00a7202e","reference":false,"createdAt":"2014-10-22T01:34:57.891Z","from_sync":false,"order":16,"slug":"server-rest-api","title":"Server REST API"},"parentDoc":null,"project":"542b6018044e1e2200413772","user":"542b6010044e1e220041376f","version":{"__v":7,"_id":"551ef4ef4986f62b00a7202e","forked_from":"542b6018044e1e2200413775","project":"542b6018044e1e2200413772","createdAt":"2015-04-03T20:15:43.149Z","releaseDate":"2015-04-03T20:15:43.149Z","categories":["551ef4ef4986f62b00a7202f","551ef4ef4986f62b00a72030","551ef4ef4986f62b00a72031","551ef4ef4986f62b00a72032","551ef4ef4986f62b00a72033","551ef4ef4986f62b00a72034","551ef4ef4986f62b00a72035","551ef4ef4986f62b00a72036","551ef4ef4986f62b00a72037","551ef4ef4986f62b00a72038","551ef4ef4986f62b00a72039","551ef4ef4986f62b00a7203a","551ef4ef4986f62b00a7203b","551ef4ef4986f62b00a7203c","551ef4ef4986f62b00a7203d","551ef4ef4986f62b00a7203e","55d7f1879510f00d007ec727","56b94a5a9fc0de1700b60ae9","56bd0e48ac1c5c1900b2dbe4","56d74afc3eb4dd0b0020196a","5723ab8a1f41110e003081ed","576b4dd327d6252b00085422"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2.0"},"updates":["559a7bd61b009a0d00a0056b"],"createdAt":"2014-10-28T18:51:25.074Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"name":"","code":"{\n \"app_id\": \"5eb5a37e-b458-11e3-ac11-000c2940e62c\",\n \"included_segments\": [\"All\"],\n \"data\": {\"foo\": \"bar\"},\n \"contents\": {\"en\": \"English Message\"}\n}","language":"json"},{"language":"shell","code":"curl --include \\\n --request POST \\\n --header \"Content-Type: application/json\" \\\n --header \"Authorization: Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\" \\\n --data-binary \"{\\\"app_id\\\": \\\"5eb5a37e-b458-11e3-ac11-000c2940e62c\\\",\n\\\"contents\\\": {\\\"en\\\": \\\"English Message\\\"},\n\\\"included_segments\\\": [\\\"All\\\"]}\" \\\n https://onesignal.com/api/v1/notifications"},{"language":"php","code":"<?PHP\n\tfunction sendMessage(){\n\t\t$content = array(\n\t\t\t\"en\" => 'English Message'\n\t\t\t);\n\t\t\n\t\t$fields = array(\n\t\t\t'app_id' => \"5eb5a37e-b458-11e3-ac11-000c2940e62c\",\n\t\t\t'included_segments' => array('All'),\n 'data' => array(\"foo\" => \"bar\"),\n\t\t\t'contents' => $content\n\t\t);\n\t\t\n\t\t$fields = json_encode($fields);\n print(\"\\nJSON sent:\\n\");\n print($fields);\n\t\t\n\t\t$ch = curl_init();\n\t\tcurl_setopt($ch, CURLOPT_URL, \"https://onesignal.com/api/v1/notifications\");\n\t\tcurl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',\n\t\t\t\t\t\t\t\t\t\t\t\t 'Authorization: Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj'));\n\t\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);\n\t\tcurl_setopt($ch, CURLOPT_HEADER, FALSE);\n\t\tcurl_setopt($ch, CURLOPT_POST, TRUE);\n\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS, $fields);\n\t\tcurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);\n\n\t\t$response = curl_exec($ch);\n\t\tcurl_close($ch);\n\t\t\n\t\treturn $response;\n\t}\n\t\n\t$response = sendMessage();\n\t$return[\"allresponses\"] = $response;\n\t$return = json_encode( $return);\n\t\n print(\"\\n\\nJSON received:\\n\");\n\tprint($return);\n print(\"\\n\");\n?>"},{"name":"C#(.NET standard)","language":"csharp","code":"using System.IO;\nusing System.Net;\nusing System.Text;\n\nvar request = WebRequest.Create(\"https://onesignal.com/api/v1/notifications\") as HttpWebRequest;\n\nrequest.KeepAlive = true;\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\n\nrequest.Headers.Add(\"authorization\", \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\");\n\nbyte[] byteArray = Encoding.UTF8.GetBytes(\"{\"\n + \"\\\"app_id\\\": \\\"5eb5a37e-b458-11e3-ac11-000c2940e62c\\\",\"\n + \"\\\"contents\\\": {\\\"en\\\": \\\"English Message\\\"},\"\n + \"\\\"included_segments\\\": [\\\"All\\\"]}\");\n\nstring responseContent = null;\n\ntry {\n using (var writer = request.GetRequestStream()) {\n writer.Write(byteArray, 0, byteArray.Length);\n }\n\n using (var response = request.GetResponse() as HttpWebResponse) {\n using (var reader = new StreamReader(response.GetResponseStream())) {\n responseContent = reader.ReadToEnd();\n }\n }\n}\ncatch (WebException ex) {\n System.Diagnostics.Debug.WriteLine(ex.Message);\n System.Diagnostics.Debug.WriteLine(new StreamReader(ex.Response.GetResponseStream()).ReadToEnd());\n}\n\nSystem.Diagnostics.Debug.WriteLine(responseContent);"},{"name":"Ruby (Rails)","language":"ruby","code":"params = {\"app_id\" => \"5eb5a37e-b458-11e3-ac11-000c2940e62c\", \n \"contents\" => {\"en\" => \"English Message\"},\n \"included_segments\" => [\"All\"]}\nuri = URI.parse('https://onesignal.com/api/v1/notifications')\nhttp = Net::HTTP.new(uri.host, uri.port)\nhttp.use_ssl = true\n\nrequest = Net::HTTP::Post.new(uri.path,\n 'Content-Type' => 'application/json',\n 'Authorization' => \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\")\nrequest.body = params.as_json.to_json\nresponse = http.request(request) \nputs response.body"},{"language":"python","code":"import requests\nimport json\n\nheader = {\"Content-Type\": \"application/json\",\n \"Authorization\": \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\"}\n\npayload = {\"app_id\": \"5eb5a37e-b458-11e3-ac11-000c2940e62c\",\n \"included_segments\": [\"All\"],\n \"contents\": {\"en\": \"English Message\"}}\n \nreq = requests.post(\"https://onesignal.com/api/v1/notifications\", headers=header, data=json.dumps(payload))\n \nprint(req.status_code, req.reason)"},{"name":"NodeJS","language":"javascript","code":"var sendNotification = function(data) {\n var headers = {\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\"\n };\n \n var options = {\n host: \"onesignal.com\",\n port: 443,\n path: \"/api/v1/notifications\",\n method: \"POST\",\n headers: headers\n };\n \n var https = require('https');\n var req = https.request(options, function(res) { \n res.on('data', function(data) {\n console.log(\"Response:\");\n console.log(JSON.parse(data));\n });\n });\n \n req.on('error', function(e) {\n console.log(\"ERROR:\");\n console.log(e);\n });\n \n req.write(JSON.stringify(data));\n req.end();\n};\n\nvar message = { \n app_id: \"5eb5a37e-b458-11e3-ac11-000c2940e62c\",\n contents: {\"en\": \"English Message\"},\n included_segments: [\"All\"]\n};\n\nsendNotification(message);"},{"name":"Perl","language":"ruby","code":"#!/usr/bin/perl -w\n \nuse strict;\nuse warnings;\nuse Net::Curl::Easy qw(/^CURLOPT_.*/);;\nuse JSON;\nuse Data::Dumper;\n \nsub SendNotification\n{\n my ($url , $authorisation , $app_id , $contents) = :::at:::_;\n my $curl = Net::Curl::Easy->new;\n my $json = JSON->new();\n my $response_body;\n \n my $json_string = $json->encode({ app_id => $app_id ,\n included_segments => [\"All\"] ,\n data => { \"key1\" => \"Value 1\" } ,\n ios_badgeType => \"Increase\" ,\n ios_badgeCount => 1 ,\n contents => { en => $contents}\n });\n \n $curl->setopt( CURLOPT_URL, $url);\n $curl->setopt( CURLOPT_SSL_VERIFYHOST , 0);\n $curl->setopt( CURLOPT_SSL_VERIFYPEER , 0);\n \n $curl->setopt( CURLOPT_HTTPHEADER, ['Content-Type: application/json' ,\n \"Authorization: Basic $authorisation\"]);\n $curl->setopt( CURLOPT_POST , 1);\n $curl->setopt( CURLOPT_POSTFIELDS , $json_string);\n \n $curl->setopt( CURLOPT_WRITEDATA , \\$response_body);\n \n $curl->perform;\n print Dumper($response_body);\n}\n \nSendNotification(\"https://onesignal.com/api/v1/notifications\" ,\n \"<< PUT YOUR REST API KEY HERE>>\" ,\n \"<< PUT YOUR APP ID KEY HERE >>\" ,\n \"Hello World\");\n \nexit(0);"},{"name":"Parse Cloud","language":"javascript","code":"send = function(params) {\n\nvar promise = new Parse.Promise();\n\nvar jsonBody = { \n app_id: \"5eb5a37e-b458-11e3-ac11-000c2940e62c\", \n included_segments: [\"All\"],\n contents: {en: \"English Message\"},\n data: {foo: \"bar\"}\n};\n\nParse.Cloud.httpRequest({\n method: \"POST\",\n url: \"https://onesignal.com/api/v1/notifications\",\n headers: {\n \"Content-Type\": \"application/json;charset=utf-8\",\n \"Authorization\": \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\"\n },\n body: JSON.stringify(jsonBody)\n }).then(function (httpResponse) {\n promise.resolve(httpResponse)\n },\n function (httpResponse) {\n promise.reject(httpResponse);\n});\n\nreturn promise;\n};\n\nexports.send = send;"},{"code":"function SendNewNotification() {\n\n var jsonBody = {\n\n app_id: \"5eb5a37e-b458-11e3-ac11-000c2940e62c\",\n\n included_segments: [\"All\"],\n\n contents: {en: \"English Message\"},\n\n };\n\n var promise = Spark.getHttp(\"https://onesignal.com/api/v1/notifications\").setHeaders({\n\n \"Content-Type\": \"application/json;charset=utf-8\",\n\n \"Authorization\": \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\"\n\n }).postJson(jsonBody);\n \n\n return promise;\n\n}\n\nvar response = SendNewNotification().getResponseJson();\n\nSpark.setScriptData(\"response\", response)","language":"javascript","name":"GameSparks"},{"code":"try {\n String jsonResponse;\n \n URL url = new URL(\"https://onesignal.com/api/v1/notifications\");\n HttpURLConnection con = (HttpURLConnection)url.openConnection();\n con.setUseCaches(false);\n con.setDoOutput(true);\n con.setDoInput(true);\n\n con.setRequestProperty(\"Content-Type\", \"application/json; charset=UTF-8\");\n con.setRequestProperty(\"Authorization\", \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\");\n con.setRequestMethod(\"POST\");\n\n String strJsonBody = \"{\"\n + \"\\\"app_id\\\": \\\"5eb5a37e-b458-11e3-ac11-000c2940e62c\\\",\"\n + \"\\\"included_segments\\\": [\\\"All\\\"],\"\n + \"\\\"data\\\": {\\\"foo\\\": \\\"bar\\\"},\"\n + \"\\\"contents\\\": {\\\"en\\\": \\\"English Message\\\"}\"\n + \"}\";\n \n \n System.out.println(\"strJsonBody:\\n\" + strJsonBody);\n\n byte[] sendBytes = strJsonBody.getBytes(\"UTF-8\");\n con.setFixedLengthStreamingMode(sendBytes.length);\n\n OutputStream outputStream = con.getOutputStream();\n outputStream.write(sendBytes);\n\n int httpResponse = con.getResponseCode();\n System.out.println(\"httpResponse: \" + httpResponse);\n\n if ( httpResponse >= HttpURLConnection.HTTP_OK\n && httpResponse < HttpURLConnection.HTTP_BAD_REQUEST) {\n Scanner scanner = new Scanner(con.getInputStream(), \"UTF-8\");\n jsonResponse = scanner.useDelimiter(\"\\\\A\").hasNext() ? scanner.next() : \"\";\n scanner.close();\n }\n else {\n Scanner scanner = new Scanner(con.getErrorStream(), \"UTF-8\");\n jsonResponse = scanner.useDelimiter(\"\\\\A\").hasNext() ? scanner.next() : \"\";\n scanner.close();\n }\n System.out.println(\"jsonResponse:\\n\" + jsonResponse);\n \n} catch(Throwable t) {\n t.printStackTrace();\n}","language":"java"},{"code":"using System.IO;\nusing System.Net;\nusing System.Text;\n\nvar request = WebRequest.Create(\"https://onesignal.com/api/v1/notifications\") as HttpWebRequest;\n\nrequest.KeepAlive = true;\nrequest.Method = \"POST\";\nrequest.ContentType = \"application/json\";\n\nrequest.Headers.Add(\"authorization\", \"Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj\");\n\nvar serializer = new JavaScriptSerializer();\nvar obj = new { app_id = \"5eb5a37e-b458-11e3-ac11-000c2940e62c\",\n contents = new { en = \"English Message\" },\n included_segments = new string[] {\"All\"} };\nvar param = serializer.Serialize(obj);\nbyte[] byteArray = Encoding.UTF8.GetBytes(param);\n\nstring responseContent = null;\n\ntry {\n using (var writer = request.GetRequestStream()) {\n writer.Write(byteArray, 0, byteArray.Length);\n }\n\n using (var response = request.GetResponse() as HttpWebResponse) {\n using (var reader = new StreamReader(response.GetResponseStream())) {\n responseContent = reader.ReadToEnd();\n }\n }\n}\ncatch (WebException ex) {\n System.Diagnostics.Debug.WriteLine(ex.Message);\n System.Diagnostics.Debug.WriteLine(new StreamReader(ex.Response.GetResponseStream()).ReadToEnd());\n}\n\nSystem.Diagnostics.Debug.WriteLine(responseContent);","language":"csharp","name":"C#(ASP.NET)"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n \"id\": \"458dcec4-cf53-11e3-add2-000c2940e62c\",\n \"recipients\": 5\n}","name":""},{"status":400,"language":"json","code":"{\n \"errors\": [\"Notification content must not be null for any languages.\"]\n}"},{"name":"invalid_player_ids","language":"json","code":"// Returned if using include_player_ids and some were valid and others were not.\n// Please process theses on your server and removing them from your database if your tracking them.\n\n{\n \"errors\": {\n \"invalid_player_ids\" : [\"5fdc92b2-3b2a-11e5-ac13-8fdccfe4d986\", \"00cb73f8-5815-11e5-ba69-f75522da5528\"]\n }\n}","status":200},{"code":"{'id': \"\", 'recipients': 0, 'errors': [\"All included players are not subscribed\"]}","language":"json","name":"No subscribed players","status":200}]},"settings":"","auth":"optional","params":[{"_id":"5450097c3c6f700800a9b3eb","ref":"","required":true,"desc":"Your OneSignal Application Key","default":"Required","type":"string","name":"app_id"},{"_id":"5450097c3c6f700800a9b3ea","ref":"","required":true,"desc":"Message contents to send to players. \"en\" (English) is required. The key of each hash is either a a 2 character language code or one of zh-Hans/zh-Hant for Simplified or Traditional Chinese. The value of each key is the message that will be sent to users for that language. If do not specify a language English will be used.<br>Example: `{\"en\": \"English Message\",\"es\": \"Spanish Message\"}`","default":"Required unless content_available=true, *_background_data=true, or template_id is set.","type":"object","name":"contents"},{"_id":"546bd25c5281200800041490","ref":"","required":false,"desc":"Notification title to send to Android, Amazon, Chrome apps, and Chrome Websites. By default, this will be the application name. If this option is used, a value for \"en\" (English) is required. The value of each key is the title that will be sent to users for that language. If do not specify a language English will be used.<br>Example: `{\"en\": \"English Title\",\"es\": \"Spanish Title\"}`","default":"Optional","type":"object","name":"headings"},{"_id":"5450097c3c6f700800a9b3e9","ref":"","required":false,"desc":"Send to iOS devices?","default":"Optional.","type":"boolean","name":"isIos"},{"_id":"5450097c3c6f700800a9b3e8","ref":"","required":false,"desc":"Send to Google Play Android devices?","default":"Optional.","type":"boolean","name":"isAndroid"},{"_id":"5450097c3c6f700800a9b3e7","ref":"","required":false,"desc":"Send to Windows Phone 8.0 Devices?","default":"Optional.","type":"boolean","name":"isWP"},{"_id":"5747688c338b84190025f454","ref":"","required":false,"desc":"Send to Windows Phone 8.1 Devices?","default":"Optional","type":"boolean","name":"isWP_WNS"},{"_id":"54b4143df6445c1f00087485","ref":"","required":false,"desc":"Send to Amazon ADM devices?","default":"Optional.","type":"boolean","name":"isAdm"},{"_id":"54c6c329f0320f0d00ac9c75","ref":"","required":false,"desc":"Send to Google Chrome App/Extension?","default":"Optional.","type":"boolean","name":"isChrome"},{"_id":"5563cb3f6d874e0d00584286","ref":"","required":false,"desc":"Send to Chrome Web subscribers?","default":"Optional","type":"boolean","name":"isChromeWeb"},{"_id":"561c42801529740d00a70dcc","ref":"","required":false,"desc":"Send to Safari subscribers?","default":"Optional","type":"boolean","name":"isSafari"},{"_id":"561c42801529740d00a70dcb","ref":"","required":false,"desc":"Send to all web subscribers? Includes ChromeWeb, Safari, Firefox, and any future browsers.","default":"Optional","type":"boolean","name":"isAnyWeb"},{"_id":"5450097c3c6f700800a9b3e6","ref":"","required":false,"desc":"Names of segments to send the message to. Any player in any of these segments will be sent this notification. Only compatible with excluded_segments, do not use any other targeting parameters with this one.<br>Example: `[\"Free Players\", \"New Players\"]`<br>*NOTE: 'REST API Key' Required*","default":"Optional. Targeting parameter.","type":"array_string","name":"included_segments"},{"_id":"5450097c3c6f700800a9b3e5","ref":"","required":false,"desc":"Use with included_segments. Do not use with any other targeting parameters. Names of segments to exclude players from. Any players in any of these segments will not be sent the notification even if they are a member of included_segments. Requires API Auth Key.<br>Example: `[\"Free Players\", \"New Players\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"excluded_segments"},{"_id":"5450097c3c6f700800a9b3e4","ref":"","required":false,"desc":"Specific players to send your notification to. Do not combine with other targeting parameters. Not compatible with any other targeting parameters. Does not require API Auth Key.<br>Example: `[\"1dd608f2-c6a1-11e3-851d-000c2940e62c\"]`<br>*Note: Recommended maximum of 2,000 ids per REST call for the best delivery times.*","default":"Optional. Targeting parameter.","type":"array_string","name":"include_player_ids"},{"_id":"5450097c3c6f700800a9b3e3","ref":"","required":false,"desc":"Recommend using include_player_ids instead. <br>**Warning:** Only works with Production tokens. <br><br>Specific iOS device tokens to send the notification to (all non-alphanumeric characters must be removed from the tokens). Do not combine with other targeting parameters. If any of these tokens do not correspond to players in our system, a player will be automatically created for each of them. Does not require your \"API Auth Key\".<br>Example: `[\"ce777617da7f548fe7a9ab6febb56cf39fba6d38203...\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_ios_tokens"},{"_id":"5450097c3c6f700800a9b3e2","ref":"","required":false,"desc":"Recommend using include_player_ids instead. Specific Android registration ids to send the notification to. Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your \"API Auth Key\".<br>Example: `[\"APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_android_reg_ids"},{"_id":"5450097c3c6f700800a9b3e1","ref":"","required":false,"desc":"Recommend using include_player_ids instead. Specific Windows Phone 8.0 channel URI to send the notification to. Do not combine with other targeting parameters. If these channel URIs do not correspond to players in our system, players will be automatically created. Does not require your \"API Auth Key\".<br>Example: `[\"http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-...\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_wp_uris"},{"_id":"55e674749cc7c62b00c4a1e0","ref":"","required":false,"desc":"Recommend using include_player_ids instead. Specific Windows Phone 8.1 channel URI to send the notification to. Do not combine with other targeting parameters. If these channel URIs do not correspond to players in our system, players will be automatically created. Does not require your \"API Auth Key\".<br>Example: `[\"http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-...\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_wp_wns_uris"},{"_id":"54b41531f6445c1f00087487","ref":"","required":false,"desc":"Recommend using include_player_ids instead. Specific Amazon ADM registration ids to send the notification to. Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your \"API Auth Key\".<br>Example: `[\"amzn1.adm-registration.v1.XpvSSUk0Rc3hTVVV...\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_amazon_reg_ids"},{"_id":"54c6c4e5f0320f0d00ac9c7a","ref":"","required":false,"desc":"Recommend using include_player_ids instead. Specific Chrome App/Extension Google registration ids to send the notification to. Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your \"API Auth Key\".<br>Example: `[\"APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_chrome_reg_ids"},{"_id":"556b8c3730922f1700ad5dd5","ref":"","required":false,"desc":"Recommend using include_player_ids instead. Specific Chrome Web Google registration ids to send the notification to. **Highly recommend using `include_player_ids` instead as these can change from time to time.**<br>Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your \"API Auth Key\".<br>Example: `[\"APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_chrome_web_reg_ids"},{"_id":"554d0443de67270d009b02f6","ref":"","required":false,"desc":"Used to target all users across a list of your apps. If a user has 2 or more of the apps installed they will only receive 1 notification.<br>Example: <code class=\"inline-code\">[\"2dd608f2-a6a1-11e3-251d-400c2940e62b\", \"2dd608f2-a6a1-11e3-251d-500f2950e61c\"]</code><br>NOTE: Requires your \"User Auth Key\" in the HTTP header.","default":"Optional. Targeting parameter.","type":"array_string","name":"app_ids"},{"_id":"5450097c3c6f700800a9b3e0","ref":"","required":false,"desc":"Match users by the values set for their tags. Do not combine with other targeting parameters. Possible relations are \">\", \"<\",, \"=\", and \"!=\". \"<\" means that the value of the user's tag must be less than the value supplied in the \"value\" field of this hash. By default users must match all of the hashes specified in this array to receive the notification.<br>*You may add `{\"operator\": \"OR\"}` between the entries to allow any of the tag conditions.*<br>*A maximum of 200 tags and operators can be used at a time.*<br>*Note: Requires \"REST API Key\".*<br><br>**Example 1**<br>level='10' AND madePurchase='true'<br><code class=\"inline-code\">[{\"key\": \"level\", \"relation\": \">\", \"value\": \"10\"},<br> {\"key\": \"madePurchase\", \"relation\": \"=\",\"value\": \"true\"}]</code><br>**Example 2:**<br>level='10' OR level='20'<br><code class=\"inline-code\">[{\"key\": \"level\", \"relation\": \"=\", \"value\": \"10\"},<br> {\"operator\": \"OR\"},<br> {\"key\": \"level\", \"relation\": \"=\", \"value\": \"20\"}]</code><br>**Example 3:**<br>level='10' OR level='20'<br><code class=\"inline-code\">[{\"key\": \"is_vip\", \"relation\": \"!=\", \"value\": \"true\"},<br> {\"operator\": \"OR\"},<br> {\"key\": \"is_admin\", \"relation\": \"=\", \"value\": \"true\"}]</code>","default":"Optional. Targeting parameter.","type":"array_object","name":"tags"},{"_id":"5450097c3c6f700800a9b3df","ref":"","required":false,"desc":"Options are: `None`, `SetTo`, or `Increase`.<br>None leaves the count unaffected on the device. If you use Increase, it will be based on the current value of the player's badge_count.","default":"Optional","type":"string","name":"ios_badgeType"},{"_id":"5450097c3c6f700800a9b3de","ref":"","required":false,"desc":"Sets or increases the badge icon on the device depending on the ios_badgeType value","default":"Optional","type":"int","name":"ios_badgeCount"},{"_id":"5450097c3c6f700800a9b3dd","ref":"","required":false,"desc":"Sound file that is included in your app to play instead of the default device notification sound. Pass \"nil\" to disable vibration and sound for the notification.<br>Example: `\"notification.wav\"`","default":"Optional","type":"string","name":"ios_sound"},{"_id":"5450097c3c6f700800a9b3dc","ref":"","required":false,"desc":"Sound file that is included in your app to play instead of the default device notification sound.<br>NOTE: Leave off file extension for Android.<br>Example: `\"notification\"`","default":"Optional","type":"string","name":"android_sound"},{"_id":"55e66ff4de6fef23009480ba","ref":"","required":false,"desc":"Amazon devices<br>Sound file that is included in your app to play instead of the default device notification sound.<br>NOTE: Leave off file extension for Android.<br>Example: `\"notification\"`","default":"Optional","type":"string","name":"adm_sound"},{"_id":"5450097c3c6f700800a9b3db","ref":"","required":false,"desc":"Windows Phone 8.0<br>Sound file that is included in your app to play instead of the default device notification sound.<br>Example: `\"notification.wav\"`","default":"Optional","type":"string","name":"wp_sound"},{"_id":"55e66f5d85a9741900314e7d","ref":"","required":false,"desc":"Windows Phone 8.1<br>Sound file that is included in your app to play instead of the default device notification sound.<br>Example: `\"notification.wav\"`","default":"Optional","type":"string","name":"wp_wns_sound"},{"_id":"5450097c3c6f700800a9b3da","ref":"","required":false,"desc":"Custom key value pair hash that you can programmatically read in your app's code.<br>Example: `{\"abc\": \"123\", \"foo\": \"bar\"}`","default":"Optional","type":"object","name":"data"},{"_id":"5450097c3c6f700800a9b3d9","ref":"","required":false,"desc":"Buttons to add to the notification. Supported by iOS 8.0 and Android 4.1+ devices. Icon only works for Android.<br>Example: <code class=\"inline-code\">[{\"id\": \"id1\", \"text\": \"button1\", \"icon\": \"ic_menu_share\"}, {\"id\": \"id2\", \"text\": \"button2\", \"icon\": \"ic_menu_send\"}]</code>","default":"Optional","type":"array_object","name":"buttons"},{"_id":"5772e144ddd4502000f30227","ref":"","required":false,"desc":"Chrome 48+ (web push) only. Add action buttons to the notification. <br>Example: <code class=\"inline-code\">[{\"id\": \"like-button\", \"text\": \"Like\", \"icon\": \"http://i.imgur.com/N8SN8ZS.png\", \"url\": \"https://yoursite.com\"}, {\"id\": \"read-more-button\", \"text\": \"Read more\", \"icon\": \"http://i.imgur.com/MIxJp1L.png\", \"url\": \"https://yoursite.com\"}]</code>","default":"Optional","type":"array_object","name":"web_buttons"},{"_id":"54821d7ec7026c210099d173","ref":"","required":false,"desc":"Specific Android icon to use. If blank the app icon is used. Must be the drawable resource name.","default":"Optional","type":"string","name":"small_icon"},{"_id":"54821d7ec7026c210099d172","ref":"","required":false,"desc":"Specific Android icon to display to the left of the notification. If blank the small_icon is used. Can be a drawable resource name or a URL.","default":"Optional","type":"string","name":"large_icon"},{"_id":"54821dcb2dca603300bf6f59","ref":"","required":false,"desc":"Specific Android picture to display in the expanded view. Can be a drawable resource name or a URL.","default":"Optional","type":"string","name":"big_picture"},{"_id":"54b41d1a4f25cb1600518d33","ref":"","required":false,"desc":"Specific Amazon icon to use. If blank the app icon is used. Must be the drawable resource name.","default":"Optional","type":"string","name":"adm_small_icon"},{"_id":"54b41d1a4f25cb1600518d32","ref":"","required":false,"desc":"Specific Amazon icon to display to the left of the notification. If blank the adm_small_icon is used. Can be a drawable resource name or a URL.","default":"Optional","type":"string","name":"adm_large_icon"},{"_id":"54b41d1a4f25cb1600518d31","ref":"","required":false,"desc":"Specific Amazon picture to display in the expanded view. Can be a drawable resource name or a URL.","default":"Optional","type":"string","name":"adm_big_picture"},{"_id":"54c6c329f0320f0d00ac9c74","ref":"","required":false,"desc":"For Chrome extensions & apps only, NOT for Chrome web push. The local URL to an icon to use. if blank the app icon will be used. For Chrome web push please see \"chrome_web_icon\".","default":"Optional","type":"string","name":"chrome_icon"},{"_id":"54c6c421f2ab9319008e8212","ref":"","required":false,"desc":"Specific Chrome large picture to display below the notification text. Must be a local URL.","default":"Optional","type":"string","name":"chrome_big_picture"},{"_id":"5575127242f283190024a48c","ref":"","required":false,"desc":"Specific Chrome website image URL to be shown to the left of the notification text. Should be 80x80 @ 24bit so it displays on all platforms correctly.","default":"Optional","type":"string","name":"chrome_web_icon"},{"_id":"56b122806d004b170080668c","ref":"","required":false,"desc":"Specific Firefox website image URL to be shown to the right of the notification text.","default":"Optional","type":"string","name":"firefox_icon"},{"_id":"5450097c3c6f700800a9b3d8","ref":"","required":false,"desc":"When the player opens the notification their web browser will open this url.<br>Example: `\"http://google.com\"`","default":"Optional","type":"string","name":"url"},{"_id":"5450097c3c6f700800a9b3d7","ref":"","required":false,"desc":"Schedule notification for future delivery.<br>Examples:<br>*All examples are the exact same date & time.*<br>`\"Thu Sep 24 2015 14:00:00 GMT-0700 (PDT)\"`<br>`\"September 24th 2015, 2:00:00 pm UTC-07:00\"`<br>`\"2015-09-24 14:00:00 GMT-0700\"`<br>`\"Sept 24 2015 14:00:00 GMT-0700\"`<br>`\"Thu Sep 24 2015 14:00:00 GMT-0700 (Pacific Daylight Time)\"`","default":"Optional","type":"string","name":"send_after"},{"_id":"5450097c3c6f700800a9b3d6","ref":"","required":false,"desc":"Possible values are:<br>`\"timezone\"` (Deliver at a specific time-of-day in each users own timezone)<br>`\"last-active\"` (Deliver at the same time of day as each user last used your app).<br>If \"send_after\" is used, this takes effect after the \"send_after' time has elapsed.","default":"Optional","type":"string","name":"delayed_option"},{"_id":"5450097c3c6f700800a9b3d5","ref":"","required":false,"desc":"Use with delayed_option=timezone.<br>Example: `\"9:00AM\"`","default":"Optional","type":"string","name":"delivery_time_of_day"},{"_id":"5500e352cfeeea1700471873","ref":"","required":false,"desc":"Sets the devices LED notification light if the device has one. ARGB Hex format.<br>Example(Blue): `\"FF0000FF\"`","default":"Optional","type":"string","name":"android_led_color"},{"_id":"5500e352cfeeea1700471872","ref":"","required":false,"desc":"Sets the background color of the notification circle to the left of the notification text. Only applies to apps targeting Android API level 21+ on Android 5.0+ devices.<br>Example(Red): `\"FFFF0000\"`","default":"Optional","type":"string","name":"android_accent_color"},{"_id":"5500e529cfeeea1700471877","ref":"","required":false,"desc":"Sets the lock screen visibility for apps targeting Android API level 21+ running on Android 5.0+ devices.<br>`-1` = Secret (Notification does not show on the lock screen at all)<br>`0` = Private (Hides message contents on lock screen if the user set \"Hide sensitive notification content\" in the system settings)<br>`1` = Public (OneSignal's default) (Shows the full message on the lock screen unless the user has disabled all notifications from showing on the lock screen. Please consider the user and mark private if the contents are.)","default":"Optional","type":"int","name":"android_visibility"},{"_id":"54b9b6b70308090c00e9a1d4","ref":"","required":false,"desc":"For iOS devices. Sends content-available=1 to wake your app to run custom native code.","default":"Optional","type":"boolean","name":"content_available"},{"_id":"54fe6df84f692335008c3593","ref":"","required":false,"desc":"Fires a Broadcast with a `com.onesignal.BackgroundBroadcast.RECEIVE` action when a notification is received. See our [Background Data Documentation](http://documentation.onesignal.com/docs/android-notification-customizations#background-data-silent-notifications).","default":"Optional","type":"boolean","name":"amazon_background_data"},{"_id":"55022c4764d596210042de5a","ref":"","required":false,"desc":"Use a template you setup on our dashboard. You can override the template values by sending other parameters with the request. The template_id is the UUID found in the URL when viewing a template on our dashboard.<br>Example: `be4a8044-bbd6-11e4-a581-000c2940e62c`","default":"Optional","type":"string","name":"template_id"},{"_id":"559ef0b6df92223500dc50ca","ref":"","required":false,"desc":"All Android notifications with the same group will be stacked together using Android's [Notification Stacking](https://developer.android.com/training/wearables/notifications/stacks.html) feature.","default":"Optional","type":"string","name":"android_group"},{"_id":"559ef2aedf92223500dc50d1","ref":"","required":false,"desc":"Summary message to display when 2+ notifications are stacked together. Default is \"# new messages\". Include $[notif_count] in your message and it will be replaced with the current number. \"en\" (English) is required. The key of each hash is either a a 2 character language code or one of zh-Hans/zh-Hant for Simplified or Traditional Chinese. The value of each key is the message that will be sent to users for that language.<br>Example: `\"{ \"en\" : \"You have $[notif_count] new messages\"}`","default":"Optional","type":"object","name":"android_group_message"},{"_id":"559ef324befce63500890026","ref":"","required":false,"desc":"All Amazon notifications with the same group will be stacked together using Android's [Notification Stacking](https://developer.android.com/training/wearables/notifications/stacks.html) feature.","default":"Optional","type":"string","name":"adm_group"},{"_id":"559ef324befce63500890025","ref":"","required":false,"desc":"Summary message to display when 2+ notifications are stacked together. Default is \"# new messages\". Include $[notif_count] in your message and it will be replaced with the current number. \"en\" (English) is required. The key of each hash is either a a 2 character language code or one of zh-Hans/zh-Hant for Simplified or Traditional Chinese. The value of each key is the message that will be sent to users for that language.<br>Example: `\"{ \"en\" : \"You have $[notif_count] new messages\"}`","default":"Optional","type":"object","name":"adm_group_message"},{"_id":"572a7a94c2ce542b00e6a9f5","ref":"","required":false,"desc":"Time To Live - In seconds. The notification will be expired if the device does not come back online within this time. The default is 259,200 seconds (3 days). Only works for Android, ChromeWeb, and iOS","default":"Optional","type":"int","name":"ttl"},{"_id":"572a7b587f34182900ce9edf","ref":"","required":false,"desc":"10 = High GCM priority for Android. Ignored on iOS as notifications are always sent with a 10 priority. This brings Android 6.0 devices out of doze mode. Only use if your notification is time sensitive and is important to the user as a high priority impacts battery life.","default":"Optional","type":"int","name":"priority"},{"_id":"576dad52a542fc0e0074a2f0","ref":"","required":false,"desc":"category aps payload, use with `registerUserNotificationSettings:categories` in your Objective-C / Swift code.","default":"Optional","type":"string","name":"ios_category"}],"url":"/notifications"},"isReference":false,"order":17,"body":"[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"'REST API Key' Required\",\n \"body\": \"This method requires an application 'REST API Key' when using `include_segments` or `tags`.<br>**NEVER** use your 'REST API key' in client code, it is intended for use on your system or server only.\\n\\nAdd the REST API Key to the HTTP 'Authorization' header as basic authentication. Check out our examples above (except the JSON one) for some tips.\"\n}\n[/block]\nThis method can be used to send push notifications to programmatically send notifications to users of your app.\n\nAt least one targeting parameters must be specified. Some targeting parameters are not compatible with each other.\n\nHere are the groups of possible targeting parameters. If a targeting parameter from one group is used, then targeting parameters from other groups must not be used:\n\n# Segment Group\n- included_segments\n- excluded_segments (Requires usage of included_segments)\n\n# Specific Users Group\n- include_player_ids\n- include_ios_tokens\n- include_android_reg_ids\n- include_wp_urls\n- include_wp_wns_uris\n- include_amazon_reg_ids\n- include_chrome_reg_ids\n- include_chrome_web_reg_ids\n\n# Tags group\n- tags\n\n<br>\n# Postman Example\n\n[block:image]\n{\n \"images\": [\n {\n \"image\": [\n \"https://www.filepicker.io/api/file/PAE2lwpeRgeDrJL2NDYR\",\n \"PostmanExample2.png\",\n \"838\",\n \"220\",\n \"#1b96cc\",\n \"\"\n ]\n }\n ]\n}\n[/block]\n\n[block:image]\n{\n \"images\": [\n {\n \"image\": [\n \"https://www.filepicker.io/api/file/eICzk0KQuaObNgbNaGSz\",\n \"PostmanExample1.png\",\n \"604\",\n \"208\",\n \"#485492\",\n \"\"\n ]\n }\n ]\n}\n[/block]","excerpt":"","slug":"notifications-create-notification","type":"post","title":"/notifications (Create Notification)"}post/notifications (Create Notification)
Definition
{{ api_url }}{{ page_api_url }}
Parameters
app_id:
required
stringRequired
Your OneSignal Application Key
contents:
required
objectRequired unless content_available=true, *_background_data=true, or template_id is set.
Message contents to send to players. "en" (English) is required. The key of each hash is either a a 2 character language code or one of zh-Hans/zh-Hant for Simplified or Traditional Chinese. The value of each key is the message that will be sent to users for that language. If do not specify a language English will be used.<br>Example: `{"en": "English Message","es": "Spanish Message"}`
headings:
objectOptional
Notification title to send to Android, Amazon, Chrome apps, and Chrome Websites. By default, this will be the application name. If this option is used, a value for "en" (English) is required. The value of each key is the title that will be sent to users for that language. If do not specify a language English will be used.<br>Example: `{"en": "English Title","es": "Spanish Title"}`
isIos:
booleanOptional.
Send to iOS devices?
isAndroid:
booleanOptional.
Send to Google Play Android devices?
isWP:
booleanOptional.
Send to Windows Phone 8.0 Devices?
isWP_WNS:
booleanOptional
Send to Windows Phone 8.1 Devices?
isAdm:
booleanOptional.
Send to Amazon ADM devices?
isChrome:
booleanOptional.
Send to Google Chrome App/Extension?
isChromeWeb:
booleanOptional
Send to Chrome Web subscribers?
isSafari:
booleanOptional
Send to Safari subscribers?
isAnyWeb:
booleanOptional
Send to all web subscribers? Includes ChromeWeb, Safari, Firefox, and any future browsers.
included_segments:
array of stringsOptional. Targeting parameter.
Names of segments to send the message to. Any player in any of these segments will be sent this notification. Only compatible with excluded_segments, do not use any other targeting parameters with this one.<br>Example: `["Free Players", "New Players"]`<br>*NOTE: 'REST API Key' Required*
excluded_segments:
array of stringsOptional. Targeting parameter.
Use with included_segments. Do not use with any other targeting parameters. Names of segments to exclude players from. Any players in any of these segments will not be sent the notification even if they are a member of included_segments. Requires API Auth Key.<br>Example: `["Free Players", "New Players"]`
include_player_ids:
array of stringsOptional. Targeting parameter.
Specific players to send your notification to. Do not combine with other targeting parameters. Not compatible with any other targeting parameters. Does not require API Auth Key.<br>Example: `["1dd608f2-c6a1-11e3-851d-000c2940e62c"]`<br>*Note: Recommended maximum of 2,000 ids per REST call for the best delivery times.*
include_ios_tokens:
array of stringsOptional. Targeting parameter.
Recommend using include_player_ids instead. <br>**Warning:** Only works with Production tokens. <br><br>Specific iOS device tokens to send the notification to (all non-alphanumeric characters must be removed from the tokens). Do not combine with other targeting parameters. If any of these tokens do not correspond to players in our system, a player will be automatically created for each of them. Does not require your "API Auth Key".<br>Example: `["ce777617da7f548fe7a9ab6febb56cf39fba6d38203..."]`
include_android_reg_ids:
array of stringsOptional. Targeting parameter.
Recommend using include_player_ids instead. Specific Android registration ids to send the notification to. Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your "API Auth Key".<br>Example: `["APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_..."]`
include_wp_uris:
array of stringsOptional. Targeting parameter.
Recommend using include_player_ids instead. Specific Windows Phone 8.0 channel URI to send the notification to. Do not combine with other targeting parameters. If these channel URIs do not correspond to players in our system, players will be automatically created. Does not require your "API Auth Key".<br>Example: `["http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-..."]`
include_wp_wns_uris:
array of stringsOptional. Targeting parameter.
Recommend using include_player_ids instead. Specific Windows Phone 8.1 channel URI to send the notification to. Do not combine with other targeting parameters. If these channel URIs do not correspond to players in our system, players will be automatically created. Does not require your "API Auth Key".<br>Example: `["http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-..."]`
include_amazon_reg_ids:
array of stringsOptional. Targeting parameter.
Recommend using include_player_ids instead. Specific Amazon ADM registration ids to send the notification to. Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your "API Auth Key".<br>Example: `["amzn1.adm-registration.v1.XpvSSUk0Rc3hTVVV..."]`
include_chrome_reg_ids:
array of stringsOptional. Targeting parameter.
Recommend using include_player_ids instead. Specific Chrome App/Extension Google registration ids to send the notification to. Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your "API Auth Key".<br>Example: `["APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_..."]`
include_chrome_web_reg_ids:
array of stringsOptional. Targeting parameter.
Recommend using include_player_ids instead. Specific Chrome Web Google registration ids to send the notification to. **Highly recommend using `include_player_ids` instead as these can change from time to time.**<br>Do not combine with other targeting parameters. If these registration ids do not correspond to players in our system, players will be automatically created. Does not require your "API Auth Key".<br>Example: `["APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_..."]`
app_ids:
array of stringsOptional. Targeting parameter.
Used to target all users across a list of your apps. If a user has 2 or more of the apps installed they will only receive 1 notification.<br>Example: <code class="inline-code">["2dd608f2-a6a1-11e3-251d-400c2940e62b", "2dd608f2-a6a1-11e3-251d-500f2950e61c"]</code><br>NOTE: Requires your "User Auth Key" in the HTTP header.
tags:
array of objectsOptional. Targeting parameter.
Match users by the values set for their tags. Do not combine with other targeting parameters. Possible relations are ">", "<",, "=", and "!=". "<" means that the value of the user's tag must be less than the value supplied in the "value" field of this hash. By default users must match all of the hashes specified in this array to receive the notification.<br>*You may add `{"operator": "OR"}` between the entries to allow any of the tag conditions.*<br>*A maximum of 200 tags and operators can be used at a time.*<br>*Note: Requires "REST API Key".*<br><br>**Example 1**<br>level='10' AND madePurchase='true'<br><code class="inline-code">[{"key": "level", "relation": ">", "value": "10"},<br> {"key": "madePurchase", "relation": "=","value": "true"}]</code><br>**Example 2:**<br>level='10' OR level='20'<br><code class="inline-code">[{"key": "level", "relation": "=", "value": "10"},<br> {"operator": "OR"},<br> {"key": "level", "relation": "=", "value": "20"}]</code><br>**Example 3:**<br>level='10' OR level='20'<br><code class="inline-code">[{"key": "is_vip", "relation": "!=", "value": "true"},<br> {"operator": "OR"},<br> {"key": "is_admin", "relation": "=", "value": "true"}]</code>
ios_badgeType:
stringOptional
Options are: `None`, `SetTo`, or `Increase`.<br>None leaves the count unaffected on the device. If you use Increase, it will be based on the current value of the player's badge_count.
ios_badgeCount:
integerOptional
Sets or increases the badge icon on the device depending on the ios_badgeType value
ios_sound:
stringOptional
Sound file that is included in your app to play instead of the default device notification sound. Pass "nil" to disable vibration and sound for the notification.<br>Example: `"notification.wav"`
android_sound:
stringOptional
Sound file that is included in your app to play instead of the default device notification sound.<br>NOTE: Leave off file extension for Android.<br>Example: `"notification"`
adm_sound:
stringOptional
Amazon devices<br>Sound file that is included in your app to play instead of the default device notification sound.<br>NOTE: Leave off file extension for Android.<br>Example: `"notification"`
wp_sound:
stringOptional
Windows Phone 8.0<br>Sound file that is included in your app to play instead of the default device notification sound.<br>Example: `"notification.wav"`
wp_wns_sound:
stringOptional
Windows Phone 8.1<br>Sound file that is included in your app to play instead of the default device notification sound.<br>Example: `"notification.wav"`
data:
objectOptional
Custom key value pair hash that you can programmatically read in your app's code.<br>Example: `{"abc": "123", "foo": "bar"}`
buttons:
array of objectsOptional
Buttons to add to the notification. Supported by iOS 8.0 and Android 4.1+ devices. Icon only works for Android.<br>Example: <code class="inline-code">[{"id": "id1", "text": "button1", "icon": "ic_menu_share"}, {"id": "id2", "text": "button2", "icon": "ic_menu_send"}]</code>
web_buttons:
array of objectsOptional
Chrome 48+ (web push) only. Add action buttons to the notification. <br>Example: <code class="inline-code">[{"id": "like-button", "text": "Like", "icon": "http://i.imgur.com/N8SN8ZS.png", "url": "https://yoursite.com"}, {"id": "read-more-button", "text": "Read more", "icon": "http://i.imgur.com/MIxJp1L.png", "url": "https://yoursite.com"}]</code>
small_icon:
stringOptional
Specific Android icon to use. If blank the app icon is used. Must be the drawable resource name.
large_icon:
stringOptional
Specific Android icon to display to the left of the notification. If blank the small_icon is used. Can be a drawable resource name or a URL.
big_picture:
stringOptional
Specific Android picture to display in the expanded view. Can be a drawable resource name or a URL.
adm_small_icon:
stringOptional
Specific Amazon icon to use. If blank the app icon is used. Must be the drawable resource name.
adm_large_icon:
stringOptional
Specific Amazon icon to display to the left of the notification. If blank the adm_small_icon is used. Can be a drawable resource name or a URL.
adm_big_picture:
stringOptional
Specific Amazon picture to display in the expanded view. Can be a drawable resource name or a URL.
chrome_icon:
stringOptional
For Chrome extensions & apps only, NOT for Chrome web push. The local URL to an icon to use. if blank the app icon will be used. For Chrome web push please see "chrome_web_icon".
chrome_big_picture:
stringOptional
Specific Chrome large picture to display below the notification text. Must be a local URL.
chrome_web_icon:
stringOptional
Specific Chrome website image URL to be shown to the left of the notification text. Should be 80x80 @ 24bit so it displays on all platforms correctly.
firefox_icon:
stringOptional
Specific Firefox website image URL to be shown to the right of the notification text.
url:
stringOptional
When the player opens the notification their web browser will open this url.<br>Example: `"http://google.com"`
send_after:
stringOptional
Schedule notification for future delivery.<br>Examples:<br>*All examples are the exact same date & time.*<br>`"Thu Sep 24 2015 14:00:00 GMT-0700 (PDT)"`<br>`"September 24th 2015, 2:00:00 pm UTC-07:00"`<br>`"2015-09-24 14:00:00 GMT-0700"`<br>`"Sept 24 2015 14:00:00 GMT-0700"`<br>`"Thu Sep 24 2015 14:00:00 GMT-0700 (Pacific Daylight Time)"`
delayed_option:
stringOptional
Possible values are:<br>`"timezone"` (Deliver at a specific time-of-day in each users own timezone)<br>`"last-active"` (Deliver at the same time of day as each user last used your app).<br>If "send_after" is used, this takes effect after the "send_after' time has elapsed.
delivery_time_of_day:
stringOptional
Use with delayed_option=timezone.<br>Example: `"9:00AM"`
android_led_color:
stringOptional
Sets the devices LED notification light if the device has one. ARGB Hex format.<br>Example(Blue): `"FF0000FF"`
android_accent_color:
stringOptional
Sets the background color of the notification circle to the left of the notification text. Only applies to apps targeting Android API level 21+ on Android 5.0+ devices.<br>Example(Red): `"FFFF0000"`
android_visibility:
integerOptional
Sets the lock screen visibility for apps targeting Android API level 21+ running on Android 5.0+ devices.<br>`-1` = Secret (Notification does not show on the lock screen at all)<br>`0` = Private (Hides message contents on lock screen if the user set "Hide sensitive notification content" in the system settings)<br>`1` = Public (OneSignal's default) (Shows the full message on the lock screen unless the user has disabled all notifications from showing on the lock screen. Please consider the user and mark private if the contents are.)
content_available:
booleanOptional
For iOS devices. Sends content-available=1 to wake your app to run custom native code.
amazon_background_data:
booleanOptional
Fires a Broadcast with a `com.onesignal.BackgroundBroadcast.RECEIVE` action when a notification is received. See our [Background Data Documentation](http://documentation.onesignal.com/docs/android-notification-customizations#background-data-silent-notifications).
template_id:
stringOptional
Use a template you setup on our dashboard. You can override the template values by sending other parameters with the request. The template_id is the UUID found in the URL when viewing a template on our dashboard.<br>Example: `be4a8044-bbd6-11e4-a581-000c2940e62c`
android_group:
stringOptional
All Android notifications with the same group will be stacked together using Android's [Notification Stacking](https://developer.android.com/training/wearables/notifications/stacks.html) feature.
android_group_message:
objectOptional
Summary message to display when 2+ notifications are stacked together. Default is "# new messages". Include $[notif_count] in your message and it will be replaced with the current number. "en" (English) is required. The key of each hash is either a a 2 character language code or one of zh-Hans/zh-Hant for Simplified or Traditional Chinese. The value of each key is the message that will be sent to users for that language.<br>Example: `"{ "en" : "You have $[notif_count] new messages"}`
adm_group:
stringOptional
All Amazon notifications with the same group will be stacked together using Android's [Notification Stacking](https://developer.android.com/training/wearables/notifications/stacks.html) feature.
adm_group_message:
objectOptional
Summary message to display when 2+ notifications are stacked together. Default is "# new messages". Include $[notif_count] in your message and it will be replaced with the current number. "en" (English) is required. The key of each hash is either a a 2 character language code or one of zh-Hans/zh-Hant for Simplified or Traditional Chinese. The value of each key is the message that will be sent to users for that language.<br>Example: `"{ "en" : "You have $[notif_count] new messages"}`
ttl:
integerOptional
Time To Live - In seconds. The notification will be expired if the device does not come back online within this time. The default is 259,200 seconds (3 days). Only works for Android, ChromeWeb, and iOS
priority:
integerOptional
10 = High GCM priority for Android. Ignored on iOS as notifications are always sent with a 10 priority. This brings Android 6.0 devices out of doze mode. Only use if your notification is time sensitive and is important to the user as a high priority impacts battery life.
ios_category:
stringOptional
category aps payload, use with `registerUserNotificationSettings:categories` in your Objective-C / Swift code.