/createMessage

Creates a new push notification

Creates a new push notification.

Platform-specific parameters:

{
   "request":{
      "application": "XXXXX-XXXXX", // Your Pushwoosh application code
      "applications_group": "GROUP_CODE",   // optional. Can be used instead of "application".
      "auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel
      "notifications":[
         {
            // Content settings 
            "send_date": "now",             // YYYY-MM-DD HH:mm OR 'now'
            "ignore_user_timezone": true,   // or false
            "timezone": "America/New_York", // optional. If ignored UTC-0 is default for "send_date". See http://php.net/manual/timezones.php for supported timezones.
            "campaign": "CAMPAIGN_CODE",    // optional. Campaign code to which you want to assign this push message.
            "content":{                     // object( language1: 'content1', language2: 'content2' ) OR string. Ignored for Windows 8, use "wns_content" instead. (Use \n for multiline text. Ex: "hello\nfriend")
               "en":"English",
               "ru":"Русский",
               "de":"Deutsch"
            }, 
            
            // iOS related
            "ios_badges": 5,     // optional, integer. iOS application badge number. Use "+n" or "-n" to increment/decrement the badge value by 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.
            "ios_ttl": 3600, // optional. Time to live parameter — maximum message lifespan in seconds.
            "ios_silent": 1, // optional. Enables silent notifications (ignore "sound" and "content").
            "ios_category_id": "1",       // optional, integer. iOS8 category ID from Pushwoosh.
            "ios_root_params" : {  // optional. Root level parameters to the aps dictionary.
              "aps":{
                "content-available": "1",
                "mutable-content":1 // required for iOS 10 Media attachments.
							},
              "attachment":"YOUR_ATTACHMENT_URL", // iOS 10 media attachment URL.
							"data": << User supplied data, max of 4KB>> 
            },
            "apns_trim_content": 1,     // optional. (0|1) Trims the exceeding content strings with ellipsis.
            "ios_trim_content": 1,       // Deprecated, use "apns_trim_content" instead.
           "ios_title":"Title", // optional. Adds Title for push notification.
           "ios_subtitle" : "SubTitle", // optional. Adds sub-title for push notification.
           
            // Android related
            "android_root_params": {"key": "value"}, // optional. Custom key-value object. Root level parameters for the android payload recipients.
            "android_sound" : "soundfile", // optional. No file extension. If left empty, the device will produce no sound upon receiving a push.
            "android_header": "header",    // optional. Android notification header.
            "android_icon": "icon.png",
            "android_custom_icon": "http://example.com/image.png", // optional. Full path URL to the image file.
            "android_banner": "http://example.com/banner.png", // optional. Full path URL to the image file.
            "android_badges": 5, // optional, integer. Android application icon badge number. Use "+n" or "-n" to increment/decrement the badge value by n.
            "android_gcm_ttl": 3600, // optional. Time to live parameter — maximum message lifespan in seconds.
             "android_vibration": 0,  // boolean. Android force-vibration for high-priority pushes.
            "android_led": "#rrggbb",  // LED hex color, device will do its best approximation.
            "android_priority": -1,  // Sets the “importance” parameter for devices with Android 8.0 and higher, as well as the “priority” parameter for devices with Android 7.1 and lower. Establishes the interruption level of a notification channel or a particular notification. Valid values are -2, -1, 0, 1, 2.
            "android_delivery_priority": "normal",  // or "high", optional. Enables notification’s delivery when the device is in the power saving mode. 
            "android_ibc": "#RRGGBB",  // icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
           "android_silent": 1, // optional. 0 or 1, enable silent notificaiton (ignore sound and content). 
 
            // Amazon related
            "adm_root_params": {"key":"value"}, // custom key-value object
            "adm_sound": "push.mp3",
            "adm_header": "Header",
            "adm_icon": "icon",
            "adm_custom_icon": "http://example.com/image.png",
            "adm_banner": "http://example.com/banner.png",
            "adm_ttl": 3600, // optional. Time to live parameter — the maximum message lifespan in seconds.
            "adm_priority":-1,  // priority of the push in Amazon push drawer, valid values are -2, -1, 0, 1 and 2.
 
            // Windows Phone related.
            "wp_type": "Tile",           // Windows Phone notification type. 'Tile' or 'Toast'. Raw notifications are not supported. 'Tile' is default. 
            "wp_background": "/Resources/Red.jpg", // tile image
            "wp_backbackground": "/Resources/Green.jpg", // back tile image
            "wp_backtitle": "back title",  // back tile title 
            "wp_backcontent": "back content",  // back tile content
            "wp_count": 3,               // optional, integer. Badge for Windows Phone notification.
 
            // BlackBerry related.
            "blackberry_header": "header",           // BlackBerry header, applicable to BB10 Series devices.
 
            // Mac OS X related
            "mac_badges": 3,
            "mac_sound": "sound.caf",
            "mac_root_params": {"content-available":1},
            "mac_ttl": 3600, // optional. Time to live parameter — maximum message lifespan in seconds.
 
            // WNS related
            "wns_content": { // Content (XML or raw) of notification encoded in MIME's base64 in form of Object( language1: 'content1', language2: 'content2' ) OR String
               "en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==",
               "de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4="
            },
            "wns_type": "Badge", // 'Tile' | 'Toast' | 'Badge' | 'Raw'
            "wns_tag": "myTag", // optional. Used in Tile replacement policy. An alphanumeric string of no more than 16 characters.
            "wns_cache": 1, // optional. (1|0) Translates into X-WNS-Cache-Policy value.
            "wns_ttl": 600, // optional. Expiration time for notification in seconds.
            // Safari related
            "safari_title": "Title", // obligatory. Title of the notification. 
            "safari_action": "Click here", // optional
            "safari_url_args": ["firstArgument", "secondArgument"], // obligatory, but the value may be empty
            "safari_ttl": 3600, // optional. Time to live parameter — the maximum lifespan of a message in seconds.
           
            // Chrome related 
            "chrome_title": "Title", // optional. You can specify the header of the message in this parameter.
            "chrome_icon": "icon_URL", // full path URL to the icon or extension resources file path
            "chrome_gcm_ttl": 3600, // optional. Time to live parameter – maximum message lifespan in seconds.
     		  	"chrome_duration": 20, // optional. Changes chrome push display time. Set to 0 to display push until user interacts with it.
					  "chrome_image": "image_URL", // optional. URL to large image. 
            "chrome_root_params": {"key":"value"}, // optional. Set parameters specific to messages sent to Chrome.
					  "chrome_button_text1": "1", // optional
					  "chrome_button_url1": "button1_URL", // optional. Ignored if chrome_button_text1 is not set.
					  "chrome_button_text2": "2", // optional
				    "chrome_button_url2": "button2_url", // optional. Ignored if chrome_button_text2 is not set. 
            // Firefox-related 
            "firefox_title": "Title", // optional. You can specify message header here.
            "firefox_icon": "icon_URL", // full path URL to the icon or path to the file in extension resources. 
            "firefox_root_params": {"key":"value"} // optional. Set parameters specific to messages sent to Firefox.
         }
      ]
   }
}

