{"__v":29,"_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","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-22T01:34:57.891Z","from_sync":false,"order":19,"slug":"server-rest-api","title":"Server REST API"},"editedParams":true,"editedParams2":true,"parentDoc":null,"project":"542b6018044e1e2200413772","user":"542b6010044e1e220041376f","version":{"__v":10,"_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","5792ca4369c5120e00efe023","5792ca55366dd20e004736d7","5792d30b23106419009c431b"],"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":"","in":"body","required":true,"desc":"Your OneSignal application ID, which can be found on our dashboard at onesignal.com under *App Settings* > *Keys & IDs*. It is a UUID and looks similar to `8250eaf6-1a58-489e-b136-7c74a864b434`.","default":"Required","type":"string","name":"app_id"},{"_id":"5450097c3c6f700800a9b3ea","ref":"","in":"body","required":true,"desc":"<p>The notification's content (excluding the title), a map of language codes to text for each language.</p> <p>Each hash must have a language code string for a key, mapped to the localized text you would like users to receive for that language. **English must be included in the hash**. [See the language codes you can use here.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-what-languages-codes-can-i-use-)</p> <p>Example: `{\"en\": \"English Message\", \"es\": \"Spanish Message\"}`</p>","default":"Required unless content_available=true or template_id is set.","type":"object","name":"contents"},{"_id":"546bd25c5281200800041490","ref":"","in":"body","required":false,"desc":"<p>The notification's title, a map of language codes to text for each language.</p> <p>Each hash must have a language code string for a key, mapped to the localized text you would like users to receive for that language. A default title *may* be displayed if a title is not provided. [See the language codes you can use here.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-what-languages-codes-can-i-use-)</p> <p>Example: `{\"en\": \"English Title\", \"es\": \"Spanish Title\"}`</p>","default":"Optional","type":"object","name":"headings"},{"_id":"5450097c3c6f700800a9b3e9","ref":"","in":"body","required":false,"desc":"Indicates whether to send to all devices registered under your app's *Apple iOS* platform.","default":"Optional.","type":"boolean","name":"isIos"},{"_id":"5450097c3c6f700800a9b3e8","ref":"","in":"body","required":false,"desc":"Indicates whether to send to all devices registered under your app's *Google Android* platform.","default":"Optional.","type":"boolean","name":"isAndroid"},{"_id":"5450097c3c6f700800a9b3e7","ref":"","in":"body","required":false,"desc":"Indicates whether to send to all devices registered under your app's *Windows Phone 8.0* platform.","default":"Optional.","type":"boolean","name":"isWP"},{"_id":"5747688c338b84190025f454","ref":"","in":"body","required":false,"desc":"Indicates whether to send to all devices registered under your app's *Windows Phone 8.1+* platform.","default":"Optional","type":"boolean","name":"isWP_WNS"},{"_id":"54b4143df6445c1f00087485","ref":"","in":"body","required":false,"desc":"Indicates whether to send to all devices registered under your app's *Amazon Fire* platform.","default":"Optional.","type":"boolean","name":"isAdm"},{"_id":"54c6c329f0320f0d00ac9c75","ref":"","in":"body","required":false,"desc":"<p>Indicates whether to send to all devices registered under your app's *Google Chrome Apps & Extension* platform.</p><p>**This flag is *not used* for web push**. Please see `isChromeWeb` for sending to web push users. This flag only applies to *Google Chrome Apps & Extensions*.</p>","default":"Optional.","type":"boolean","name":"isChrome"},{"_id":"5563cb3f6d874e0d00584286","ref":"","in":"body","required":false,"desc":"Indicates whether to send to all *Google Chrome, Chrome on Android, and Mozilla Firefox users* registered under your Chrome & Firefox web push platform.","default":"Optional","type":"boolean","name":"isChromeWeb"},{"_id":"57aa55fa96457c0e005a3773","ref":"","in":"body","required":false,"desc":"<p>Indicates whether to send to all *Mozilla Firefox* desktop users registered under your Firefox web push platform.</p>","default":"","type":"boolean","name":"isFirefox"},{"_id":"561c42801529740d00a70dcc","ref":"","in":"body","required":false,"desc":"<p>Indicates whether to send to all *Apple's Safari* desktop users registered under your Safari web push platform.</p><p>[This is not supported on iOS.](https://onesignal.com/blog/when-will-web-push-be-supported-in-ios/)</p>","default":"Optional","type":"boolean","name":"isSafari"},{"_id":"561c42801529740d00a70dcb","ref":"","in":"body","required":false,"desc":"<p>Indicates whether to send to all subscribed web browser users, including *Chrome, Firefox, and Safari*.</p><p>You may use this instead as a combined flag instead of separately enabling `isChromeWeb` and `isSafari`, though the two options are equivalent to this one.</p>","default":"Optional","type":"boolean","name":"isAnyWeb"},{"_id":"5450097c3c6f700800a9b3e6","ref":"","in":"body","required":false,"desc":"<p>An array of segment names. Users in these segments *will* receive a notification.</p> <p>This targeting parameter is *only compatible with* `excluded_segments`.</p> <p>[Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-)</p> <p>Example: `[\"Active Users\", \"Inactive Users\"]</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"included_segments"},{"_id":"5450097c3c6f700800a9b3e5","ref":"","in":"body","required":false,"desc":"<p>An array of segment names. Users in these segments *will not* receive a notification, even if they were included in `included_segments`.</p> <p>This targeting parameter is *only compatible with* `included_segments`.</p> <p>[Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-)</p> <p>Example: `[\"Active Users\", \"Inactive Users\"]</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"excluded_segments"},{"_id":"5450097c3c6f700800a9b3e4","ref":"","in":"body","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\"]`","default":"Optional. Targeting parameter.","type":"array_string","name":"include_player_ids"},{"_id":"5450097c3c6f700800a9b3e3","ref":"","in":"body","required":false,"desc":"<p>An array of iOS device tokens to send the notification to.</p> <p>**Warning:** Only works with *Production* tokens.</p> <p>All non-alphanumeric characters must be removed from each token.</p> <p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `ce777617da7f548fe7a9ab6febb56cf39fba6d38203...`</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"include_ios_tokens"},{"_id":"5450097c3c6f700800a9b3e2","ref":"","in":"body","required":false,"desc":"<p>An array of Android registration IDs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...`</p> <p>Warning: Registration tokens for a device may change and the old ones will become invalid. Use include_player_ids to avoid this issue.</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"include_android_reg_ids"},{"_id":"5450097c3c6f700800a9b3e1","ref":"","in":"body","required":false,"desc":"<p>An array of Windows Phone 8.0 channel URIs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-...`</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"include_wp_uris"},{"_id":"55e674749cc7c62b00c4a1e0","ref":"","in":"body","required":false,"desc":"<p>An array of Windows Phone 8.1 channel URIs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-...`</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"include_wp_wns_uris"},{"_id":"54b41531f6445c1f00087487","ref":"","in":"body","required":false,"desc":"<p>An array of Amazon ADM registration IDs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `amzn1.adm-registration.v1.XpvSSUk0Rc3hTVVV...`</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"include_amazon_reg_ids"},{"_id":"54c6c4e5f0320f0d00ac9c7a","ref":"","in":"body","required":false,"desc":"<p>An array of Chrome App/Ext Google registration IDs IDs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...`</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"include_chrome_reg_ids"},{"_id":"556b8c3730922f1700ad5dd5","ref":"","in":"body","required":false,"desc":"<p>An array of Google Chrome web push registration IDs to send the notification to.</p> <p>Please consider using `include_player_ids` as an alternative, as web push registration IDs can vary over time where our player IDs remain constant.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...`</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"include_chrome_web_reg_ids"},{"_id":"554d0443de67270d009b02f6","ref":"","in":"body","required":false,"desc":"<p>An array of OneSignal app IDs. All users within these apps will receive at most one notification.</p> <p>[Your User Auth API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-user-auth-key-)</p> <p>Example: `[\"2dd608f2-a6a1-11e3-251d-400c2940e62b\", \"2dd608f2-a6a1-11e3-251d-500f2950e61c\"]`</p>","default":"Optional. Targeting parameter.","type":"array_string","name":"app_ids"},{"_id":"5450097c3c6f700800a9b3e0","ref":"","in":"body","required":false,"desc":"**NOTE: The tags field is being deprecated, please use the filter field below instead to filter by tags** <br><br><p>Targets notification recipients by tag. A tag is custom data you can store on each user. This parameter is described by a map of tag key, relation, and value.</p> <p>`{\"key\": \"level\", \"relation\": \">\", \"value\": \"10\"}`</p> <p>Valid tag relations are `>`, `<`, `=`, `!=`. Tags are *AND*ed by default; insert `{\"operator\": \"OR\"}` between entries to `OR` the parameters together.</p> <p>[Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-)</p> <p>For performance reasons, a *maximum of 200 tags and operators* can be used at a time.</p><p> This targeting parameter cannot be combined with any other parameter.</p> <p>Example 1 (User *is* level 10 *and* purchased item): `[{\"key\": \"level\", \"relation\": \">\", \"value\": \"10\"}, {\"key\": \"madePurchase\", \"relation\": \"=\",\"value\": \"true\"}]`</p> <p>Example 2 (User *is* level 10 *or* 20): `[{\"key\": \"level\", \"relation\": \"=\", \"value\": \"10\"}, {\"operator\": \"OR\"}, {\"key\": \"level\", \"relation\": \"=\", \"value\": \"20\"}]`</p> <p>Example 3 (User *is not* VIP *or* is admin): `[{\"key\": \"is_vip\", \"relation\": \"!=\", \"value\": \"true\"}, {\"operator\": \"OR\"}, {\"key\": \"is_admin\", \"relation\": \"=\", \"value\": \"true\"}]`</p><br>","default":"Optional. Targeting parameter.","type":"array_object","name":"tags"},{"_id":"57bcf02776d7050e0069e74a","ref":"","in":"body","required":false,"desc":"<p>Targets notification recipients with filters. This is a array of JSON objects containing field conditions to check.</p> See the below field options.<br> **last_session** <br> <ul><li>`relation` = `\">\"` or `\"<\"`</li><li>`hours_ago` = number of hours before or after the users last session. Example: `\"1.1\"`</li></ul> **first_session** <br> <ul><li>`relation` = `\">\"` or `\"<\"`</li><li>`hours_ago` = number of hours before or after the users first session. Example: `\"1.1\"`</li></ul> **session_count** <br> <ul><li>`relation` = `\">\"`, `\"<\"`, `\"=\"`, or `\"!=\"`</li><li>`value` = number sessions. Example: `\"1\"`</li></ul> **session_time** <br> <ul><li>`relation` = `\">\"` or `\"<\"`. </li><li>`value` = Time in seconds the user has been in your app. Example: `\"3600\"`</li></ul> **amount_spent** <br> <ul><li>`relation` = `\">\"`, `\"<\"`, or `\"=\"`</li><li>`value` = Amount in USD a user has spent on IAP (In App Purchases). Example: `\"0.99\"`</li></ul> **bought_sku** <br> <ul><li>`relation` = `\">\"`, `\"<\"`, or `\"=\"`</li><li>`key` = SKU purchased in your app as an IAP (In App Purchases). Example: `\"com.domain.100coinpack\"`</li><li>`value` = value of SKU to compare to. Example: `\"0.99\"`</li></ul> **tag** <br> <ul><li>`relation` = `\">\"`, `\"<\"`, `\"=\"`, `\"!=\"`</li><li>`key` = Tag key to compare.</li><li>`value` = Tag value to compare. Example: See tag example below</li></ul> **language** <br> <ul><li>`relation` = `\"=\"`, `\"!=\"`. </li><li>`value` = 2 character language code. Example: \"en\". See a list of all language codes [here](frequently-asked-questions#section-what-languages-codes-can-i-use-)</li></ul> **app_version** <br> <ul><li>`relation` = `\">\"`, `\"<\"`, `\"=\"`, `\"!=\"`</li><li>`value` = app version. Example: \"1.0.0\"</li></ul> **location** <br> <ul><li>`radius` = in meters</li><li>`lat` = latitude</li><li>`long` = longitude</li></ul> **email** <br> <ul><li>`value` = email address</li></ul> <br><br> Filter entires are *AND*ed by default; insert `{\"operator\": \"OR\"}` between entries to `OR` the parameters together.<br> [Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-) For performance reasons, a *maximum of 200 entries* can be used at a time. This filter targeting parameter cannot be combined with any other targeting parameters.<br> <br> Example 1 (User *is* level 10 *and* purchased item):<br> `[{\"field\": \"tag\", \"key\": \"level\", \"relation\": \">\", \"value\": \"10\"}, {\"field\": \"amount_spent\", \"relation\": \">\",\"value\": \"0\"}]`<br> <br> Example 2 (User *is* level 10 *or* 20):<br> `[{\"field\": \"tag\", \"key\": \"level\", \"relation\": \"=\", \"value\": \"10\"}, {\"operator\": \"OR\"}, {\"field\": \"tag\", \"key\": \"level\", \"relation\": \"=\", \"value\": \"20\"}]`<br> <br> Example 3 (User *is not* VIP *or* is admin):<br> `[{\"field\": \"tag\", \"key\": \"is_vip\", \"relation\": \"!=\", \"value\": \"true\"}, {\"operator\": \"OR\"}, {\"field\": \"tag\",\"key\": \"is_admin\", \"relation\": \"=\", \"value\": \"true\"}]`","default":"Optional","type":"array_object","name":"filters"},{"_id":"5450097c3c6f700800a9b3df","ref":"","in":"body","required":false,"desc":"<p>Describes whether to *set* or *increase/decrease* your app's iOS badge count by the `ios_badgeCount` specified count.</p> <p>One of `None`, `SetTo`, or `Increase`.</p> <p>`None` leaves the count unaffected. `SetTo` directly sets the badge count to the number specified in `ios_badgeCount`. `Increase` increases the badge count by the number specified in `ios_badgeCount`. Use a negative `ios_badgeCount` to decrease the badge count.</p>","default":"Optional","type":"string","name":"ios_badgeType"},{"_id":"5450097c3c6f700800a9b3de","ref":"","in":"body","required":false,"desc":"<p>Used with `ios_badgeType`, describes the value to *set* or amount to *increase/decrease* your app's iOS badge count by.</p> <p>You can use a negative number to decrease the badge count when used with an `ios_badgeType` of `Increase`.</p>","default":"Optional","type":"int","name":"ios_badgeCount"},{"_id":"5450097c3c6f700800a9b3dd","ref":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","required":false,"desc":"<p>A custom map of data that is passed back to your app.</p> <p>Example: `{\"abc\": \"123\", \"foo\": \"bar\"}`</p>","default":"Optional","type":"object","name":"data"},{"_id":"5450097c3c6f700800a9b3d9","ref":"","in":"body","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":"","in":"body","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><br>The `id` field is required.","default":"Optional","type":"array_object","name":"web_buttons"},{"_id":"54821d7ec7026c210099d173","ref":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","required":false,"desc":"Sets the web push notification's icon. An image URL linking to a valid image. Common image types are supported; GIF will not animate. We recommend 256x256 (at least 80x80) to display well on high DPI devices. This icon is also used a default for Firefox if not provided.","default":"Optional","type":"string","name":"chrome_web_icon"},{"_id":"56b122806d004b170080668c","ref":"","in":"body","required":false,"desc":"Sets the web push notification's icon for Firefox. An image URL linking to a valid image. Common image types are supported; GIF will not animate. We recommend 256x256 (at least 80x80) to display well on high DPI devices.","default":"Optional","type":"string","name":"firefox_icon"},{"_id":"5450097c3c6f700800a9b3d8","ref":"","in":"body","required":false,"desc":"<p>The URL to open in the browser when a user clicks on the notification.</p> <p>Example: `http://www.google.com`</p>","default":"Optional","type":"string","name":"url"},{"_id":"5450097c3c6f700800a9b3d7","ref":"","in":"body","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":"","in":"body","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":"","in":"body","required":false,"desc":"Use with delayed_option=timezone.<br>Example: `\"9:00AM\"`","default":"Optional","type":"string","name":"delivery_time_of_day"},{"_id":"5500e352cfeeea1700471873","ref":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"55022c4764d596210042de5a","ref":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","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":"","in":"body","required":false,"desc":"category aps payload, use with `registerUserNotificationSettings:categories` in your Objective-C / Swift code. For iOS 10: Fires the [UNNotificationContentExtension](https://developer.apple.com/reference/usernotificationsui/unnotificationcontentextension) in your app.","default":"Optional","type":"string","name":"ios_category"},{"_id":"57c61fc61ece610e009cfde1","ref":"","in":"body","required":false,"desc":"Adds media attachments to iOS 10 notifications. Set as JSON object, key as a media id of your choice and the value as a valid local file name or URL. Example:<br>`{\"id1\": \"https://domain.com/image.jpg\"}`<br>Press and hold on the notification to view. mutable-content not required. Must be using our 2.1.1 SDK or newer.","default":"Optional","type":"object","name":"ios_attachments"},{"_id":"57c625c95a5ce417004c37e4","ref":"","in":"body","required":false,"desc":"iOS 10 feature used to trigger `didReceive(_:withContentHandler:)` on your [UNNotificationServiceExtension](https://developer.apple.com/reference/usernotifications/unnotificationserviceextension). This allows you to change the notification content in your app before it is displayed.","default":"Optional","type":"boolean","name":"mutable_content"},{"_id":"57d092881b001c0e00223b18","ref":"","in":"body","required":false,"desc":"Allowing setting a background image for the notification. This is a JSON object containing the following keys.<br>`image` - Asset file, android resource name, or URL to remote image. recommend size: 1582x256<br>`headings_color` - Title text color ARGB Hex format. Example(Blue): `\"FF0000FF\"`.<br>`contents_color` - Body text color ARGB Hex format. Example(Red): `\"FFFF0000\"`<br>Example:<br>`{\"image\": \"https://domain.com/background_image.jpg\", \"headings_color\": \"FFFF0000\", \"contents_color\": \"FF00FF00\"}`","default":"Optional","type":"object","name":"android_background_layout"}],"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# Filters group\n- tags\n- filters\n\n<br>\n# Postman Example\n\n[block:image]\n{\n \"images\": [\n {\n \"image\": [\n \"https://files.readme.io/fKb06zZaQgW3AtnQqXUX_PostmanExample2.png\",\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://files.readme.io/AWhI22Y7T8O4YUmgZba2_PostmanExample1.png\",\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
Body JSON
app_id:
required
stringRequired
Your OneSignal application ID, which can be found on our dashboard at onesignal.com under *App Settings* > *Keys & IDs*. It is a UUID and looks similar to `8250eaf6-1a58-489e-b136-7c74a864b434`.
contents:
required
objectRequired unless content_available=true or template_id is set.
<p>The notification's content (excluding the title), a map of language codes to text for each language.</p> <p>Each hash must have a language code string for a key, mapped to the localized text you would like users to receive for that language. **English must be included in the hash**. [See the language codes you can use here.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-what-languages-codes-can-i-use-)</p> <p>Example: `{"en": "English Message", "es": "Spanish Message"}`</p>
headings:
objectOptional
<p>The notification's title, a map of language codes to text for each language.</p> <p>Each hash must have a language code string for a key, mapped to the localized text you would like users to receive for that language. A default title *may* be displayed if a title is not provided. [See the language codes you can use here.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-what-languages-codes-can-i-use-)</p> <p>Example: `{"en": "English Title", "es": "Spanish Title"}`</p>
isIos:
booleanOptional.
Indicates whether to send to all devices registered under your app's *Apple iOS* platform.
isAndroid:
booleanOptional.
Indicates whether to send to all devices registered under your app's *Google Android* platform.
isWP:
booleanOptional.
Indicates whether to send to all devices registered under your app's *Windows Phone 8.0* platform.
isWP_WNS:
booleanOptional
Indicates whether to send to all devices registered under your app's *Windows Phone 8.1+* platform.
isAdm:
booleanOptional.
Indicates whether to send to all devices registered under your app's *Amazon Fire* platform.
isChrome:
booleanOptional.
<p>Indicates whether to send to all devices registered under your app's *Google Chrome Apps & Extension* platform.</p><p>**This flag is *not used* for web push**. Please see `isChromeWeb` for sending to web push users. This flag only applies to *Google Chrome Apps & Extensions*.</p>
isChromeWeb:
booleanOptional
Indicates whether to send to all *Google Chrome, Chrome on Android, and Mozilla Firefox users* registered under your Chrome & Firefox web push platform.
isFirefox:
boolean
<p>Indicates whether to send to all *Mozilla Firefox* desktop users registered under your Firefox web push platform.</p>
isSafari:
booleanOptional
<p>Indicates whether to send to all *Apple's Safari* desktop users registered under your Safari web push platform.</p><p>[This is not supported on iOS.](https://onesignal.com/blog/when-will-web-push-be-supported-in-ios/)</p>
isAnyWeb:
booleanOptional
<p>Indicates whether to send to all subscribed web browser users, including *Chrome, Firefox, and Safari*.</p><p>You may use this instead as a combined flag instead of separately enabling `isChromeWeb` and `isSafari`, though the two options are equivalent to this one.</p>
included_segments:
array of stringsOptional. Targeting parameter.
<p>An array of segment names. Users in these segments *will* receive a notification.</p> <p>This targeting parameter is *only compatible with* `excluded_segments`.</p> <p>[Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-)</p> <p>Example: `["Active Users", "Inactive Users"]</p>
excluded_segments:
array of stringsOptional. Targeting parameter.
<p>An array of segment names. Users in these segments *will not* receive a notification, even if they were included in `included_segments`.</p> <p>This targeting parameter is *only compatible with* `included_segments`.</p> <p>[Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-)</p> <p>Example: `["Active Users", "Inactive Users"]</p>
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"]`
include_ios_tokens:
array of stringsOptional. Targeting parameter.
<p>An array of iOS device tokens to send the notification to.</p> <p>**Warning:** Only works with *Production* tokens.</p> <p>All non-alphanumeric characters must be removed from each token.</p> <p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `ce777617da7f548fe7a9ab6febb56cf39fba6d38203...`</p>
include_android_reg_ids:
array of stringsOptional. Targeting parameter.
<p>An array of Android registration IDs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...`</p> <p>Warning: Registration tokens for a device may change and the old ones will become invalid. Use include_player_ids to avoid this issue.</p>
include_wp_uris:
array of stringsOptional. Targeting parameter.
<p>An array of Windows Phone 8.0 channel URIs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-...`</p>
include_wp_wns_uris:
array of stringsOptional. Targeting parameter.
<p>An array of Windows Phone 8.1 channel URIs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-...`</p>
include_amazon_reg_ids:
array of stringsOptional. Targeting parameter.
<p>An array of Amazon ADM registration IDs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `amzn1.adm-registration.v1.XpvSSUk0Rc3hTVVV...`</p>
include_chrome_reg_ids:
array of stringsOptional. Targeting parameter.
<p>An array of Chrome App/Ext Google registration IDs IDs to send the notification to.</p><p>Please consider using `include_player_ids` as an alternative.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...`</p>
include_chrome_web_reg_ids:
array of stringsOptional. Targeting parameter.
<p>An array of Google Chrome web push registration IDs to send the notification to.</p> <p>Please consider using `include_player_ids` as an alternative, as web push registration IDs can vary over time where our player IDs remain constant.</p> <p>If a token does not correspond to an existing user, a new user will be created.</p> <p>Example: `APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_...`</p>
app_ids:
array of stringsOptional. Targeting parameter.
<p>An array of OneSignal app IDs. All users within these apps will receive at most one notification.</p> <p>[Your User Auth API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-user-auth-key-)</p> <p>Example: `["2dd608f2-a6a1-11e3-251d-400c2940e62b", "2dd608f2-a6a1-11e3-251d-500f2950e61c"]`</p>
tags:
array of objectsOptional. Targeting parameter.
**NOTE: The tags field is being deprecated, please use the filter field below instead to filter by tags** <br><br><p>Targets notification recipients by tag. A tag is custom data you can store on each user. This parameter is described by a map of tag key, relation, and value.</p> <p>`{"key": "level", "relation": ">", "value": "10"}`</p> <p>Valid tag relations are `>`, `<`, `=`, `!=`. Tags are *AND*ed by default; insert `{"operator": "OR"}` between entries to `OR` the parameters together.</p> <p>[Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-)</p> <p>For performance reasons, a *maximum of 200 tags and operators* can be used at a time.</p><p> This targeting parameter cannot be combined with any other parameter.</p> <p>Example 1 (User *is* level 10 *and* purchased item): `[{"key": "level", "relation": ">", "value": "10"}, {"key": "madePurchase", "relation": "=","value": "true"}]`</p> <p>Example 2 (User *is* level 10 *or* 20): `[{"key": "level", "relation": "=", "value": "10"}, {"operator": "OR"}, {"key": "level", "relation": "=", "value": "20"}]`</p> <p>Example 3 (User *is not* VIP *or* is admin): `[{"key": "is_vip", "relation": "!=", "value": "true"}, {"operator": "OR"}, {"key": "is_admin", "relation": "=", "value": "true"}]`</p><br>
filters:
array of objectsOptional
<p>Targets notification recipients with filters. This is a array of JSON objects containing field conditions to check.</p> See the below field options.<br> **last_session** <br> <ul><li>`relation` = `">"` or `"<"`</li><li>`hours_ago` = number of hours before or after the users last session. Example: `"1.1"`</li></ul> **first_session** <br> <ul><li>`relation` = `">"` or `"<"`</li><li>`hours_ago` = number of hours before or after the users first session. Example: `"1.1"`</li></ul> **session_count** <br> <ul><li>`relation` = `">"`, `"<"`, `"="`, or `"!="`</li><li>`value` = number sessions. Example: `"1"`</li></ul> **session_time** <br> <ul><li>`relation` = `">"` or `"<"`. </li><li>`value` = Time in seconds the user has been in your app. Example: `"3600"`</li></ul> **amount_spent** <br> <ul><li>`relation` = `">"`, `"<"`, or `"="`</li><li>`value` = Amount in USD a user has spent on IAP (In App Purchases). Example: `"0.99"`</li></ul> **bought_sku** <br> <ul><li>`relation` = `">"`, `"<"`, or `"="`</li><li>`key` = SKU purchased in your app as an IAP (In App Purchases). Example: `"com.domain.100coinpack"`</li><li>`value` = value of SKU to compare to. Example: `"0.99"`</li></ul> **tag** <br> <ul><li>`relation` = `">"`, `"<"`, `"="`, `"!="`</li><li>`key` = Tag key to compare.</li><li>`value` = Tag value to compare. Example: See tag example below</li></ul> **language** <br> <ul><li>`relation` = `"="`, `"!="`. </li><li>`value` = 2 character language code. Example: "en". See a list of all language codes [here](frequently-asked-questions#section-what-languages-codes-can-i-use-)</li></ul> **app_version** <br> <ul><li>`relation` = `">"`, `"<"`, `"="`, `"!="`</li><li>`value` = app version. Example: "1.0.0"</li></ul> **location** <br> <ul><li>`radius` = in meters</li><li>`lat` = latitude</li><li>`long` = longitude</li></ul> **email** <br> <ul><li>`value` = email address</li></ul> <br><br> Filter entires are *AND*ed by default; insert `{"operator": "OR"}` between entries to `OR` the parameters together.<br> [Your REST API key is required for authentication.](https://documentation.onesignal.com/docs/frequently-asked-questions#section-where-can-i-find-my-rest-api-key-) For performance reasons, a *maximum of 200 entries* can be used at a time. This filter targeting parameter cannot be combined with any other targeting parameters.<br> <br> Example 1 (User *is* level 10 *and* purchased item):<br> `[{"field": "tag", "key": "level", "relation": ">", "value": "10"}, {"field": "amount_spent", "relation": ">","value": "0"}]`<br> <br> Example 2 (User *is* level 10 *or* 20):<br> `[{"field": "tag", "key": "level", "relation": "=", "value": "10"}, {"operator": "OR"}, {"field": "tag", "key": "level", "relation": "=", "value": "20"}]`<br> <br> Example 3 (User *is not* VIP *or* is admin):<br> `[{"field": "tag", "key": "is_vip", "relation": "!=", "value": "true"}, {"operator": "OR"}, {"field": "tag","key": "is_admin", "relation": "=", "value": "true"}]`
ios_badgeType:
stringOptional
<p>Describes whether to *set* or *increase/decrease* your app's iOS badge count by the `ios_badgeCount` specified count.</p> <p>One of `None`, `SetTo`, or `Increase`.</p> <p>`None` leaves the count unaffected. `SetTo` directly sets the badge count to the number specified in `ios_badgeCount`. `Increase` increases the badge count by the number specified in `ios_badgeCount`. Use a negative `ios_badgeCount` to decrease the badge count.</p>
ios_badgeCount:
integerOptional
<p>Used with `ios_badgeType`, describes the value to *set* or amount to *increase/decrease* your app's iOS badge count by.</p> <p>You can use a negative number to decrease the badge count when used with an `ios_badgeType` of `Increase`.</p>
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
<p>A custom map of data that is passed back to your app.</p> <p>Example: `{"abc": "123", "foo": "bar"}`</p>
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><br>The `id` field is required.
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
Sets the web push notification's icon. An image URL linking to a valid image. Common image types are supported; GIF will not animate. We recommend 256x256 (at least 80x80) to display well on high DPI devices. This icon is also used a default for Firefox if not provided.
firefox_icon:
stringOptional
Sets the web push notification's icon for Firefox. An image URL linking to a valid image. Common image types are supported; GIF will not animate. We recommend 256x256 (at least 80x80) to display well on high DPI devices.
url:
stringOptional
<p>The URL to open in the browser when a user clicks on the notification.</p> <p>Example: `http://www.google.com`</p>
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.
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. For iOS 10: Fires the [UNNotificationContentExtension](https://developer.apple.com/reference/usernotificationsui/unnotificationcontentextension) in your app.
ios_attachments:
objectOptional
Adds media attachments to iOS 10 notifications. Set as JSON object, key as a media id of your choice and the value as a valid local file name or URL. Example:<br>`{"id1": "https://domain.com/image.jpg"}`<br>Press and hold on the notification to view. mutable-content not required. Must be using our 2.1.1 SDK or newer.
mutable_content:
booleanOptional
iOS 10 feature used to trigger `didReceive(_:withContentHandler:)` on your [UNNotificationServiceExtension](https://developer.apple.com/reference/usernotifications/unnotificationserviceextension). This allows you to change the notification content in your app before it is displayed.
android_background_layout:
objectOptional
Allowing setting a background image for the notification. This is a JSON object containing the following keys.<br>`image` - Asset file, android resource name, or URL to remote image. recommend size: 1582x256<br>`headings_color` - Title text color ARGB Hex format. Example(Blue): `"FF0000FF"`.<br>`contents_color` - Body text color ARGB Hex format. Example(Red): `"FFFF0000"`<br>Example:<br>`{"image": "https://domain.com/background_image.jpg", "headings_color": "FFFF0000", "contents_color": "FF00FF00"}`