{"__v":90,"_id":"5540ce1d31827a0d007ab1d2","category":{"__v":17,"_id":"5540ce1c31827a0d007ab1d0","pages":["5540ce1d31827a0d007ab1d2","5540ff9dbb9e762d00f59557","554109205cf9682100d61b65","554109c35cf9682100d61b6b","55a635b6249a40190051d9a2","55bb5de0a8400c2d00873e19","55bb5f4174f10a0d002209a2","55bb607374f10a0d002209a6","55bb614f7313650d00c46e88","55bb61d8a8400c2d00873e20","55bb629874f10a0d002209aa","55bb6318a8400c2d00873e23","55bb63a07313650d00c46e8a","55d5dc84988e130d000b4110","5620b53d40e2c30d0002a848","567cfe57221af70d00fc5498","567d01fd221af70d00fc549c"],"project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T12:27:08.888Z","from_sync":false,"order":1,"slug":"remote-api","title":"Remote API"},"parentDoc":null,"project":"5540ce1b31827a0d007ab1cc","user":"5540cdbf5cf9682100d61a97","version":{"__v":31,"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","createdAt":"2015-04-29T12:27:08.390Z","releaseDate":"2015-04-29T12:27:08.390Z","categories":["5540ce1c31827a0d007ab1d0","5540d91bbb9e762d00f594ad","5540e5f131827a0d007ab212","5540e5febb9e762d00f594d3","5540e61331827a0d007ab213","5540e6195cf9682100d61afa","5540e62631827a0d007ab214","5540e63031827a0d007ab215","5540e63531827a0d007ab216","5540e63e5cf9682100d61afc","5540e6445cf9682100d61afd","5540e64a5cf9682100d61afe","55a4ff5b2e70c0250038050f","55acb28318eefd0d0071d504","55ae1abe8576b92300291c80","55ae453ef302af23000ac109","55af586d555b900d0036d296","55af91dac8a85321007a53c3","55b9fee204775a2f00628071","55b9ff0e04775a2f00628072","55b9ff4604775a2f00628073","55b9ff5fd72d1e1900276a38","55b9ff7f04775a2f00628074","55b9ff90eb08801900f833e5","55b9ffa5d72d1e1900276a39","55b9ffca04775a2f00628075","55b9fffdd72d1e1900276a3a","56bc2f033ee9e70d008b46af","56c2f6efbbf9ec2d00e0fe4f","57595bbb18760817001e8bbe","57d8d9793916800e003dde53"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["5673d6e38565060d009a86b2","5673fe024b2a680d00524ebb","56c44748dd8e400d001aff9c","57b34a28eeec08220094eaad","589b64a7291da51b004b3170","58b1d066cd7f282500fb0cc1"],"next":{"pages":[],"description":""},"createdAt":"2015-04-29T12:27:09.615Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Quick start! Check out these cool third-party libraries!\",\n  \"body\": \"PHP-Pushwoosh library by Gomoob:\\nhttp://gomoob.github.io/php-pushwoosh/\\nhttp://gomoob.github.io/php-pushwoosh/create-message.html\\n\\nPython library **by Pushwoosh**:\\nhttps://github.com/Pushwoosh/pushwoosh-python-lib\\n\\nLaravel library:\\nhttps://github.com/hoymultimedia/Laravel-Pushwoosh\\n\\nNode JS client\\nhttps://github.com/nluo/pushwoosh-node-client\\n\\nMeteor JS client\\nhttps://github.com/lpender/meteor-pushwoosh\\n\\nRails library\\nhttps://github.com/pedroandrade/pushwoosh\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"/createMessage Throttling\",\n  \"body\": \"Keep in mind that non-enterprise accounts cannot send more than 10 **/createMessage**  and/or **/createTargetedMessage** requests per second.\\n \\nHowever, if you send pushes via the **devices** parameter to **10 devices or less**, there are no restrictions for any account type.\\n\\nNote that **we always save scheduled pushes** to the Push History, even if you are sending them to less than 10 devices via devices parameter. Therefore, such pushes are also throttled.\"\n}\n[/block]\nService URL is `https://cp.pushwoosh.com/json/1.3/%method%`\nSend **POST** request with the JSON data as per API below.\nThe total size of the POST request must not exceed 10 Mb. Some methods require you to provide an Auth Token. You can create this token at the [API Access page](https://cp.pushwoosh.com/api_access) of your account.\n\nThis creates a new push notification.\n\n## Request:\nHere’s a simple request that will send a **Hello world!** push notification to all subscribers of the app:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"request\\\": {\\n        \\\"application\\\": \\\"APPLICATION_CODE\\\",\\n        \\\"auth\\\": \\\"API_ACCESS_TOKEN\\\",\\n        \\\"notifications\\\": [{\\n            \\\"send_date\\\": \\\"now\\\", // YYYY-MM-DD HH:mm  OR 'now'\\n            \\\"ignore_user_timezone\\\": true, // or false\\n            \\\"content\\\": \\\"Hello world!\\\"\\n        }]\\n    }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"\"\n    }\n  ]\n}\n[/block]\nBelow is an advanced `createMessage` request that contains *all available* parameters:\n###createMessage\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n   \\\"request\\\":{\\n      \\\"application\\\":\\\"APPLICATION_CODE\\\",\\n      \\\"applications_group\\\":\\\"GROUP_CODE\\\",   // optional. Can be used instead of \\\"application\\\"\\n      \\\"auth\\\": \\\"API_ACCESS_TOKEN\\\",\\n      \\\"notifications\\\":[\\n         {\\n            // Content settings \\n            \\\"send_date\\\":\\\"now\\\",             // YYYY-MM-DD HH:mm  OR 'now'\\n            \\\"ignore_user_timezone\\\": true,  // or false\\n            \\\"timezone\\\":\\\"America/New_York\\\", // optional, if ignored UTC-0 is default in \\\"send_date\\\". See http://php.net/manual/timezones.php for supported timezones\\n            \\\"campaign\\\":\\\"CAMPAIGN_CODE\\\",    // optional. Campaign code to which you want to assign this push message\\n            \\\"content\\\":{                    // object( language1: 'content1', language2: 'content2' ) OR string. Ignored for Windows 8, use \\\"wns_content\\\" instead. (Use \\\\n for multiline text. Ex: \\\"hello\\\\nfriend\\\")\\n               \\\"en\\\":\\\"English\\\",\\n               \\\"ru\\\":\\\"Русский\\\",\\n               \\\"de\\\":\\\"Deutsch\\\"\\n            }, \\n            \\\"page_id\\\": 39,                 // optional. HTML Pages. integer\\n            \\\"rich_page_id\\\": 42,            // optional. Rich Pages. integer\\n            \\\"rich_media\\\": \\\"XXXX-XXXX\\\",     // optional. Rich Media code. string\\n            \\\"remote_page\\\" : \\\"http://myremoteurl.com\\\",  // Remote Rich HTML Page URL. <scheme>://<authority>\\n            \\\"link\\\": \\\"http://google.com\\\",   // optional, string. For deeplinks add \\\"minimize_link\\\":0\\n            \\\"minimize_link\\\": 0,            // optional. False or 0 — do not minimize, 1 — Google, 2 — bitly. Default = 1 \\n            \\\"data\\\": {\\\"key\\\":\\\"value\\\"},       // JSON string or JSON object, will be passed as \\\"u\\\" parameter in the payload (converted to JSON string)\\n            \\\"platforms\\\": [1,2,3,5,7,8,9,10,11,12], // 1 — iOS; 2 — BB; 3 — Android; 5 — Windows Phone; 7 — OS X; 8 — Windows 8; 9 — Amazon; 10 — Safari; 11 — Chrome; 12 — Firefox\\n            \\\"preset\\\":\\\"Q1A2Z-6X8SW\\\",        // Push Preset Code from your Control Panel\\n            \\\"send_rate\\\": 100,              // throttling. Valid values are from 100 to 1000 pushes/second.\\n            \\\"devices\\\": [\\\"dec301908b9ba8df85e57a58e40f96f523f4c2068674f5fe2ba25cdc250a2a41\\\"], // Optional. Specify tokens or hwids to send targeted push notifications. Not more than 1000 tokens/hwids in an array. If set, the message will only be sent to the devices on the list. Ignored if the Applications Group is used. iOS push tokens can only be lower case.\\n           \\n            // user-centric push notifications\\n            \\\"users\\\":[\\\"user_3078a\\\"],       // optional. Enterprise API. If set, message will only be delivered to the specified users Id's (specified via /registerUser call). If specified together with devices parameter, the latter will be ignored.\\n\\n            //filters and conditions\\n            \\\"filter\\\": \\\"FILTER_NAME\\\",       // optional.\\n            \\\"conditions\\\": [TAG_CONDITION1, TAG_CONDITION2, ..., TAG_CONDITIONN], //Optional. See remark\\n \\n            // iOS related\\n            \\\"ios_badges\\\": 5,     // Optional, integer. iOS application badge number. Use \\\"+n\\\" or \\\"-n\\\" to increment/decrement the badge value by n\\n            \\\"ios_sound\\\": \\\"sound file.wav\\\",    // Optional. Sound file name in the main bundle of application. If left empty, the device will produce no sound upon receiving a push\\n            \\\"ios_ttl\\\": 3600, // optional. Time to live parameter — maximum message lifespan in seconds\\n            \\\"ios_category_id\\\": \\\"1\\\",       // Optional. Integer. iOS8 category ID from Pushwoosh\\n            \\\"ios_root_params\\\" : {\\\"aps\\\":{\\\"content-available\\\": \\\"1\\\"} , \\\"data\\\": << User supplied data, max of 4KB>> }, // Optional — root level parameters to the aps dictionary\\n            \\\"apns_trim_content\\\":1,     // Optional. (0|1) Trims the exceeding content strings with ellipsis\\n            \\\"ios_trim_content\\\": 1,       // Deprecated, use \\\"apns_trim_content\\\" instead.\\n           \\n            // Android related\\n            \\\"android_root_params\\\": {\\\"key\\\": \\\"value\\\"}, // custom key-value object. root level parameters for the android payload recipients\\n            \\\"android_sound\\\" : \\\"soundfile\\\", // Optional. No file extension. If left empty, the device will produce no sound upon receiving a push\\n            \\\"android_header\\\":\\\"header\\\",    // Optional. Android notification header\\n            \\\"android_icon\\\": \\\"icon\\\",\\n            \\\"android_custom_icon\\\": \\\"http://example.com/image.png\\\", // Optional. Full path URL to the image file\\n            \\\"android_banner\\\": \\\"http://example.com/banner.png\\\", // Optional. Full path URL to the image file\\n            \\\"android_badges\\\": 5, // optional, integer. Android application icon badge number. Use \\\"+n\\\" or \\\"-n\\\" to increment/decrement the badge value by n\\n            \\\"android_gcm_ttl\\\": 3600, // optional. Time to live parameter — maximum message lifespan oin seconds\\n \\n            \\\"android_vibration\\\": 0,   // Android force-vibration for high-priority pushes, boolean\\n            \\\"android_led\\\":\\\"#rrggbb\\\",  // LED hex color, device will do its best approximation\\n            \\\"android_priority\\\":-1,  // priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2\\n            \\\"android_ibc\\\":\\\"#RRGGBB\\\",  // icon background color on Lollipop, #RRGGBB, #AARRGGBB, \\\"red\\\", \\\"black\\\", \\\"yellow\\\", etc.\\n \\n            // Amazon related\\n            \\\"adm_root_params\\\": {\\\"key\\\": \\\"value\\\"}, // custom key-value object\\n            \\\"adm_sound\\\": \\\"push.mp3\\\",\\n            \\\"adm_header\\\": \\\"Header\\\",\\n            \\\"adm_icon\\\": \\\"icon\\\",\\n            \\\"adm_custom_icon\\\": \\\"http://example.com/image.png\\\",\\n            \\\"adm_banner\\\": \\\"http://example.com/banner.png\\\",\\n            \\\"adm_ttl\\\": 3600, // optional. Time to live parameter — the maximum message lifespan in seconds\\n            \\\"adm_priority\\\":-1,  // priority of the push in Amazon push drawer, valid values are -2, -1, 0, 1 and 2\\n \\n            // Windows Phone related.\\n            \\\"wp_type\\\": \\\"Tile\\\",           // Windows Phone notification type. 'Tile' or 'Toast'. Raw notifications are not supported. 'Tile' if default \\n            \\\"wp_background\\\": \\\"/Resources/Red.jpg\\\", // tile image\\n            \\\"wp_backbackground\\\": \\\"/Resources/Green.jpg\\\", // back tile image\\n            \\\"wp_backtitle\\\": \\\"back title\\\",  // back tile title \\n            \\\"wp_backcontent\\\": \\\"back content\\\",  // back tile content\\n            \\\"wp_count\\\": 3,               // optional. Integer. Badge for Windows Phone notification\\n \\n            // BlackBerry related.\\n            \\\"blackberry_header\\\": \\\"header\\\",           // BlackBerry header, applicable to BB10 Series devices\\n \\n            // Mac OS X related\\n            \\\"mac_badges\\\": 3,\\n            \\\"mac_sound\\\": \\\"sound.caf\\\",\\n            \\\"mac_root_params\\\": {\\\"content-available\\\":1},\\n            \\\"mac_ttl\\\": 3600, // Optional. Time to live parameter — maximum message lifespan in seconds\\n \\n            // WNS related\\n            \\\"wns_content\\\": { // Content (XML or raw) of notification encoded in MIME's base64 in form of Object( language1: 'content1', language2: 'content2' ) OR String\\n               \\\"en\\\": \\\"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==\\\",\\n               \\\"de\\\": \\\"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4=\\\"\\n            },\\n            \\\"wns_type\\\": \\\"Badge\\\", // 'Tile' | 'Toast' | 'Badge' | 'Raw'\\n            \\\"wns_tag\\\": \\\"myTag\\\", // optional. Used in Tile replacement policy. An alphanumeric string of no more than 16 characters.\\n            \\\"wns_cache\\\": 1, // optional. (1|0) Translates into X-WNS-Cache-Policy value\\n            \\\"wns_ttl\\\": 600, // optional. Expiration time for notification in seconds\\n             // Safari related\\n            \\\"safari_title\\\": \\\"Title\\\", // obligatory, title of the notification\\n            \\\"safari_action\\\": \\\"Click here\\\", // optional\\n            \\\"safari_url_args\\\": [\\\"firstArgument\\\", \\\"secondArgument\\\"], // Obligatory, but the value may be empty\\n            \\\"safari_ttl\\\": 3600, // optional. Time to live parameter — the maximum lifespan of a message in seconds\\n           \\n            // Chrome related \\n            \\\"chrome_title\\\":\\\"\\\", // optional. You can specify the header of the message in this parameter\\n            \\\"chrome_icon\\\":\\\"\\\", // full path URL to the icon or extension resources file path\\n            \\\"chrome_gcm_ttl\\\": 3600, // Optional. Time to live parameter – maximum message lifespan in seconds\\n           \\n            // Firefox-related \\n            \\\"firefox_title\\\":\\\"\\\", // optional. You can specify message header here\\n            \\\"firefox_icon\\\":\\\"\\\", // full path URL to the icon or path to the file in extension resources \\n         }\\n      ]\\n   }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n## Response:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"HTTP Status code\",\n    \"h-1\": \"status_code\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"200\",\n    \"1-0\": \"200\",\n    \"2-0\": \"400\",\n    \"3-0\": \"500\",\n    \"0-1\": \"200\",\n    \"1-1\": \"210\",\n    \"2-1\": \"N/A\",\n    \"3-1\": \"500\",\n    \"0-2\": \"Message successfully created\",\n    \"1-2\": \"Argument error. See status_message for more info\",\n    \"2-2\": \"Malformed request string\",\n    \"3-2\": \"Internal error\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n## Debug Mode\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Debug Mode\",\n  \"body\": \"For load balancing purposes *we do not store messages sent through API with the “devices” parameter that contains less than 10 devices in an array*. Due to this, such messages will not be displayed in your Push History.\\n\\nTo see push reports during the testing phase, there’s **Debug Mode**. Turning Debug Mode **ON** allows you to *override this limit for 1 hour and save such pushes in the push history*. Debug mode turns OFF automatically after 1 hour.\\n\\nDebug Mode can be activated on the [Push History](https://cp.pushwoosh.com/notifications) page by switching the toggle in the upper right corner.\\n\\nIf the Debug Mode is turned OFF, and you send a /createMessage request with less than 10 device tokens to Pushwoosh API, the server will return a `“CODE_NOT_AVAILABLE”` value for `“Messages”`, and an empty key for Unknown Devices instead of Message Code unless the message is scheduled to be sent in the future with the `\\\"send_date\\\"` parameter.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Parameters\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"auth\",\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Description\",\n    \"0-2\": \"API access token from the Pushwoosh control panel (create this token at https://cp.pushwoosh.com/api_access)\",\n    \"0-1\": \"API access token from the Pushwoosh control panel (create this token at https://cp.pushwoosh.com/api_access)\",\n    \"1-0\": \"application\",\n    \"1-2\": \"your Pushwoosh application ID where you send the message to (cannot be used together with “applications_group”)\",\n    \"2-0\": \"applications_group\",\n    \"2-2\": \"your Pushwoosh Application group code (cannot be used together with “application”)\",\n    \"3-0\": \"content\",\n    \"3-2\": \"is the text push message delivered to the application\",\n    \"4-0\": \"data\",\n    \"4-2\": \"use this only if you want to pass custom data to the application (JSON format) or omit this parameter. Please note that Mac OSX push is limited to 256 bytes\",\n    \"5-0\": \"page_id\",\n    \"5-2\": \"HTML page id (created from Application’s HTML Pages). Use this if you want to deliver additional HTML content to the application or omit this parameter\",\n    \"6-0\": \"send_date\",\n    \"6-2\": \"set the time you want the message to be sent (in UTC) or use ‘now’ to send it immediately\",\n    \"7-0\": \"wp_count\",\n    \"7-2\": \"sets the badge for WP7 platform\",\n    \"8-0\": \"ios_badges\",\n    \"8-2\": \"sets the badge on the icon for iOS platform. This value will be sent to ALL devices given in the “devices” list.\",\n    \"9-0\": \"devices\",\n    \"9-2\": \"omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs as described\",\n    \"12-0\": \"ios_root_params\",\n    \"12-2\": \"root level parameters to the aps dictionary. For example to use with NewsStand apps.\",\n    \"1-1\": \"your Pushwoosh application ID where you send the message to (cannot be used together with “applications_group”)\",\n    \"2-1\": \"your Pushwoosh Application group code (cannot be used together with “application”)\",\n    \"3-1\": \"the text push message delivered to the application\",\n    \"4-1\": \"use this only if you want to pass custom data to the application (JSON format) or omit this parameter. Please note that Mac OSX push is limited to 256 bytes\",\n    \"5-1\": \"HTML page id (created from Application’s HTML Pages). Use this if you want to deliver additional HTML content to the application or omit this parameter\",\n    \"6-1\": \"set the time you want the message to be sent (in UTC) or use ‘now’ to send it immediately\",\n    \"7-1\": \"sets the badge for WP7 platform\",\n    \"8-1\": \"sets the badge on the icon for iOS platform. This value will be sent to ALL devices given in the “devices” list.\",\n    \"9-1\": \"omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs as described\",\n    \"12-1\": \"root level parameters to the aps dictionary. For example to use with NewsStand apps.\",\n    \"13-0\": \"conditions\",\n    \"13-1\": \"see [below](http://docs.pushwoosh.com/docs/createmessage#tag-conditions)\",\n    \"11-0\": \"send_rate\",\n    \"11-1\": \"keep in mind that parameters \\\"send_rate\\\" and \\\"devices\\\" should not be used simulatneously in a single /createMessage request. Send rate throttling cannot be applied to messages sent to raw device tokens, only to bulk pushes or pushes with filter.\",\n    \"10-0\": \"users\",\n    \"10-1\": \"user-centric push notifications. If set, message will only be delivered to the specified users Id's (specified via /registerUser call). If specified together with the devices parameter, the latter will be ignored. Push notification will be delivered to the last used user's device.\"\n  },\n  \"cols\": 2,\n  \"rows\": 14\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Tag conditions\"\n}\n[/block]\nEach tag condition is an array like `[tagName, operator, operand]` where\n\n* tagName: name of a tag\n* operator: \"EQ\" | \"IN\" | \"NOTEQ\" | \"NOTIN\" | \"LTE\" | \"GTE\" | \"BETWEEN\"\n* operand: string | integer | array | date\n \n## Operand description\n\n- EQ: tag value is equal to operand;\n- IN: tag value intersects with operand (operand must always be an array);\n- NOTEQ: tag value is not equal to an operand;\n- NOTIN: tag value does not intersect with operand (operand must always be an array);\n- GTE: tag value is greater than or equal to operand;\n- LTE: tag value is less than or equal to operand;\n- BETWEEN: tag value is greater than or equal to min operand value but less than or equal to max operand value (operand must always be an array).\n\n## String tags\n\nValid operators: EQ, IN, NOTEQ, NOTIN\nValid operands:\n- EQ, NOTEQ: operand must be a string;\n- IN, NOTIN: operand must be an array of strings like `[\"value 1\", \"value 2\", \"value N\"]`;\n\n## Integer tags\n\nValid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE\nValid operands:\n- EQ, NOTEQ, GTE, LTE: operand must be an integer;\n- IN, NOTIN: operand must be an array of integers like `[value 1, value 2, value N]`;\n- BETWEEN: operand must be an array of integers like `[min_value, max_value]`.\n\n## Date tags\n\nValid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE\nValid operands: `\"YYYY-MM-DD 00:00\"` (string), unix timestamp like `1234567890` (integer)\n\n## Boolean tags\n\nValid operators: EQ\nValid operands: `0, 1, true, false`\n\n## List tags\n\nValid operators: IN\nValid operands: operand must be an array of strings like `[\"value 1\", \"value 2\", \"value N\"]`.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"Remember that “filter” and “conditions” parameters should not be used together.\\nAlso, both of them **will be ignored**, if the \\\"devices\\\" parameter is used in the same request.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Country and Language tags\",\n  \"body\": \"Language tag value is a lowercase two-letter code according to [ISO-639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)\\nCountry tag value is an UPPERCASE two-letter code according to [ISO_3166-2](http://en.wikipedia.org/wiki/ISO_3166-2)\\nFor example, to send push a notification to Portuguese-speaking subscribers in Brazil, you will need to specify the following condition: `\\\"conditions\\\": [[\\\"Country\\\", \\\"EQ\\\", \\\"BR\\\"],[\\\"Language\\\", \\\"EQ\\\", \\\"pt\\\"]]`\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"/createMessage snippets\"\n}\n[/block]\nSample `/createMessage` requests in BASH, PHP, Erlang, Ruby, Java and Python:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#!/bin/bash\\n \\n#Usage\\nif [ ! -n \\\"$1\\\" ] || [ ! -n \\\"$2\\\" ]\\nthen\\n  echo \\\"`basename $0` usage: api_token appid message\\\";\\n  exit 1;\\nfi;\\nMESSAGE=\\\"$3\\\";\\nif [ -z \\\"$3\\\" ]\\nthen\\nMESSAGE='One push to rule them all!'\\nfi;\\n \\necho -e \\\"Response:\\\"\\ncurl --data-binary \\\"\\n{\\\\\\\"request\\\\\\\":\\n    {\\\\\\\"application\\\\\\\":\\\\\\\"$2\\\\\\\",\\n     \\\\\\\"auth\\\\\\\":\\\\\\\"$1\\\\\\\",\\n     \\\\\\\"notifications\\\\\\\":\\n        [{\\n                        \\\\\\\"send_date\\\\\\\": \\\\\\\"now\\\\\\\",\\n            \\\\\\\"content\\\\\\\": \\\\\\\"$MESSAGE\\\\\\\"\\n        }]\\n    }\\n}\\\" \\\\\\n-H \\\"Content-type: application/json\\\" \\\\\\n\\\"https://cp.pushwoosh.com/json/1.3/createMessage\\\"\\necho\\\"\\\";\\nexit 0;\",\n      \"language\": \"java\",\n      \"name\": \"BASH\"\n    },\n    {\n      \"code\": \"<?php \\ndefine('PW_AUTH', 'API TOKEN');\\ndefine('PW_APPLICATION', 'APPLICATION CODE');\\ndefine('PW_DEBUG', true);\\n \\nfunction pwCall($method, $data) {\\n    $url = 'https://cp.pushwoosh.com/json/1.3/' . $method;\\n    $request = json_encode(['request' => $data]);\\n \\n    $ch = curl_init($url);\\n    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\\n    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);\\n    curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');\\n    curl_setopt($ch, CURLOPT_HEADER, true);\\n    curl_setopt($ch, CURLOPT_POST, true);\\n    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);\\n \\n    $response = curl_exec($ch);\\n    $info = curl_getinfo($ch);\\n    curl_close($ch);\\n \\n    if (defined('PW_DEBUG') && PW_DEBUG) {\\n        print \\\"[PW] request: $request\\\\n\\\";\\n        print \\\"[PW] response: $response\\\\n\\\";\\n        print '[PW] info: ' . print_r($info, true);\\n    }\\n}\\n \\npwCall('createMessage', array(\\n    'application' => PW_APPLICATION,\\n    'auth' => PW_AUTH,\\n    'notifications' => array(\\n            array(\\n                'send_date' => 'now',\\n                'content' => 'test',\\n                'data' => array('custom' => 'json data'),\\n                'link' => 'http://pushwoosh.com/'\\n            )\\n        )\\n    )\\n);\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"-module(pushwoosh).\\n-export([run/0, stop/0, sendMessage/1]).\\n%% sendMessage argument: message text %%\\n \\n%% Authentication & App_id %%\\n-define(PW_AUTH, \\\"YOUR_AUTH_TOKEN\\\").\\n-define(PW_APPLICATION, \\\"YOUR_PUSHWOOSH_APP_CODE\\\").\\n \\n%% KickStart %%\\nrun() ->\\n    application:start(unicode),\\n    application:start(crypto),\\n    application:start(public_key),\\n    application:start(ssl),\\n    application:start(inets),\\n    %% HTTP Client verbosity options flase, verbose, debug\\n    httpc:set_options([{verbose, false}]).  \\nstop() ->\\n    application:stop(ssl),\\n    application:stop(public_key),       \\n    application:stop(crypto),\\n    application:stop(inets).\\n%% JSON Wars !\\nencode(S) -> encode(S, [$\\\"]).\\nencode([], Acc) -> lists:reverse([$\\\" | Acc]);\\nencode([C | Cs], Acc) ->\\n        Hex = lists:flatten(io_lib:format(\\\"~4.16.0b\\\", [C])),\\n        encode(Cs, lists:reverse(Hex) ++ \\\"u\\\\\\\\\\\" ++ Acc).\\n \\nsendMessage(Message_text) ->\\n    %% URL to JSON API 1.3\\n    Url = \\\"https://cp.pushwoosh.com/json/1.3/createMessage\\\",\\n    EncodedMessage = encode(Message_text),\\n    {ok, Response} = httpc:request(\\n        %%Method \\n        post, \\n        %%Request\\n        {Url, [{\\\"User-Agent\\\", \\\"Erlang exemple\\\"}], \\\"application/json; charset=UTF-8\\\", \\n        \\\"{\\\\\\\"request\\\\\\\":{\\n        \\\\\\\"application\\\\\\\": \\\\\\\"\\\"?PW_APPLICATION\\\"\\\\\\\",\\n        \\\\\\\"auth\\\\\\\": \\\\\\\"\\\"?PW_AUTH\\\"\\\\\\\",\\n        \\\\\\\"notifications\\\\\\\": [{\\n        \\\\\\\"send_date\\\\\\\": \\\\\\\"now\\\\\\\",\\n        \\\\\\\"content\\\\\\\": \\\"++EncodedMessage++\\\"\\n        }]}}\\\"},\\n        %%HTTP options\\n        [{ssl,[{verify, verify_none}]}, {version, \\\"HTTP/1.0\\\"}],\\n        %%Options\\n        []),\\n    io:format(\\\"And received ~p\\\", [Response]).\",\n      \"language\": \"erlang\"\n    },\n    {\n      \"code\": \"class PushNotification\\n \\n  #- PushWoosh API Documentation http://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/ \\n  #- Two methods here:\\n  #     - PushNotification.new.notify_all(message) Notifies all with the same option\\n  #     - PushNotification.new.notify_devices(notification_options = {}) Notifies specific devices with custom options\\n \\n  include HTTParty #Make sure to have the HTTParty gem declared in your gemfile https://github.com/jnunemaker/httparty\\n  default_params :output => 'json'\\n  format :json\\n \\n  def initialize\\n    #- Change to your settings\\n    :::at:::auth = {:application  => \\\"00000-00000\\\",:auth => \\\"auth_token\\\"}\\n  end\\n \\n  # PushNotification.new.notify_all(\\\"This is a test notification to all devices\\\")\\n  def notify_all(message)\\n    notify_devices({:content  => message})\\n  end\\n \\n  # PushNotification.new.notify_device({\\n  #  :content  => \\\"TEST\\\",\\n  #  :data  => {:custom_data  => value},\\n  #  :devices  => array_of_tokens\\n  #})\\n  def notify_devices(notification_options = {})\\n    #- Default options, uncomment :data or :devices if needed\\n    default_notification_options = {\\n                        # YYYY-MM-DD HH:mm  OR 'now'\\n                        :send_date  => \\\"now\\\",\\n                        # Object( language1: 'content1', language2: 'content2' ) OR string\\n                        :content  => {\\n                            :fr  => \\\"Test\\\",\\n                            :en  => \\\"Test\\\"\\n                        },\\n                        # JSON string or JSON object \\\"custom\\\": \\\"json data\\\"\\n                        #:data  => {\\n                        #    :custom_data  => value\\n                        #},\\n                        # omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs\\n                        #:devices  => {}\\n                      }\\n \\n    #- Merging with specific options\\n    final_notification_options = default_notification_options.merge(notification_options)\\n \\n    #- Constructing the final call\\n    options = @auth.merge({:notifications  => [final_notification_options]})\\n    options = {:request  => options}                                                                                                                             \\n    #- Executing the POST API Call with HTTPARTY - :body => options.to_json allows us to send the json as an object instead of a string\\n    response = self.class.post(\\\"https://cp.pushwoosh.com/json/1.3/createMessage\\\", :body  => options.to_json,:headers => { 'Content-Type' => 'application/json' })\\n  end\\nend\",\n      \"language\": \"ruby\"\n    },\n    {\n      \"code\": \"// Uses JSON classes from http://json.org/java/\\n\\npackage com.arellomobile;\\n \\nimport org.json.*;\\nimport java.io.*;\\nimport java.net.*;\\n \\npublic class SendPushNotificationSample\\n{\\n    public static final String PUSHWOOSH_SERVICE_BASE_URL = \\\"https://cp.pushwoosh.com/json/1.3/\\\";\\n    private static final String AUTH_TOKEN = \\\"YOUR_AUTH_TOKEN\\\";\\n    private static final String APPLICATION_CODE = \\\"PW_APPLICATION_CODE\\\";\\n \\n    public static void main(String[] args) throws JSONException, MalformedURLException\\n    {\\n        String method = \\\"createMessage\\\";\\n        URL url = new URL(PUSHWOOSH_SERVICE_BASE_URL + method);\\n \\n        JSONArray notificationsArray = new JSONArray()\\n                .put(new JSONObject().put(\\\"send_date\\\", \\\"now\\\")\\n                                     .put(\\\"content\\\", \\\"test\\\")\\n                                     .put(\\\"link\\\", \\\"http://pushwoosh.com/\\\"));\\n \\n        JSONObject requestObject = new JSONObject()\\n                .put(\\\"application\\\", APPLICATION_CODE)\\n                .put(\\\"auth\\\", AUTH_TOKEN)\\n                .put(\\\"notifications\\\", notificationsArray);\\n \\n        JSONObject mainRequest = new JSONObject().put(\\\"request\\\", requestObject);\\n        JSONObject response = SendServerRequest.sendJSONRequest(url, mainRequest.toString());\\n \\n        System.out.println(\\\"Response is: \\\" + response);\\n    }\\n}\\n \\nclass SendServerRequest\\n{\\n    static JSONObject sendJSONRequest(URL url, String request)\\n    {\\n        HttpURLConnection connection = null;\\n        try\\n        {\\n            connection = (HttpURLConnection) url.openConnection();\\n            connection.setRequestMethod(\\\"POST\\\");\\n            connection.setRequestProperty(\\\"Content-Type\\\", \\\"application/json\\\");\\n            connection.setDoInput(true);\\n            connection.setDoOutput(true);\\n \\n            DataOutputStream writer = new DataOutputStream(connection.getOutputStream());\\n            writer.write(request.getBytes(\\\"UTF-8\\\"));\\n            writer.flush();\\n            writer.close();\\n \\n            return parseResponse(connection);\\n        }\\n        catch (Exception e)\\n        {\\n            System.out.println(\\\"An error occurred: \\\" + e.getMessage());\\n            return null;\\n        }\\n        finally\\n        {\\n            if (connection != null)\\n            {\\n                connection.disconnect();\\n            }\\n        }\\n    }\\n \\n    static JSONObject parseResponse(HttpURLConnection connection) throws IOException, JSONException\\n    {\\n        String line;\\n        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));\\n        StringBuilder response = new StringBuilder();\\n \\n        while ((line = reader.readLine()) != null)\\n        {\\n            response.append(line).append('\\\\r');\\n        }\\n        reader.close();\\n \\n        return new JSONObject(response.toString());\\n    }\\n}\",\n      \"language\": \"java\"\n    },\n    {\n      \"code\": \"import json\\n \\nPW_AUTH = 'API TOKEN'\\nPW_APPLICATION_CODE = 'APPLICATION CODE'\\n \\ntry:\\n    # For Python 3.0 and later\\n    from urllib.request import urlopen\\n    from urllib.request import Request\\nexcept ImportError:\\n    # Fall back to Python 2's urllib2\\n    from urllib2 import urlopen\\n    from urllib2 import Request\\n \\ndef pw_call(method, data):\\n    url = 'https://cp.pushwoosh.com/json/1.3/' + method\\n    data = json.dumps({'request': data})\\n    req = Request(url, data.encode('UTF-8'), {'Content-Type': 'application/json'})\\n    try:\\n        f = urlopen(req)\\n        response = f.read()\\n        f.close()\\n        print('Pushwoosh response: ' + str(response))\\n    except Exception as e:\\n        print ('Request error: ' + str(e))\\n \\nif __name__ == '__main__':\\n    pw_call('createMessage', {\\n        'auth': PW_AUTH,\\n        'application': PW_APPLICATION_CODE,\\n        'notifications': [\\n            {\\n                'send_date': 'now',\\n                'content': 'test',\\n                'data': {\\\"custom\\\": \\\"json data\\\"},\\n                'link': 'http://pushwoosh.com'\\n            }\\n        ]\\n    }\\n    )\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"using System;\\nusing System.IO;\\nusing System.Net;\\nusing Newtonsoft.Json.Linq;\\n\\nnamespace WebApplication1\\n{\\n   public partial class Default : System.Web.UI.Page\\n   {\\n       protected void Page_Load(object sender, EventArgs e)\\n       {\\n           string pwAuth = \\\"YOUR_AUTH_TOKEN\\\";\\n           string pwApplication = \\\"PW_APPLICATION_CODE\\\";\\n           JObject json = new JObject(\\n               new JProperty(\\\"application\\\", pwApplication),\\n               new JProperty(\\\"auth\\\", pwAuth),\\n               new JProperty(\\\"notifications\\\",\\n                   new JArray(\\n                       new JObject(\\n                           new JProperty(\\\"send_date\\\", \\\"now\\\"),\\n                           new JProperty(\\\"content\\\", \\\"test\\\"),\\n                           new JProperty(\\\"wp_type\\\", \\\"Toast\\\"),\\n                           new JProperty(\\\"wp_count\\\", 3),\\n                           new JProperty(\\\"data\\\",\\n                               new JObject(\\n                                   new JProperty(\\\"custom\\\", \\\"json data\\\"))),\\n                           new JProperty(\\\"link\\\", \\\"http://pushwoosh.com/\\\"),\\n                           new JProperty(\\\"conditions\\\",\\n                               new JArray(\\n                                   (object)new JArray(\\\"Color\\\", \\\"EQ\\\", \\\"black\\\")))))));\\n           PWCall(\\\"createMessage\\\", json);\\n       }\\n       private void PWCall(string action, JObject data)\\n       {\\n           Uri url = new Uri(\\\"https://cp.pushwoosh.com/json/1.3/\\\" + action);\\n           JObject json = new JObject(new JProperty(\\\"request\\\", data));\\n           DoPostRequest(url, json);\\n       }\\n       private void DoPostRequest(Uri url, JObject data)\\n       {\\n           HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);\\n           req.ContentType = \\\"text/json\\\";\\n           req.Method = \\\"POST\\\";\\n           using (var streamWriter = new StreamWriter(req.GetRequestStream()))\\n           {\\n               streamWriter.Write(data.ToString());\\n           }\\n           HttpWebResponse httpResponse;\\n           try\\n           {\\n               httpResponse = (HttpWebResponse)req.GetResponse();\\n           }\\n           catch (Exception exc)\\n           {\\n               throw new Exception(string.Format(\\\"Problem with {0}, {1}\\\", url, exc.Message));\\n           }\\n           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))\\n           {\\n               var responseText = streamReader.ReadToEnd();\\n               Page.Response.Write(responseText);\\n           }\\n       }\\n   }\\n}\",\n      \"language\": \"csharp\",\n      \"name\": \".NET\"\n    },\n    {\n      \"code\": \"package main\\n\\nimport\\n(\\n\\t\\\"fmt\\\"\\n\\t\\\"encoding/json\\\"\\n\\t\\\"net/http\\\"\\n\\t\\\"bytes\\\"\\n\\t\\\"io/ioutil\\\"\\n)\\n\\nconst (\\n\\tPW_APPLICATION = \\\"APPLICATION CODE\\\"\\n\\tPW_AUTH = \\\"API TOKEN\\\"\\n\\tPW_ENDPOINT = \\\"https://cp.pushwoosh.com/json/1.3/\\\"\\n)\\n\\nfunc pwCall(method string, data []byte) (bool) {\\n\\turl := PW_ENDPOINT + method\\n\\trequest, err := http.NewRequest(\\\"POST\\\", url, bytes.NewBuffer(data))\\n\\trequest.Header.Set(\\\"Content-Type\\\", \\\"application/json\\\")\\n\\n\\tclient := http.Client{}\\n\\tresponse, err := client.Do(request)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Error occur: \\\" + err.Error())\\n\\t\\treturn false\\n\\t}\\n\\tdefer response.Body.Close()\\n\\n\\tfmt.Println(\\\"Response Status: \\\", response.Status)\\n\\tif (response.StatusCode == 200) {\\n\\t\\tbody, _ := ioutil.ReadAll(response.Body)\\n\\t\\tfmt.Println(\\\"Response Body: \\\", string(body))\\n\\t\\treturn true\\n\\t}\\n\\treturn false\\n}\\n\\nfunc main() {\\n\\trequestData := map[string]interface{}{\\n\\t\\t\\\"request\\\": map[string]interface{} {\\n\\t\\t\\t\\\"auth\\\": PW_AUTH,\\n\\t\\t\\t\\\"application\\\": PW_APPLICATION,\\n\\t\\t\\t\\\"notifications\\\": []interface{}{\\n\\t\\t\\t\\tmap[string]interface{} {\\n\\t\\t\\t\\t\\t\\\"send_date\\\": \\\"now\\\",\\n\\t\\t\\t\\t\\t\\\"content\\\": \\\"test\\\",\\n\\t\\t\\t\\t\\t\\\"link\\\": \\\"https://pushwoosh.com\\\",\\n\\t\\t\\t\\t},\\n\\t\\t\\t},\\n\\t\\t},\\n\\t}\\n\\tjsonRequest, _ := json.Marshal(requestData)\\n\\trequestString := string(jsonRequest)\\n\\tfmt.Println(\\\"Request body: \\\" + requestString)\\n\\n\\tpwCall(\\\"createMessage\\\", jsonRequest)\\n}\",\n      \"language\": \"go\"\n    },\n    {\n      \"code\": \"$.ajax({\\n    type: \\\"POST\\\",\\n    url: \\\"https://cp.pushwoosh.com/json/1.3/createMessage\\\",\\n    data: JSON.stringify({\\n        \\\"request\\\": {\\n            \\\"application\\\": \\\"APPLICATION CODE\\\",\\n            \\\"auth\\\": \\\"API TOKEN\\\",\\n            \\\"notifications\\\": [{\\n                \\\"send_date\\\": \\\"now\\\",\\n                \\\"ignore_user_timezone\\\": true,\\n                \\\"content\\\": \\\"Hello world!\\\"\\n            }]\\n        }\\n    }),\\n    dataType: \\\"json\\\"\\n}).done(function(data) {\\n    console.log(data);\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Javascript(JQuery)\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"createmessage","type":"basic","title":"/createMessage"}
[block:callout] { "type": "success", "title": "Quick start! Check out these cool third-party libraries!", "body": "PHP-Pushwoosh library by Gomoob:\nhttp://gomoob.github.io/php-pushwoosh/\nhttp://gomoob.github.io/php-pushwoosh/create-message.html\n\nPython library **by Pushwoosh**:\nhttps://github.com/Pushwoosh/pushwoosh-python-lib\n\nLaravel library:\nhttps://github.com/hoymultimedia/Laravel-Pushwoosh\n\nNode JS client\nhttps://github.com/nluo/pushwoosh-node-client\n\nMeteor JS client\nhttps://github.com/lpender/meteor-pushwoosh\n\nRails library\nhttps://github.com/pedroandrade/pushwoosh" } [/block] [block:callout] { "type": "warning", "title": "/createMessage Throttling", "body": "Keep in mind that non-enterprise accounts cannot send more than 10 **/createMessage** and/or **/createTargetedMessage** requests per second.\n \nHowever, if you send pushes via the **devices** parameter to **10 devices or less**, there are no restrictions for any account type.\n\nNote that **we always save scheduled pushes** to the Push History, even if you are sending them to less than 10 devices via devices parameter. Therefore, such pushes are also throttled." } [/block] Service URL is `https://cp.pushwoosh.com/json/1.3/%method%` Send **POST** request with the JSON data as per API below. The total size of the POST request must not exceed 10 Mb. Some methods require you to provide an Auth Token. You can create this token at the [API Access page](https://cp.pushwoosh.com/api_access) of your account. This creates a new push notification. ## Request: Here’s a simple request that will send a **Hello world!** push notification to all subscribers of the app: [block:code] { "codes": [ { "code": "{\n \"request\": {\n \"application\": \"APPLICATION_CODE\",\n \"auth\": \"API_ACCESS_TOKEN\",\n \"notifications\": [{\n \"send_date\": \"now\", // YYYY-MM-DD HH:mm OR 'now'\n \"ignore_user_timezone\": true, // or false\n \"content\": \"Hello world!\"\n }]\n }\n}", "language": "json", "name": "" } ] } [/block] Below is an advanced `createMessage` request that contains *all available* parameters: ###createMessage [block:code] { "codes": [ { "code": "{\n \"request\":{\n \"application\":\"APPLICATION_CODE\",\n \"applications_group\":\"GROUP_CODE\", // optional. Can be used instead of \"application\"\n \"auth\": \"API_ACCESS_TOKEN\",\n \"notifications\":[\n {\n // Content settings \n \"send_date\":\"now\", // YYYY-MM-DD HH:mm OR 'now'\n \"ignore_user_timezone\": true, // or false\n \"timezone\":\"America/New_York\", // optional, if ignored UTC-0 is default in \"send_date\". See http://php.net/manual/timezones.php for supported timezones\n \"campaign\":\"CAMPAIGN_CODE\", // optional. Campaign code to which you want to assign this push message\n \"content\":{ // object( language1: 'content1', language2: 'content2' ) OR string. Ignored for Windows 8, use \"wns_content\" instead. (Use \\n for multiline text. Ex: \"hello\\nfriend\")\n \"en\":\"English\",\n \"ru\":\"Русский\",\n \"de\":\"Deutsch\"\n }, \n \"page_id\": 39, // optional. HTML Pages. integer\n \"rich_page_id\": 42, // optional. Rich Pages. integer\n \"rich_media\": \"XXXX-XXXX\", // optional. Rich Media code. string\n \"remote_page\" : \"http://myremoteurl.com\", // Remote Rich HTML Page URL. <scheme>://<authority>\n \"link\": \"http://google.com\", // optional, string. For deeplinks add \"minimize_link\":0\n \"minimize_link\": 0, // optional. False or 0 — do not minimize, 1 — Google, 2 — bitly. Default = 1 \n \"data\": {\"key\":\"value\"}, // JSON string or JSON object, will be passed as \"u\" parameter in the payload (converted to JSON string)\n \"platforms\": [1,2,3,5,7,8,9,10,11,12], // 1 — iOS; 2 — BB; 3 — Android; 5 — Windows Phone; 7 — OS X; 8 — Windows 8; 9 — Amazon; 10 — Safari; 11 — Chrome; 12 — Firefox\n \"preset\":\"Q1A2Z-6X8SW\", // Push Preset Code from your Control Panel\n \"send_rate\": 100, // throttling. Valid values are from 100 to 1000 pushes/second.\n \"devices\": [\"dec301908b9ba8df85e57a58e40f96f523f4c2068674f5fe2ba25cdc250a2a41\"], // Optional. Specify tokens or hwids to send targeted push notifications. Not more than 1000 tokens/hwids in an array. If set, the message will only be sent to the devices on the list. Ignored if the Applications Group is used. iOS push tokens can only be lower case.\n \n // user-centric push notifications\n \"users\":[\"user_3078a\"], // optional. Enterprise API. If set, message will only be delivered to the specified users Id's (specified via /registerUser call). If specified together with devices parameter, the latter will be ignored.\n\n //filters and conditions\n \"filter\": \"FILTER_NAME\", // optional.\n \"conditions\": [TAG_CONDITION1, TAG_CONDITION2, ..., TAG_CONDITIONN], //Optional. See remark\n \n // iOS related\n \"ios_badges\": 5, // Optional, integer. iOS application badge number. Use \"+n\" or \"-n\" to increment/decrement the badge value by n\n \"ios_sound\": \"sound file.wav\", // Optional. Sound file name in the main bundle of application. If left empty, the device will produce no sound upon receiving a push\n \"ios_ttl\": 3600, // optional. Time to live parameter — maximum message lifespan in seconds\n \"ios_category_id\": \"1\", // Optional. Integer. iOS8 category ID from Pushwoosh\n \"ios_root_params\" : {\"aps\":{\"content-available\": \"1\"} , \"data\": << User supplied data, max of 4KB>> }, // Optional — root level parameters to the aps dictionary\n \"apns_trim_content\":1, // Optional. (0|1) Trims the exceeding content strings with ellipsis\n \"ios_trim_content\": 1, // Deprecated, use \"apns_trim_content\" instead.\n \n // Android related\n \"android_root_params\": {\"key\": \"value\"}, // custom key-value object. root level parameters for the android payload recipients\n \"android_sound\" : \"soundfile\", // Optional. No file extension. If left empty, the device will produce no sound upon receiving a push\n \"android_header\":\"header\", // Optional. Android notification header\n \"android_icon\": \"icon\",\n \"android_custom_icon\": \"http://example.com/image.png\", // Optional. Full path URL to the image file\n \"android_banner\": \"http://example.com/banner.png\", // Optional. Full path URL to the image file\n \"android_badges\": 5, // optional, integer. Android application icon badge number. Use \"+n\" or \"-n\" to increment/decrement the badge value by n\n \"android_gcm_ttl\": 3600, // optional. Time to live parameter — maximum message lifespan oin seconds\n \n \"android_vibration\": 0, // Android force-vibration for high-priority pushes, boolean\n \"android_led\":\"#rrggbb\", // LED hex color, device will do its best approximation\n \"android_priority\":-1, // priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2\n \"android_ibc\":\"#RRGGBB\", // icon background color on Lollipop, #RRGGBB, #AARRGGBB, \"red\", \"black\", \"yellow\", etc.\n \n // Amazon related\n \"adm_root_params\": {\"key\": \"value\"}, // custom key-value object\n \"adm_sound\": \"push.mp3\",\n \"adm_header\": \"Header\",\n \"adm_icon\": \"icon\",\n \"adm_custom_icon\": \"http://example.com/image.png\",\n \"adm_banner\": \"http://example.com/banner.png\",\n \"adm_ttl\": 3600, // optional. Time to live parameter — the maximum message lifespan in seconds\n \"adm_priority\":-1, // priority of the push in Amazon push drawer, valid values are -2, -1, 0, 1 and 2\n \n // Windows Phone related.\n \"wp_type\": \"Tile\", // Windows Phone notification type. 'Tile' or 'Toast'. Raw notifications are not supported. 'Tile' if default \n \"wp_background\": \"/Resources/Red.jpg\", // tile image\n \"wp_backbackground\": \"/Resources/Green.jpg\", // back tile image\n \"wp_backtitle\": \"back title\", // back tile title \n \"wp_backcontent\": \"back content\", // back tile content\n \"wp_count\": 3, // optional. Integer. Badge for Windows Phone notification\n \n // BlackBerry related.\n \"blackberry_header\": \"header\", // BlackBerry header, applicable to BB10 Series devices\n \n // Mac OS X related\n \"mac_badges\": 3,\n \"mac_sound\": \"sound.caf\",\n \"mac_root_params\": {\"content-available\":1},\n \"mac_ttl\": 3600, // Optional. Time to live parameter — maximum message lifespan in seconds\n \n // WNS related\n \"wns_content\": { // Content (XML or raw) of notification encoded in MIME's base64 in form of Object( language1: 'content1', language2: 'content2' ) OR String\n \"en\": \"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==\",\n \"de\": \"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4=\"\n },\n \"wns_type\": \"Badge\", // 'Tile' | 'Toast' | 'Badge' | 'Raw'\n \"wns_tag\": \"myTag\", // optional. Used in Tile replacement policy. An alphanumeric string of no more than 16 characters.\n \"wns_cache\": 1, // optional. (1|0) Translates into X-WNS-Cache-Policy value\n \"wns_ttl\": 600, // optional. Expiration time for notification in seconds\n // Safari related\n \"safari_title\": \"Title\", // obligatory, title of the notification\n \"safari_action\": \"Click here\", // optional\n \"safari_url_args\": [\"firstArgument\", \"secondArgument\"], // Obligatory, but the value may be empty\n \"safari_ttl\": 3600, // optional. Time to live parameter — the maximum lifespan of a message in seconds\n \n // Chrome related \n \"chrome_title\":\"\", // optional. You can specify the header of the message in this parameter\n \"chrome_icon\":\"\", // full path URL to the icon or extension resources file path\n \"chrome_gcm_ttl\": 3600, // Optional. Time to live parameter – maximum message lifespan in seconds\n \n // Firefox-related \n \"firefox_title\":\"\", // optional. You can specify message header here\n \"firefox_icon\":\"\", // full path URL to the icon or path to the file in extension resources \n }\n ]\n }\n}", "language": "json" } ] } [/block] ## Response: [block:parameters] { "data": { "h-0": "HTTP Status code", "h-1": "status_code", "h-2": "Description", "0-0": "200", "1-0": "200", "2-0": "400", "3-0": "500", "0-1": "200", "1-1": "210", "2-1": "N/A", "3-1": "500", "0-2": "Message successfully created", "1-2": "Argument error. See status_message for more info", "2-2": "Malformed request string", "3-2": "Internal error" }, "cols": 3, "rows": 4 } [/block] ## Debug Mode [block:callout] { "type": "info", "title": "Debug Mode", "body": "For load balancing purposes *we do not store messages sent through API with the “devices” parameter that contains less than 10 devices in an array*. Due to this, such messages will not be displayed in your Push History.\n\nTo see push reports during the testing phase, there’s **Debug Mode**. Turning Debug Mode **ON** allows you to *override this limit for 1 hour and save such pushes in the push history*. Debug mode turns OFF automatically after 1 hour.\n\nDebug Mode can be activated on the [Push History](https://cp.pushwoosh.com/notifications) page by switching the toggle in the upper right corner.\n\nIf the Debug Mode is turned OFF, and you send a /createMessage request with less than 10 device tokens to Pushwoosh API, the server will return a `“CODE_NOT_AVAILABLE”` value for `“Messages”`, and an empty key for Unknown Devices instead of Message Code unless the message is scheduled to be sent in the future with the `\"send_date\"` parameter." } [/block] [block:api-header] { "type": "basic", "title": "Parameters" } [/block] [block:parameters] { "data": { "0-0": "auth", "h-0": "Parameter", "h-1": "Description", "h-2": "Description", "0-2": "API access token from the Pushwoosh control panel (create this token at https://cp.pushwoosh.com/api_access)", "0-1": "API access token from the Pushwoosh control panel (create this token at https://cp.pushwoosh.com/api_access)", "1-0": "application", "1-2": "your Pushwoosh application ID where you send the message to (cannot be used together with “applications_group”)", "2-0": "applications_group", "2-2": "your Pushwoosh Application group code (cannot be used together with “application”)", "3-0": "content", "3-2": "is the text push message delivered to the application", "4-0": "data", "4-2": "use this only if you want to pass custom data to the application (JSON format) or omit this parameter. Please note that Mac OSX push is limited to 256 bytes", "5-0": "page_id", "5-2": "HTML page id (created from Application’s HTML Pages). Use this if you want to deliver additional HTML content to the application or omit this parameter", "6-0": "send_date", "6-2": "set the time you want the message to be sent (in UTC) or use ‘now’ to send it immediately", "7-0": "wp_count", "7-2": "sets the badge for WP7 platform", "8-0": "ios_badges", "8-2": "sets the badge on the icon for iOS platform. This value will be sent to ALL devices given in the “devices” list.", "9-0": "devices", "9-2": "omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs as described", "12-0": "ios_root_params", "12-2": "root level parameters to the aps dictionary. For example to use with NewsStand apps.", "1-1": "your Pushwoosh application ID where you send the message to (cannot be used together with “applications_group”)", "2-1": "your Pushwoosh Application group code (cannot be used together with “application”)", "3-1": "the text push message delivered to the application", "4-1": "use this only if you want to pass custom data to the application (JSON format) or omit this parameter. Please note that Mac OSX push is limited to 256 bytes", "5-1": "HTML page id (created from Application’s HTML Pages). Use this if you want to deliver additional HTML content to the application or omit this parameter", "6-1": "set the time you want the message to be sent (in UTC) or use ‘now’ to send it immediately", "7-1": "sets the badge for WP7 platform", "8-1": "sets the badge on the icon for iOS platform. This value will be sent to ALL devices given in the “devices” list.", "9-1": "omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs as described", "12-1": "root level parameters to the aps dictionary. For example to use with NewsStand apps.", "13-0": "conditions", "13-1": "see [below](http://docs.pushwoosh.com/docs/createmessage#tag-conditions)", "11-0": "send_rate", "11-1": "keep in mind that parameters \"send_rate\" and \"devices\" should not be used simulatneously in a single /createMessage request. Send rate throttling cannot be applied to messages sent to raw device tokens, only to bulk pushes or pushes with filter.", "10-0": "users", "10-1": "user-centric push notifications. If set, message will only be delivered to the specified users Id's (specified via /registerUser call). If specified together with the devices parameter, the latter will be ignored. Push notification will be delivered to the last used user's device." }, "cols": 2, "rows": 14 } [/block] [block:api-header] { "type": "basic", "title": "Tag conditions" } [/block] Each tag condition is an array like `[tagName, operator, operand]` where * tagName: name of a tag * operator: "EQ" | "IN" | "NOTEQ" | "NOTIN" | "LTE" | "GTE" | "BETWEEN" * operand: string | integer | array | date ## Operand description - EQ: tag value is equal to operand; - IN: tag value intersects with operand (operand must always be an array); - NOTEQ: tag value is not equal to an operand; - NOTIN: tag value does not intersect with operand (operand must always be an array); - GTE: tag value is greater than or equal to operand; - LTE: tag value is less than or equal to operand; - BETWEEN: tag value is greater than or equal to min operand value but less than or equal to max operand value (operand must always be an array). ## String tags Valid operators: EQ, IN, NOTEQ, NOTIN Valid operands: - EQ, NOTEQ: operand must be a string; - IN, NOTIN: operand must be an array of strings like `["value 1", "value 2", "value N"]`; ## Integer tags Valid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE Valid operands: - EQ, NOTEQ, GTE, LTE: operand must be an integer; - IN, NOTIN: operand must be an array of integers like `[value 1, value 2, value N]`; - BETWEEN: operand must be an array of integers like `[min_value, max_value]`. ## Date tags Valid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE Valid operands: `"YYYY-MM-DD 00:00"` (string), unix timestamp like `1234567890` (integer) ## Boolean tags Valid operators: EQ Valid operands: `0, 1, true, false` ## List tags Valid operators: IN Valid operands: operand must be an array of strings like `["value 1", "value 2", "value N"]`. [block:callout] { "type": "danger", "body": "Remember that “filter” and “conditions” parameters should not be used together.\nAlso, both of them **will be ignored**, if the \"devices\" parameter is used in the same request." } [/block] [block:callout] { "type": "info", "title": "Country and Language tags", "body": "Language tag value is a lowercase two-letter code according to [ISO-639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)\nCountry tag value is an UPPERCASE two-letter code according to [ISO_3166-2](http://en.wikipedia.org/wiki/ISO_3166-2)\nFor example, to send push a notification to Portuguese-speaking subscribers in Brazil, you will need to specify the following condition: `\"conditions\": [[\"Country\", \"EQ\", \"BR\"],[\"Language\", \"EQ\", \"pt\"]]`" } [/block] [block:api-header] { "type": "basic", "title": "/createMessage snippets" } [/block] Sample `/createMessage` requests in BASH, PHP, Erlang, Ruby, Java and Python: [block:code] { "codes": [ { "code": "#!/bin/bash\n \n#Usage\nif [ ! -n \"$1\" ] || [ ! -n \"$2\" ]\nthen\n echo \"`basename $0` usage: api_token appid message\";\n exit 1;\nfi;\nMESSAGE=\"$3\";\nif [ -z \"$3\" ]\nthen\nMESSAGE='One push to rule them all!'\nfi;\n \necho -e \"Response:\"\ncurl --data-binary \"\n{\\\"request\\\":\n {\\\"application\\\":\\\"$2\\\",\n \\\"auth\\\":\\\"$1\\\",\n \\\"notifications\\\":\n [{\n \\\"send_date\\\": \\\"now\\\",\n \\\"content\\\": \\\"$MESSAGE\\\"\n }]\n }\n}\" \\\n-H \"Content-type: application/json\" \\\n\"https://cp.pushwoosh.com/json/1.3/createMessage\"\necho\"\";\nexit 0;", "language": "java", "name": "BASH" }, { "code": "<?php \ndefine('PW_AUTH', 'API TOKEN');\ndefine('PW_APPLICATION', 'APPLICATION CODE');\ndefine('PW_DEBUG', true);\n \nfunction pwCall($method, $data) {\n $url = 'https://cp.pushwoosh.com/json/1.3/' . $method;\n $request = json_encode(['request' => $data]);\n \n $ch = curl_init($url);\n curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);\n curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');\n curl_setopt($ch, CURLOPT_HEADER, true);\n curl_setopt($ch, CURLOPT_POST, true);\n curl_setopt($ch, CURLOPT_POSTFIELDS, $request);\n \n $response = curl_exec($ch);\n $info = curl_getinfo($ch);\n curl_close($ch);\n \n if (defined('PW_DEBUG') && PW_DEBUG) {\n print \"[PW] request: $request\\n\";\n print \"[PW] response: $response\\n\";\n print '[PW] info: ' . print_r($info, true);\n }\n}\n \npwCall('createMessage', array(\n 'application' => PW_APPLICATION,\n 'auth' => PW_AUTH,\n 'notifications' => array(\n array(\n 'send_date' => 'now',\n 'content' => 'test',\n 'data' => array('custom' => 'json data'),\n 'link' => 'http://pushwoosh.com/'\n )\n )\n )\n);", "language": "php" }, { "code": "-module(pushwoosh).\n-export([run/0, stop/0, sendMessage/1]).\n%% sendMessage argument: message text %%\n \n%% Authentication & App_id %%\n-define(PW_AUTH, \"YOUR_AUTH_TOKEN\").\n-define(PW_APPLICATION, \"YOUR_PUSHWOOSH_APP_CODE\").\n \n%% KickStart %%\nrun() ->\n application:start(unicode),\n application:start(crypto),\n application:start(public_key),\n application:start(ssl),\n application:start(inets),\n %% HTTP Client verbosity options flase, verbose, debug\n httpc:set_options([{verbose, false}]). \nstop() ->\n application:stop(ssl),\n application:stop(public_key), \n application:stop(crypto),\n application:stop(inets).\n%% JSON Wars !\nencode(S) -> encode(S, [$\"]).\nencode([], Acc) -> lists:reverse([$\" | Acc]);\nencode([C | Cs], Acc) ->\n Hex = lists:flatten(io_lib:format(\"~4.16.0b\", [C])),\n encode(Cs, lists:reverse(Hex) ++ \"u\\\\\" ++ Acc).\n \nsendMessage(Message_text) ->\n %% URL to JSON API 1.3\n Url = \"https://cp.pushwoosh.com/json/1.3/createMessage\",\n EncodedMessage = encode(Message_text),\n {ok, Response} = httpc:request(\n %%Method \n post, \n %%Request\n {Url, [{\"User-Agent\", \"Erlang exemple\"}], \"application/json; charset=UTF-8\", \n \"{\\\"request\\\":{\n \\\"application\\\": \\\"\"?PW_APPLICATION\"\\\",\n \\\"auth\\\": \\\"\"?PW_AUTH\"\\\",\n \\\"notifications\\\": [{\n \\\"send_date\\\": \\\"now\\\",\n \\\"content\\\": \"++EncodedMessage++\"\n }]}}\"},\n %%HTTP options\n [{ssl,[{verify, verify_none}]}, {version, \"HTTP/1.0\"}],\n %%Options\n []),\n io:format(\"And received ~p\", [Response]).", "language": "erlang" }, { "code": "class PushNotification\n \n #- PushWoosh API Documentation http://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/ \n #- Two methods here:\n # - PushNotification.new.notify_all(message) Notifies all with the same option\n # - PushNotification.new.notify_devices(notification_options = {}) Notifies specific devices with custom options\n \n include HTTParty #Make sure to have the HTTParty gem declared in your gemfile https://github.com/jnunemaker/httparty\n default_params :output => 'json'\n format :json\n \n def initialize\n #- Change to your settings\n @auth = {:application => \"00000-00000\",:auth => \"auth_token\"}\n end\n \n # PushNotification.new.notify_all(\"This is a test notification to all devices\")\n def notify_all(message)\n notify_devices({:content => message})\n end\n \n # PushNotification.new.notify_device({\n # :content => \"TEST\",\n # :data => {:custom_data => value},\n # :devices => array_of_tokens\n #})\n def notify_devices(notification_options = {})\n #- Default options, uncomment :data or :devices if needed\n default_notification_options = {\n # YYYY-MM-DD HH:mm OR 'now'\n :send_date => \"now\",\n # Object( language1: 'content1', language2: 'content2' ) OR string\n :content => {\n :fr => \"Test\",\n :en => \"Test\"\n },\n # JSON string or JSON object \"custom\": \"json data\"\n #:data => {\n # :custom_data => value\n #},\n # omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs\n #:devices => {}\n }\n \n #- Merging with specific options\n final_notification_options = default_notification_options.merge(notification_options)\n \n #- Constructing the final call\n options = @auth.merge({:notifications => [final_notification_options]})\n options = {:request => options} \n #- Executing the POST API Call with HTTPARTY - :body => options.to_json allows us to send the json as an object instead of a string\n response = self.class.post(\"https://cp.pushwoosh.com/json/1.3/createMessage\", :body => options.to_json,:headers => { 'Content-Type' => 'application/json' })\n end\nend", "language": "ruby" }, { "code": "// Uses JSON classes from http://json.org/java/\n\npackage com.arellomobile;\n \nimport org.json.*;\nimport java.io.*;\nimport java.net.*;\n \npublic class SendPushNotificationSample\n{\n public static final String PUSHWOOSH_SERVICE_BASE_URL = \"https://cp.pushwoosh.com/json/1.3/\";\n private static final String AUTH_TOKEN = \"YOUR_AUTH_TOKEN\";\n private static final String APPLICATION_CODE = \"PW_APPLICATION_CODE\";\n \n public static void main(String[] args) throws JSONException, MalformedURLException\n {\n String method = \"createMessage\";\n URL url = new URL(PUSHWOOSH_SERVICE_BASE_URL + method);\n \n JSONArray notificationsArray = new JSONArray()\n .put(new JSONObject().put(\"send_date\", \"now\")\n .put(\"content\", \"test\")\n .put(\"link\", \"http://pushwoosh.com/\"));\n \n JSONObject requestObject = new JSONObject()\n .put(\"application\", APPLICATION_CODE)\n .put(\"auth\", AUTH_TOKEN)\n .put(\"notifications\", notificationsArray);\n \n JSONObject mainRequest = new JSONObject().put(\"request\", requestObject);\n JSONObject response = SendServerRequest.sendJSONRequest(url, mainRequest.toString());\n \n System.out.println(\"Response is: \" + response);\n }\n}\n \nclass SendServerRequest\n{\n static JSONObject sendJSONRequest(URL url, String request)\n {\n HttpURLConnection connection = null;\n try\n {\n connection = (HttpURLConnection) url.openConnection();\n connection.setRequestMethod(\"POST\");\n connection.setRequestProperty(\"Content-Type\", \"application/json\");\n connection.setDoInput(true);\n connection.setDoOutput(true);\n \n DataOutputStream writer = new DataOutputStream(connection.getOutputStream());\n writer.write(request.getBytes(\"UTF-8\"));\n writer.flush();\n writer.close();\n \n return parseResponse(connection);\n }\n catch (Exception e)\n {\n System.out.println(\"An error occurred: \" + e.getMessage());\n return null;\n }\n finally\n {\n if (connection != null)\n {\n connection.disconnect();\n }\n }\n }\n \n static JSONObject parseResponse(HttpURLConnection connection) throws IOException, JSONException\n {\n String line;\n BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));\n StringBuilder response = new StringBuilder();\n \n while ((line = reader.readLine()) != null)\n {\n response.append(line).append('\\r');\n }\n reader.close();\n \n return new JSONObject(response.toString());\n }\n}", "language": "java" }, { "code": "import json\n \nPW_AUTH = 'API TOKEN'\nPW_APPLICATION_CODE = 'APPLICATION CODE'\n \ntry:\n # For Python 3.0 and later\n from urllib.request import urlopen\n from urllib.request import Request\nexcept ImportError:\n # Fall back to Python 2's urllib2\n from urllib2 import urlopen\n from urllib2 import Request\n \ndef pw_call(method, data):\n url = 'https://cp.pushwoosh.com/json/1.3/' + method\n data = json.dumps({'request': data})\n req = Request(url, data.encode('UTF-8'), {'Content-Type': 'application/json'})\n try:\n f = urlopen(req)\n response = f.read()\n f.close()\n print('Pushwoosh response: ' + str(response))\n except Exception as e:\n print ('Request error: ' + str(e))\n \nif __name__ == '__main__':\n pw_call('createMessage', {\n 'auth': PW_AUTH,\n 'application': PW_APPLICATION_CODE,\n 'notifications': [\n {\n 'send_date': 'now',\n 'content': 'test',\n 'data': {\"custom\": \"json data\"},\n 'link': 'http://pushwoosh.com'\n }\n ]\n }\n )", "language": "python" }, { "code": "using System;\nusing System.IO;\nusing System.Net;\nusing Newtonsoft.Json.Linq;\n\nnamespace WebApplication1\n{\n public partial class Default : System.Web.UI.Page\n {\n protected void Page_Load(object sender, EventArgs e)\n {\n string pwAuth = \"YOUR_AUTH_TOKEN\";\n string pwApplication = \"PW_APPLICATION_CODE\";\n JObject json = new JObject(\n new JProperty(\"application\", pwApplication),\n new JProperty(\"auth\", pwAuth),\n new JProperty(\"notifications\",\n new JArray(\n new JObject(\n new JProperty(\"send_date\", \"now\"),\n new JProperty(\"content\", \"test\"),\n new JProperty(\"wp_type\", \"Toast\"),\n new JProperty(\"wp_count\", 3),\n new JProperty(\"data\",\n new JObject(\n new JProperty(\"custom\", \"json data\"))),\n new JProperty(\"link\", \"http://pushwoosh.com/\"),\n new JProperty(\"conditions\",\n new JArray(\n (object)new JArray(\"Color\", \"EQ\", \"black\")))))));\n PWCall(\"createMessage\", json);\n }\n private void PWCall(string action, JObject data)\n {\n Uri url = new Uri(\"https://cp.pushwoosh.com/json/1.3/\" + action);\n JObject json = new JObject(new JProperty(\"request\", data));\n DoPostRequest(url, json);\n }\n private void DoPostRequest(Uri url, JObject data)\n {\n HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);\n req.ContentType = \"text/json\";\n req.Method = \"POST\";\n using (var streamWriter = new StreamWriter(req.GetRequestStream()))\n {\n streamWriter.Write(data.ToString());\n }\n HttpWebResponse httpResponse;\n try\n {\n httpResponse = (HttpWebResponse)req.GetResponse();\n }\n catch (Exception exc)\n {\n throw new Exception(string.Format(\"Problem with {0}, {1}\", url, exc.Message));\n }\n using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))\n {\n var responseText = streamReader.ReadToEnd();\n Page.Response.Write(responseText);\n }\n }\n }\n}", "language": "csharp", "name": ".NET" }, { "code": "package main\n\nimport\n(\n\t\"fmt\"\n\t\"encoding/json\"\n\t\"net/http\"\n\t\"bytes\"\n\t\"io/ioutil\"\n)\n\nconst (\n\tPW_APPLICATION = \"APPLICATION CODE\"\n\tPW_AUTH = \"API TOKEN\"\n\tPW_ENDPOINT = \"https://cp.pushwoosh.com/json/1.3/\"\n)\n\nfunc pwCall(method string, data []byte) (bool) {\n\turl := PW_ENDPOINT + method\n\trequest, err := http.NewRequest(\"POST\", url, bytes.NewBuffer(data))\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := http.Client{}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tfmt.Println(\"Error occur: \" + err.Error())\n\t\treturn false\n\t}\n\tdefer response.Body.Close()\n\n\tfmt.Println(\"Response Status: \", response.Status)\n\tif (response.StatusCode == 200) {\n\t\tbody, _ := ioutil.ReadAll(response.Body)\n\t\tfmt.Println(\"Response Body: \", string(body))\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\trequestData := map[string]interface{}{\n\t\t\"request\": map[string]interface{} {\n\t\t\t\"auth\": PW_AUTH,\n\t\t\t\"application\": PW_APPLICATION,\n\t\t\t\"notifications\": []interface{}{\n\t\t\t\tmap[string]interface{} {\n\t\t\t\t\t\"send_date\": \"now\",\n\t\t\t\t\t\"content\": \"test\",\n\t\t\t\t\t\"link\": \"https://pushwoosh.com\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\tjsonRequest, _ := json.Marshal(requestData)\n\trequestString := string(jsonRequest)\n\tfmt.Println(\"Request body: \" + requestString)\n\n\tpwCall(\"createMessage\", jsonRequest)\n}", "language": "go" }, { "code": "$.ajax({\n type: \"POST\",\n url: \"https://cp.pushwoosh.com/json/1.3/createMessage\",\n data: JSON.stringify({\n \"request\": {\n \"application\": \"APPLICATION CODE\",\n \"auth\": \"API TOKEN\",\n \"notifications\": [{\n \"send_date\": \"now\",\n \"ignore_user_timezone\": true,\n \"content\": \"Hello world!\"\n }]\n }\n }),\n dataType: \"json\"\n}).done(function(data) {\n console.log(data);\n});", "language": "javascript", "name": "Javascript(JQuery)" } ] } [/block]