👍

Quick start! Check out these cool third-party libraries!

PHP-Pushwoosh library by Gomoob:
http://gomoob.github.io/php-pushwoosh/
http://gomoob.github.io/php-pushwoosh/create-message.html

Python library by Pushwoosh:
https://github.com/Pushwoosh/pushwoosh-python-lib

Laravel library:
https://github.com/hoymultimedia/Laravel-Pushwoosh

Node JS client
https://github.com/nluo/pushwoosh-node-client

Meteor JS client
https://github.com/lpender/meteor-pushwoosh

Rails library
https://github.com/iarie/pwush

Golang library
https://github.com/yyoshiki41/go-pushwoosh

🚧

/createMessage Throttling

Keep in mind that non-enterprise accounts cannot send more than 600 /createMessage and/or /createTargetedMessage requests per minute.

However, if you send pushes via the devices parameter to 10 devices or less, there are no restrictions for any account type as long as the debug mode is disabled.

Note that we always save scheduled pushes to the Message History, even if you are sending them to less than 10 devices via devices parameter. Therefore, such pushes are also throttled.

Response:

HTTP Status codestatus_codeDescription
200200Message successfully created
200210Argument error. See status_message for more info
400N/AMalformed request string
500500Internal error

📘

An error in an array of notifications

If the createMessage request has several messages in the notifications array, they will be processed and sent one by one. If one of the messages cannot be parsed, our API will return "status_code":210 with the codes of successfully sent messages, i.e. those preceding the faulty message in the request.

Debug Mode

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 Message History.

To 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 Message History. Debug mode turns OFF automatically after 1 hour.

Debug Mode can be activated on the Message History page by switching the toggle in the upper right corner.

If 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.

Parameters

ParameterDescription
authAPI access token from the Pushwoosh control panel (create this token at https://cp.pushwoosh.com/api_access)
applicationyour Pushwoosh application ID where you send the message to (cannot be used together with “applications_group”)
applications_groupyour Pushwoosh Application group code (cannot be used together with “application”)
contentthe text push message delivered to the application
datause 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
page_idHTML 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
send_dateset the time you want the message to be sent (in UTC) or use ‘now’ to send it immediately
wp_countsets the badge for WP7 platform
ios_badgessets the badge on the icon for iOS platform. This value will be sent to ALL devices given in the “devices” list.
devicesomit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs as described
usersuser-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 all devices with the specified user IDs.
send_ratekeep in mind that parameters "send_rate" and "devices" should not be used simultaneously 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.
ios_root_paramsroot level parameters to the aps dictionary. For example to use with NewsStand apps.
conditionssee below

Tag conditions

Each tag condition is an array like [tagName, operator, operand] where

  • tagName: name of a tag
  • operator: "EQ" | "IN" | "NOTEQ" | "NOTIN" | "LTE" | "GTE" | "BETWEEN" | "NOTSET" | "ANY"
  • operand: string | integer | array | date

Operator 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);
  • NOTSET: tag not set. Operand is not considered;
  • ANY: tag has any value. Operand is not considered.

String tags

Valid operators: EQ, IN, NOTEQ, NOTIN, NOTSET, ANY
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"];
  • NOTSET: tag not set. Operand is not considered;
  • ANY: tag has any value. Operand is not considered.

Integer tags

Valid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE, NOTSET, ANY
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];
  • NOTSET: tag not set. Operand is not considered;
  • ANY: tag has any value. Operand is not considered.

Date tags

Valid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE, NOTSET, ANY
Valid operands:

  • "YYYY-MM-DD 00:00" (string)
  • unix timestamp 1234567890 (integer)
  • "N days ago" (string) for operators EQ, BETWEEN, GTE, LTE

Boolean tags

Valid operators: EQ, NOTSET, ANY
Valid operands: 0, 1, true, false

List tags

Valid operators: IN, NOTIN, NOTSET, ANY
Valid operands: operand must be an array of strings like ["value 1", "value 2", "value N"].

❗️

Remember that “filter” and “conditions” parameters should not be used together.
Also, both of them will be ignored, if the "devices" parameter is used in the same request.

📘

Country and Language tags

Language tag value is a lowercase two-letter code according to ISO-639-1
Country tag value is an UPPERCASE two-letter code according to ISO_3166-2
For 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"]]

/createMessage snippets

🚧

Important!

Please be careful when using the snippets. Limit the number of recipients by specifying “users”, “devices”, “filter”, or “conditions” parameter. If none of these parameters is specified, the message will be sent to every device subscribed to push notifications from the application.

Sample /createMessage requests in BASH, PHP, Erlang, Ruby, Java and Python:

#!/bin/bash
 
#Usage
if [ ! -n "$1" ] || [ ! -n "$2" ]
then
  echo "`basename $0` usage: api_token appid message";
  exit 1;
fi;
MESSAGE="$3";
if [ -z "$3" ]
then
MESSAGE='One push to rule them all!'
fi;
 
echo -e "Response:"
curl --data-binary "
{\"request\":
    {\"application\":\"$2\",
     \"auth\":\"$1\",
     \"notifications\":
        [{
                        \"send_date\": \"now\",
            \"content\": \"$MESSAGE\"
        }]
    }
}" \
-H "Content-type: application/json" \
"https://cp.pushwoosh.com/json/1.3/createMessage"
echo "";
exit 0;
<?php 
define('PW_AUTH', 'API TOKEN');
define('PW_APPLICATION', 'APPLICATION CODE');
define('PW_DEBUG', true);
 
function pwCall($method, $data) {
    $url = 'https://cp.pushwoosh.com/json/1.3/' . $method;
    $request = json_encode(['request' => $data]);
 
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
 
    $response = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
 
    if (defined('PW_DEBUG') && PW_DEBUG) {
        print "[PW] request: $request\n";
        print "[PW] response: $response\n";
        print '[PW] info: ' . print_r($info, true);
    }
}
 
pwCall('createMessage', array(
    'application' => PW_APPLICATION,
    'auth' => PW_AUTH,
    'notifications' => array(
            array(
                'send_date' => 'now',
                'content' => 'test',
                'data' => array('custom' => 'json data'),
                'link' => 'http://pushwoosh.com/'
            )
        )
    )
);
-module(pushwoosh).
-export([run/0, stop/0, sendMessage/1]).
%% sendMessage argument: message text %%
 
%% Authentication & App_id %%
-define(PW_AUTH, "YOUR_AUTH_TOKEN").
-define(PW_APPLICATION, "YOUR_PUSHWOOSH_APP_CODE").
 
%% KickStart %%
run() ->
    application:start(unicode),
    application:start(crypto),
    application:start(public_key),
    application:start(ssl),
    application:start(inets),
    %% HTTP Client verbosity options flase, verbose, debug
    httpc:set_options([{verbose, false}]).  
stop() ->
    application:stop(ssl),
    application:stop(public_key),       
    application:stop(crypto),
    application:stop(inets).
%% JSON Wars !
encode(S) -> encode(S, [$"]).
encode([], Acc) -> lists:reverse([$" | Acc]);
encode([C | Cs], Acc) ->
        Hex = lists:flatten(io_lib:format("~4.16.0b", [C])),
        encode(Cs, lists:reverse(Hex) ++ "u\\" ++ Acc).
 
sendMessage(Message_text) ->
    %% URL to JSON API 1.3
    Url = "https://cp.pushwoosh.com/json/1.3/createMessage",
    EncodedMessage = encode(Message_text),
    {ok, Response} = httpc:request(
        %%Method 
        post, 
        %%Request
        {Url, [{"User-Agent", "Erlang exemple"}], "application/json; charset=UTF-8", 
        "{\"request\":{
        \"application\": \""?PW_APPLICATION"\",
        \"auth\": \""?PW_AUTH"\",
        \"notifications\": [{
        \"send_date\": \"now\",
        \"content\": "++EncodedMessage++"
        }]}}"},
        %%HTTP options
        [{ssl,[{verify, verify_none}]}, {version, "HTTP/1.0"}],
        %%Options
        []),
    io:format("And received ~p", [Response]).
class PushNotification
 
  #- PushWoosh API Documentation http://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/ 
  #- Two methods here:
  #     - PushNotification.new.notify_all(message) Notifies all with the same option
  #     - PushNotification.new.notify_devices(notification_options = {}) Notifies specific devices with custom options
 
  include HTTParty #Make sure to have the HTTParty gem declared in your gemfile https://github.com/jnunemaker/httparty
  default_params :output => 'json'
  format :json
 
  def initialize
    #- Change to your settings
    @auth = {:application  => "00000-00000",:auth => "auth_token"}
  end
 
  # PushNotification.new.notify_all("This is a test notification to all devices")
  def notify_all(message)
    notify_devices({:content  => message})
  end
 
  # PushNotification.new.notify_device({
  #  :content  => "TEST",
  #  :data  => {:custom_data  => value},
  #  :devices  => array_of_tokens
  #})
  def notify_devices(notification_options = {})
    #- Default options, uncomment :data or :devices if needed
    default_notification_options = {
                        # YYYY-MM-DD HH:mm  OR 'now'
                        :send_date  => "now",
                        # Object( language1: 'content1', language2: 'content2' ) OR string
                        :content  => {
                            :fr  => "Test",
                            :en  => "Test"
                        },
                        # JSON string or JSON object "custom": "json data"
                        #:data  => {
                        #    :custom_data  => value
                        #},
                        # omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs
                        #:devices  => {}
                      }
 
    #- Merging with specific options
    final_notification_options = default_notification_options.merge(notification_options)
 
    #- Constructing the final call
    options = @auth.merge({:notifications  => [final_notification_options]})
    options = {:request  => options}                                                                                                                             
    #- Executing the POST API Call with HTTPARTY - :body => options.to_json allows us to send the json as an object instead of a string
    response = self.class.post("https://cp.pushwoosh.com/json/1.3/createMessage", :body  => options.to_json,:headers => { 'Content-Type' => 'application/json' })
  end
end
// Uses JSON classes from http://json.org/java/

package com.arellomobile;
 
import org.json.*;
import java.io.*;
import java.net.*;
 
public class SendPushNotificationSample
{
    public static final String PUSHWOOSH_SERVICE_BASE_URL = "https://cp.pushwoosh.com/json/1.3/";
    private static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN";
    private static final String APPLICATION_CODE = "PW_APPLICATION_CODE";
 
    public static void main(String[] args) throws JSONException, MalformedURLException
    {
        String method = "createMessage";
        URL url = new URL(PUSHWOOSH_SERVICE_BASE_URL + method);
 
        JSONArray notificationsArray = new JSONArray()
                .put(new JSONObject().put("send_date", "now")
                                     .put("content", "test")
                                     .put("link", "http://pushwoosh.com/"));
 
        JSONObject requestObject = new JSONObject()
                .put("application", APPLICATION_CODE)
                .put("auth", AUTH_TOKEN)
                .put("notifications", notificationsArray);
 
        JSONObject mainRequest = new JSONObject().put("request", requestObject);
        JSONObject response = SendServerRequest.sendJSONRequest(url, mainRequest.toString());
 
        System.out.println("Response is: " + response);
    }
}
 
class SendServerRequest
{
    static JSONObject sendJSONRequest(URL url, String request)
    {
        HttpURLConnection connection = null;
        try
        {
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setDoInput(true);
            connection.setDoOutput(true);
 
            DataOutputStream writer = new DataOutputStream(connection.getOutputStream());
            writer.write(request.getBytes("UTF-8"));
            writer.flush();
            writer.close();
 
            return parseResponse(connection);
        }
        catch (Exception e)
        {
            System.out.println("An error occurred: " + e.getMessage());
            return null;
        }
        finally
        {
            if (connection != null)
            {
                connection.disconnect();
            }
        }
    }
 
    static JSONObject parseResponse(HttpURLConnection connection) throws IOException, JSONException
    {
        String line;
        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        StringBuilder response = new StringBuilder();
 
        while ((line = reader.readLine()) != null)
        {
            response.append(line).append('\r');
        }
        reader.close();
 
        return new JSONObject(response.toString());
    }
}
import json
 
PW_AUTH = 'API TOKEN'
PW_APPLICATION_CODE = 'APPLICATION CODE'
 
try:
    # For Python 3.0 and later
    from urllib.request import urlopen
    from urllib.request import Request
except ImportError:
    # Fall back to Python 2's urllib2
    from urllib2 import urlopen
    from urllib2 import Request
 
def pw_call(method, data):
    url = 'https://cp.pushwoosh.com/json/1.3/' + method
    data = json.dumps({'request': data})
    req = Request(url, data.encode('UTF-8'), {'Content-Type': 'application/json'})
    try:
        f = urlopen(req)
        response = f.read()
        f.close()
        print('Pushwoosh response: ' + str(response))
    except Exception as e:
        print ('Request error: ' + str(e))
 
if __name__ == '__main__':
    pw_call('createMessage', {
        'auth': PW_AUTH,
        'application': PW_APPLICATION_CODE,
        'notifications': [
            {
                'send_date': 'now',
                'content': 'test',
                'data': {"custom": "json data"},
                'link': 'http://pushwoosh.com'
            }
        ]
    }
    )
using System;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;

namespace WebApplication1
{
   public partial class Default : System.Web.UI.Page
   {
       protected void Page_Load(object sender, EventArgs e)
       {
           string pwAuth = "YOUR_AUTH_TOKEN";
           string pwApplication = "PW_APPLICATION_CODE";
           JObject json = new JObject(
               new JProperty("application", pwApplication),
               new JProperty("auth", pwAuth),
               new JProperty("notifications",
                   new JArray(
                       new JObject(
                           new JProperty("send_date", "now"),
                           new JProperty("content", "test"),
                           new JProperty("wp_type", "Toast"),
                           new JProperty("wp_count", 3),
                           new JProperty("data",
                               new JObject(
                                   new JProperty("custom", "json data"))),
                           new JProperty("link", "http://pushwoosh.com/"),
                           new JProperty("conditions",
                               new JArray(
                                   (object)new JArray("Color", "EQ", "black")))))));
           PWCall("createMessage", json);
       }
       private void PWCall(string action, JObject data)
       {
           Uri url = new Uri("https://cp.pushwoosh.com/json/1.3/" + action);
           JObject json = new JObject(new JProperty("request", data));
           DoPostRequest(url, json);
       }
       private void DoPostRequest(Uri url, JObject data)
       {
           HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
           req.ContentType = "text/json";
           req.Method = "POST";
           using (var streamWriter = new StreamWriter(req.GetRequestStream()))
           {
               streamWriter.Write(data.ToString());
           }
           HttpWebResponse httpResponse;
           try
           {
               httpResponse = (HttpWebResponse)req.GetResponse();
           }
           catch (Exception exc)
           {
               throw new Exception(string.Format("Problem with {0}, {1}", url, exc.Message));
           }
           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
           {
               var responseText = streamReader.ReadToEnd();
               Page.Response.Write(responseText);
           }
       }
   }
}
package main

import
(
	"fmt"
	"encoding/json"
	"net/http"
	"bytes"
	"io/ioutil"
)

const (
	PW_APPLICATION = "APPLICATION CODE"
	PW_AUTH = "API TOKEN"
	PW_ENDPOINT = "https://cp.pushwoosh.com/json/1.3/"
)

func pwCall(method string, data []byte) (bool) {
	url := PW_ENDPOINT + method
	request, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
	request.Header.Set("Content-Type", "application/json")

	client := http.Client{}
	response, err := client.Do(request)
	if err != nil {
		fmt.Println("Error occur: " + err.Error())
		return false
	}
	defer response.Body.Close()

	fmt.Println("Response Status: ", response.Status)
	if (response.StatusCode == 200) {
		body, _ := ioutil.ReadAll(response.Body)
		fmt.Println("Response Body: ", string(body))
		return true
	}
	return false
}

func main() {
	requestData := map[string]interface{}{
		"request": map[string]interface{} {
			"auth": PW_AUTH,
			"application": PW_APPLICATION,
			"notifications": []interface{}{
				map[string]interface{} {
					"send_date": "now",
					"content": "test",
					"link": "https://pushwoosh.com",
				},
			},
		},
	}
	jsonRequest, _ := json.Marshal(requestData)
	requestString := string(jsonRequest)
	fmt.Println("Request body: " + requestString)

	pwCall("createMessage", jsonRequest)
}
$.ajax({
    type: "POST",
    url: "https://cp.pushwoosh.com/json/1.3/createMessage",
    data: JSON.stringify({
        "request": {
            "application": "APPLICATION CODE",
            "auth": "API TOKEN",
            "notifications": [{
                "send_date": "now",
                "ignore_user_timezone": true,
                "content": "Hello world!"
            }]
        }
    }),
    dataType: "json"
}).done(function(data) {
    console.log(data);
});
Language
Click Try It! to start a request and see the response here!