createMessage
POST
https://api.pushwoosh.com/json/1.3/createMessage
Creates a new push notification.
Request Body
Name Type Description auth* string API access token from Pushwoosh Control Panel. application* string Pushwoosh application code. notifications* array JSON array of message parameters. See details in a request example below.
Request example
"application" : " XXXXX-XXXXX " , // required. Pushwoosh application code.
"applications_group" : " GROUP_CODE " , // optional. Can be used instead of "application".
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel.
"send_date" : " now " , // optional. YYYY-MM-DD HH:mm OR 'now'
"content" : { // optional. object OR string.
"en" : " English " , // Use "wns_content" instead for Windows.
"title" : { // optional. object OR string.
"en" : " Title " , // Ignored if platform-specific titles are specified
"fr" : " Titre " // 'ios_title', 'android_header', etc.
}, // see the platform-specific parameters examples below.
"subtitle" :{ // optional. object OR string.
"en" : " Subtitle " , // Ignored if platform-specific titles are specified
"fr" : " Sous-titre " // 'ios_subtitle', etc.
}, // see the platform-specific parameters examples below.
"ignore_user_timezone" : true , // optional.
"timezone" : " America/New_York " , // optional. If ignored UTC-0 is default for "send_date".
// See https://php.net/manual/timezones.php for
"campaign" : " CAMPAIGN_CODE " , // optional. Campaign code to which you want to
// assign this push message.
"geozone" : { // optional. Send to Geozone
"rich_media" : " XXXXX-XXXXX " , // optional. Copy the Rich Media code from the URL bar of
// the Rich Media editor page in Pushwoosh Control Panel.
"link" : " https://google.com " , // optional. For deeplinks add "minimize_link": 0
"minimize_link" : 0 , // optional. 0 — do not minimize, 2 — bitly. Default = 2.
// Please note that shorteners have restrictions
"data" : { // optional. JSON string or JSON object, will be passed as
"key" : " value " // "u" parameter in the payload (converted to JSON string).
"transactionId" : " unique UUID " , // optional. Unique message identifier to prevent duplicating
// in case of network problems. Stored on the side of
// Pushwoosh for 5 minutes.
"platforms" : [ // optional. 1 — iOS; 3 — Android; 7 — Mac OS X; 8 — Windows;
1 , 3 , 7 , 8 , 9 , 10 , // 9 — Amazon; 10 — Safari; 11 — Chrome;
11 , 12 , 17 , 19 // 12 — Firefox; 17 — Huawei; 19 — Xiaomi
"preset" : " XXXXX-XXXXX " , // optional. Push Preset Code from your Control Panel.
// If specific params are sent in the request,
// they override preset's params.
"send_rate" : 100 , // optional. Throttling. Valid values are from 100 to 1000 pushes/second.
// Templating related, please refer to the Template Engine guide to learn more
"template_bindings" : { // optional.
"TemplatePlaceholder" : " Value "
"dynamic_content_placeholders" : { // optional. Placeholders for dynamic content instead of device tags.
// Frequency capping params. Ensure that Global frequency capping is configured in the Control Panel.
"capping_days" : 30 , // optional. Amount of days for frequency capping (max 30 days)
"capping_count" : 10 , // optional. The max number of pushes that can be sent from a
// specific app to a particular device within a 'capping_days'
// period. In case the message created exceeds the
// 'capping_count' limit for a device, it won't
// be sent to that device.
"capping_exclude" : true , // optional. If set to true, this push notification will not
// be counted towards the capping for future pushes.
"capping_avoid" : true , // optional. If set to true, capping will not be applied to
// this specific push notification.
// To save the message to the Inbox via API, use "inbox_date" or "inbox_image".
// The message is saved when at least one of these parameters is used.
"inbox_date" : " 2017-02-02 " , // optional. Specify when to remove a message from the Inbox.
// Message will be removed from Inbox at 00:00:01 UTC
// of the date specified, so the previous date is the
// last day a user can see the message in their Inbox.
// If not specified, the default removal date is the
// next day after the send date.
"inbox_image" : " Inbox image URL " , // optional. The image to be shown near the message.
"inbox_days" : 5 , // optional. Specify when to remove a message from the
// Inbox(lifetime of an inbox message in days).
// Can be used instead of the "inbox_date" parameter.
"devices" : [ // optional. Specify tokens or hwids to send targeted push
" hwid_XXXX " // notifications. Not more than 1000 tokens/hwids in
], // an array. If set, the message will only be sent to
// the devices on the list. Application Group for devices
// list is not allowed. iOS push tokens can only be lower case.
// User-centric push notifications
"users" : [ // optional. If set, message will only be delivered to the
" user_XXXX " // specified user ID's (set via /registerUser call).
], // If specified together with devices parameter,
// the latter will be ignored. Not more than 1000 user
// ID's in an array. Application Group for users list
// Filters and conditions
"filter" : " FILTER_NAME " , // optional.
"conditions" : [ // optional. See the remark below.
" Country " , " EQ " , " France " ,
"conditions_operator" : " AND " // optional. Logical operator for conditions arrays.
// Possible values: AND | OR. AND is default.
iOS parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"ios_title" : { // optional. Object OR string. Adds iOS specific title for push notification.
"ios_subtitle" : { // optional. Object OR string. Adds iOS specific subtitle for push notification.
"ios_content" : { // optional. Object OR string. Adds iOS specific content for push notification.
"ios_badges" : 5 , // optional. 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 a default system sound.
"ios_sound_off" : true , // optional. Enable/disable sound set by "ios_sound" field.
"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. iOS8 category ID from Pushwoosh.
"ios_root_params" : { // optional. Root level parameters to the aps dictionary.
"content-available" : " 1 " ,
"mutable-content" : 1 // required for iOS10+ Media attachments.
"data" : {} // optional. User supplied data, max of 4KB
"ios_attachment" : " URL " , // optional. Insert media content in notification.
"ios_thread_id" : " some thread id " , // optional. Identifier to group related notifications.
// Messages with the same thread ID will be grouped
// on the lock screen and in the Notification Center.
"ios_critical" : true , // optional. Marks iOS notification as a critical alert
// playing sound even if a device is muted or
// Do Not Disturb mode is on.
"ios_category_custom" : " category " , // optional. Custom APNS category.
"ios_interruption_level" : " active " , // optional. One of "passive", "active", "time-sensitive",
// "critical". Indicates the importance and
// delivery timing of a notification. Refer to the
// One-time push guide for details.
"apns_trim_content" : 1 // optional. (0|1) Trims the exceeding content strings with ellipsis.
Android parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"android_header" : { // optional. Android notification header.
"android_content" : { // optional. Android notification content.
"android_root_params" : { // optional. Custom key-value object.
"key" : " value " , // Root level parameters for the android payload recipients.
"CancelID" : 12345678 // optional. Cancels the push notification with the
}, // specified Message ID (get the ID from the Message History)
"android_sound" : " soundfile " , // optional. No file extension. If left empty,
// the device will produce a default system sound.
"android_sound_off" : true , // optional. Enable/disable sound set by "android_sound" field
"android_icon" : " icon.png " , // optional.
"android_custom_icon" : " URL.png " , // optional. Full URL to the image file.
"android_banner" : " URL.png " , // optional. Full URL to the image file.
"android_badges" : 5 , // optional. 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 , // optional. Android force-vibration for high-priority pushes.
"android_led" : " #rrggbb " , // optional. LED hex color, device will do its best approximation.
"android_priority" : -1 , // optional. 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 " , // optional. "normal" or "high".
// Enables notification’s delivery when the
// device is in the power saving mode.
"android_ibc" : " #RRGGBB " , // optional. icon background color on Lollipop, #RRGGBB,
// #AARRGGBB, "red", "black", "yellow", etc.
"android_silent" : 1 , // optional. 0 or 1. Enable silent notification.
// Ignore sound and content
"android_group_id" : " 123 " // optional. Identifier to group related notifications. Messages with
// the same thread ID will be grouped in
// the Notification Center.
Huawei parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"huawei_android_header" : { // optional. Object OR string. Notification title
"huawei_android_content" : { // optional. Object OR string. Notification content
"huawei_android_badges" : true , // optional.
"huawei_android_silent" : 0 , // optional. 0 or 1. Enable silent notification.
// Ignore sound and content
"huawei_android_icon" : " URL.png " , // optional.
"huawei_android_led" : " #FF0011 " , // optional. LED hex color, device will do its best approximation
"huawei_android_vibration" : 1 , // optional. Huawei force-vibration for high-priority pushes
"huawei_android_sound" : " sound.wav " , // optional. If left empty, the device will produce
// a default system sound
"huawei_android_sound_off" : true , // optional. Enable/disable sound set by
// "huawei_android_sound" field
"huawei_android_custom_icon" : " URL.png " , // optional
"huawei_android_gcm_ttl" : 2400 , // optional. Time to live parameter - maximum
// message lifespan in seconds
"huawei_android_banner" : " URL.png " , // optional. Full path URL to the image file
"huawei_android_root_params" : { // optional. Custom key-value object.
"key" : " value " // Root-level parameters for Huawei payload recipients.
"huawei_android_priority" : 0 , // optional. Valid values: -2, -1, 0, 1, 2
"huawei_android_ibc" : " #0011AA " , // optional. Icon background color on Lollipop
"huawei_android_lockscreen" : 1 , // optional
"huawei_android_delivery_priority" : " normal " , // optional. "normal" or "high". Enables notification
// delivery in power saving mode
"huawei_android_group_id" : " group_id " // optional. Identifier to group related notifications
Safari parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"safari_url_args" : [ // required, but the value may be empty
"safari_title" : { // optional. Object OR string. Title of the notification.
"safari_content" : { // optional. Object OR string. Content of the notification.
"safari_action" : " Click here " , // optional.
"safari_ttl" : 3600 // optional. Time to live parameter — the maximum
// lifespan of a message in seconds.
Chrome parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"chrome_title" : { // optional. Object OR string. You can specify the header
"en" : " title " // of the message in this parameter.
"chrome_content" : { // optional. Object OR string. You can specify the content
"en" : " content " // of the message in this parameter.
"chrome_icon" : " URL.png " , // optional. Full 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. max 50 seconds. 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" : { // optional. Set parameters specific to messages sent to Chrome.
"chrome_button_text1" : " text1 " , // optional
"chrome_button_url1" : " button1_URL " , // optional. Ignored if chrome_button_text1 is not set.
"chrome_button_text2" : " text2 " , // optional
"chrome_button_url2" : " button2_url " // optional. Ignored if chrome_button_text2 is not set.
Firefox parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"firefox_title" : { // optional. Object OR string. You can specify message header here.
"firefox_content" : { // optional. Object OR string. You can specify message content here.
"firefox_icon" : " URL.png " , // optional. Full path URL to the icon or path to the
// file in extension resources.
"firefox_root_params" : { // optional. Set parameters specific to messages sent to Firefox.
Amazon parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"adm_header" : { // optional. Object OR string. You can specify message header here.
"adm_content" : { // optional. Object OR string. You can specify message content here.
"adm_root_params" : { // optional. Custom key-value object
"adm_sound" : " push.mp3 " , // optional.
"adm_sound_off" : true , // optional. Enable/disable sound set by "adm_sound" field
"adm_icon" : " icon.png " , // optional. Full URL to the icon.
"adm_custom_icon" : " URL.png " , // optional.
"adm_banner" : " URL.png " , // optional.
"adm_ttl" : 3600 , // optional. Time to live parameter — the maximum message
"adm_priority" : -1 // optional. Priority of the push in Amazon push drawer,
// valid values are -2, -1, 0, 1 and 2.
Mac OS X parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"mac_title" : { // optional. Object OR string. Adds Title for push notification.
"mac_subtitle" : { // optional. Adds subtitle for push notification.
"mac_content" : { // optional. Adds content for push notification.
"mac_badges" : 3 , // optional.
"mac_sound" : " sound.caf " , // optional.
"mac_sound_off" : true , // optional. Enable/disable sound set by "mac_sound" field
"mac_root_params" : { // optional.
"mac_ttl" : 3600 // optional. Time to live parameter — maximum message lifespan in seconds.
Windows parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"wns_content" : { // required. Content (XML or raw) of notification encoded in MIME's base64
// in form of Object OR String
"en" : " PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg== " ,
"de" : " PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4= "
"wns_type" : " Badge " , // optional. '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.
Xiaomi parameters
"application" : " 12345-67891 " , // required. Pushwoosh application code
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"xiaomi_header" : { // optional. Object OR string. Xiaomi notification header.
"xiaomi_content" : { // optional. Object OR string. Xiaomi notification content.
"xiaomi_root_params" : { // optional. Custom key-value object.
"key" : " value " // Root level parameters for the android payload recipients.
"xiaomi_sound" : " soundfile " , // optional. No file extension. If left empty,
// the device will produce a default system sound.
"xiaomi_sound_off" : true , // optional. Enable/disable sound set by "xiaomi_sound" field
"xiaomi_icon" : " icon.png " , // optional.
"xiaomi_custom_icon" : " URL.png " , // optional. Full URL to the image file.
"xiaomi_banner" : " URL.png " , // optional. Full URL to the image file.
"xiaomi_badges" : 5 , // optional. Xiaomi application icon badge number.
// Use "+n" or "-n" to increment/decrement the badge value by n.
"xiaomi_ttl" : 3600 , // optional. Time to live parameter — maximum message lifespan in seconds.
"xiaomi_vibration" : 0 , // optional. Xiaomi force-vibration for high-priority pushes.
"xiaomi_silent" : 1 , // optional. 0 or 1. Enable silent notification.
// Ignore sound and content
"xiaomi_group_id" : " 123 " // optional. Identifier to group related notifications. Messages with
// the same thread ID will be grouped in
// the Notification Center.
Caution
/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 API messaging tracing 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 code status_code Description 200 200 Message successfully created 200 210 Argument error. See status_message for more info 400 N/A Malformed request string 500 500 Internal error
Note
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.
API messaging tracing
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, use API messaging tracing . Turning this option ON allows you to override this limit for 1 hour and save such pushes in the Message History . API messaging tracing turns OFF automatically after 1 hour.
API messaging tracing can be activated on the Message History page by clicking Start API messaging tracing in the upper right corner.
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.
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.
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.
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
Valid operators: EQ, NOTSET, ANY
Valid operands: 0, 1, true, false
Valid operators: IN, NOTIN, NOTSET, ANY
Valid operands: operand must be an array of strings like ["value 1", "value 2", "value N"]
.
Note
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:
if [ ! -n " $1 " ] || [ ! -n " $2 " ]
echo " ` basename $0 ` usage: api_token appid message " ;
MESSAGE = ' One push to rule them all! '
\" content \" : \" $MESSAGE \"
-H " Content-type: application/json " \
" https://api.pushwoosh.com/json/1.3/createMessage "
define ( ' PW_AUTH ' , ' API TOKEN ' );
define ( ' PW_APPLICATION ' , ' APPLICATION CODE ' );
define ( ' PW_DEBUG ' , true );
function pwCall ( $method , $data ) {
$url = ' https://api.pushwoosh.com/json/1.3/ ' . $method ;
$request = json_encode ([ ' request ' => $ data ]);
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 );
if ( defined ( ' PW_DEBUG ' ) && PW_DEBUG ) {
print " [PW] request: $request
print " [PW] response: $response
print ' [PW] info: ' . print_r ($ info , true );
pwCall ( ' createMessage ' , array (
' application ' => PW_APPLICATION ,
' notifications ' => array (
' data ' => array ( ' custom ' => ' json data ' ),
' link ' => ' https://pushwoosh.com/ '
- 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 " ) .
application:start ( unicode ) ,
application:start ( crypto ) ,
application:start ( public_key ) ,
application:start ( inets ) ,
%% HTTP Client verbosity options flase, verbose, debug
httpc:set_options ([ {verbose, false} ]) .
application:stop ( public_key ) ,
application:stop ( crypto ) ,
encode ( S ) -> encode ( S , [ $" ]) .
encode ( [] , Acc ) -> lists:reverse ([ $" | Acc ]) ;
Hex = lists:flatten ( io_lib:format ( " ~4.16.0b " , [ C ])) ,
encode ( Cs , lists:reverse ( Hex ) ++ " u \" ++ Acc).
sendMessage(Message_text) ->
Url = " https: // api.pushwoosh.com / json / 1.3 / createMessage " ,
EncodedMessage = encode(Message_text),
{ok, Response} = httpc:request(
{Url, [{ " User - Agent " , " Erlang exemple " }], " application / json; charset = UTF - 8 " ,
\" application \" : \" " ? PW_APPLICATION " \" ,
\" auth \" : \" " ? PW_AUTH " \" ,
\" content \" : " ++ EncodedMessage ++ "
[ {ssl, [ {verify, verify_none} ] }, {version, " HTTP/1.0 " } ] ,
io:format ( " And received ~p " , [ Response ]) .
#- PushWoosh API Documentation https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/
# - 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 '
#- Change to your settings
@auth = { : application => " 00000-00000 " , : auth => " auth_token " }
# PushNotification.new.notify_all("This is a test notification to all devices")
notify_devices({: content => message})
# PushNotification.new.notify_device({
# :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'
# Object( language1: 'content1', language2: 'content2' ) OR string
# JSON string or JSON object "custom": "json data"
# omit this field (push notification will be delivered to all the devices for the application), or provide the list of devices IDs
#- 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://api.pushwoosh.com/json/1.3/createMessage " , : body => options. to_json , : headers => { ' Content-Type ' => ' application/json ' })
// Uses JSON classes from https://json.org/java/
package com.arellomobile ;
public class SendPushNotificationSample
public static final String PUSHWOOSH_SERVICE_BASE_URL = " https://api.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 ( " link " , " https://pushwoosh.com/ " )) ;
JSONObject requestObject = new JSONObject ()
. put ( " application " , APPLICATION_CODE )
. put ( " notifications " , notificationsArray ) ;
JSONObject mainRequest = new JSONObject () . put ( " request " , requestObject ) ;
JSONObject response = SendServerRequest . sendJSONRequest ( url, mainRequest . toString ()) ;
System . out . println ( " Response is: " + response ) ;
static JSONObject sendJSONRequest ( URL url , String request )
HttpURLConnection connection = null ;
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 " )) ;
return parseResponse ( connection ) ;
System . out . println ( " An error occurred: " + e . getMessage ()) ;
static JSONObject parseResponse ( HttpURLConnection connection ) throws IOException , JSONException
BufferedReader reader = new BufferedReader ( new InputStreamReader ( connection .getInputStream ())) ;
StringBuilder response = new StringBuilder () ;
while ((line = reader . readLine () ) != null )
response . append ( line ) . append ( '
return new JSONObject ( response .toString ()) ;
PW_APPLICATION_CODE = ' APPLICATION CODE '
# For Python 3.0 and later
from urllib.request import urlopen
from urllib.request import Request
# Fall back to Python 2's urllib2
from urllib2 import urlopen
from urllib2 import Request
def pw_call ( method , data ) :
url = ' https://api.pushwoosh.com/json/1.3/ ' + method
data = json. dumps ( { ' request ' : data} )
req = Request ( url , data. encode ( ' UTF-8 ' ) , { ' Content-Type ' : ' application/json ' } )
print ( ' Pushwoosh response: ' + str ( response ))
print ( ' Request error: ' + str ( e ))
if __name__ == ' __main__ ' :
pw_call ( ' createMessage ' , {
' application ' : PW_APPLICATION_CODE,
' data ' : { " custom " : " json data " },
' link ' : ' https://pushwoosh.com '
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 JProperty("send_date", "now"),
new JProperty("content", "test"),
new JProperty("wp_type", "Toast"),
new JProperty("wp_count", 3),
new JProperty("custom", "json data"))),
new JProperty("link", "https://pushwoosh.com/"),
new JProperty("conditions",
(object)new JArray("Color", "EQ", "black")))))));
PWCall("createMessage", json);
private void PWCall(string action, JObject data)
Uri url = new Uri("https://api.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";
using (var streamWriter = new StreamWriter(req.GetRequestStream()))
streamWriter.Write(data.ToString());
HttpWebResponse httpResponse;
httpResponse = (HttpWebResponse)req.GetResponse();
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);
PW_APPLICATION = " APPLICATION CODE "
PW_ENDPOINT = " https://api.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 " )
response , err := client . Do ( request )
fmt . Println ( " Error occur: " + err . Error ())
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 ))
requestData := map [ string ] interface {}{
" request " : map [ string ] interface {} {
" application " : PW_APPLICATION ,
" notifications " : [] interface {}{
" link " : " https://pushwoosh.com " ,
jsonRequest , _ := json . Marshal ( requestData )
requestString := string ( jsonRequest )
fmt . Println ( " Request body: " + requestString )
pwCall ( " createMessage " , jsonRequest )
url: " https://api.pushwoosh.com/json/1.3/createMessage " ,
" application " : " APPLICATION CODE " ,
" ignore_user_timezone " : true ,
" content " : " Hello world! "
deleteMessage
POST
https://api.pushwoosh.com/json/1.3/deleteMessage
Deletes a scheduled message.
Request Body
Name Type Description auth* string API access token from Pushwoosh Control Panel. message* string Message code obtained in /createMessage request.
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"message" : " xxxx-xxxxxxx-xxxxxx " // required. Message code obtained in /createMessage
Status codes:
HTTP Status code status_code Description 200 200 Message successfully deleted 200 210 Argument error. See status_message for more info 400 N/A Malformed request string 500 500 Internal error
// see https://gomoob.github.io/php-pushwoosh/delete-message.html
use Gomoob\Pushwoosh\Model\Request\ DeleteMessageRequest ;
// creates request instance
$request = DeleteMessageRequest :: create () -> setMessage ( ' MESSAGE_CODE ' );
// call '/deleteMessage' Web Service
$response = $pushwoosh -> deleteMessage ( $request );
print ' Great, my message has been deleted ! ' ;
print ' Oups, the deletion failed :-( ' ;
print ' Status code : ' . $response -> getStatusCode ();
print ' Status message : ' . $response -> getStatusMessage ();
getMessageDetails
POST
https://api.pushwoosh.com/json/1.3/getMessageDetails
Retrieves the message details.
Request Body
Name Type Description auth* string API access token from Pushwoosh Control Panel. message* string Message code or message ID.
"created" : " 2016-09-14 17:19:42 " ,
"send_date" : " 2016-09-14 17:19:41 " ,
"en" : " Hello {Name|CapitalizeFirst|friend}! 🚀 "
"ignore_user_timezone" : " 1 " ,
"code" : " XXXX-92B4C3C5-A7F5EF70 " ,
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"message" : " xxxx-xxxxxxx-xxxxxx " // required. message code or message ID
createTargetedMessage
POST
https://api.pushwoosh.com/json/1.3/createTargetedMessage
Creates a new targeted push notification.
Request Body
Name Type Description auth* string API access token from Pushwoosh Control Panel. devices_filter* string See remark below. send_date* string YYYY-MM-DD HH:mm or ‘now’. ignore_user_timezone boolean If ignored, UTC-0 is default for “send_date”. timezone string If ignored, UTC-0 is default for “send_date”. campaign string Code of a campaign to which you want to assign this push message. content* string Notification content. See the request example for details. transactionId string Unique message identifier to prevent duplicating messages in case of network problems. Stored on the side of Pushwoosh for 5 minutest. link string Link to be opened once a user opens a push message. minimize_link integer 0 - do not minimize, 2 - bit.ly. Default = 2. data object JSON string or JSON object. Will be passed as “u” parameter in the payload (converted to JSON string). preset string Preset code. send_rate integer Throttling. Valid values are from 100 to 1000 pushes per second. inbox_date string Specify when to remove a message from the Inbox. inbox_image string URL of the image to be shown near the message in the Inbox.
"messageCode" : " 97B0-C7473871-2FBDFDC6 "
The request cannot be fulfilled due to bad syntax.
More response examples:
"status_message" : " Errors occurred while compiling filter " ,
"message" : " Invalid tag set specification. \" ) \" expected. " ,
"status_message" : " Errors occurred while compiling filter " ,
"message" : " Application \" 11111-11111 \" not found " ,
"near" : " \" 11111-11111 \" "
"status_message" : " Errors occurred while compiling filter " ,
"message" : " Invalid character \" / \" at 1:19 " ,
Caution
The method is intended for advanced targeting of your messages, and can be used for sending messages across several or all of your apps . If you do not include Application Code in your device filters, the message will be sent to any device registered in your account, that fits the Tag conditions.
Please make sure that you target proper applications in order to avoid sending test pushes to the production application when it’s not intended.
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"devices_filter" : " A( \" XXXXX-XXXXX \" ) * T( \" City \" , EQ, \" Name \" ) " , // required. Syntax explained below
"send_date" : " now " , // optional. YYYY-MM-DD HH:mm OR 'now'
"ignore_user_timezone" : true , // optional.
"timezone" : " America/New_York " , // optional. If ignored UTC-0 is default for "send_date".
// More info https://php.net/manual/timezones.php.
"campaign" : " CAMPAIGN_CODE " , // optional. Campaign code to which you want to assign this push message.
"content" : { // optional. Object OR string. Use "wns_content" instead for Windows.
"transactionId" : " unique UUID " , // optional. Unique message identifier to prevent duplicating messages
// in case of network problems. Stored on the side of
// Pushwoosh for 5 minutes.
"rich_media" : " XXXXX-XXXXX " , // optional. Copy the Rich Media code from the URL bar of the
// Rich Media editor page in Pushwoosh Control Panel.
"link" : " https://google.com " , // optional. For deeplinks add "minimize_link": 0
"minimize_link" : 0 , // optional. 0 — do not minimize, 2 — bitly. Default = 2.
// Google URL shortener is disabled since March 30, 2019.
// Please note that shorteners have restrictions
"data" : { // optional. JSON string or JSON object.
"key" : " value " // Will be passed as "u" parameter in the payload
}, // (converted to JSON string).
"preset" : " XXXXX-XXXXX " , // optional. Push Preset Code from your Control Panel.
"send_rate" : 100 , // optional. Throttling. Valid values are from 100 to 1000 pushes/second.
"dynamic_content_placeholders" : { // optional. Placeholders for dynamic content instead of device tags.
// To save the message to the Inbox via API, use "inbox_date" or "inbox_image".
// The message is saved when at least one of these parameters is used.
"inbox_image" : " Inbox image URL " , // optional. The image to be shown near the message.
"inbox_date" : " 2017-02-02 " // optional. Specify when to remove a message from the Inbox.
// Message will be removed from Inbox at 00:00:01 UTC of
// the date specified, so the previous date is the last
// day a user can see the message in their Inbox.
// If not specified, the default removal date is the next
// day after the send date.
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"devices_filter" : " FILTER CONDITION " ,
"send_date" : " now " , // optional. YYYY-MM-DD HH:mm OR 'now'
"content" : { // optional. Object OR string.
"en" : " English " , // Use "wns_content" instead for Windows.
"ignore_user_timezone" : true , // optional.
"timezone" : " America/New_York " , // optional. If ignored UTC-0 is default for "send_date".
// More info https://php.net/manual/timezones.php.
"campaign" : " CAMPAIGN_CODE " , // optional. Campaign code to which you want to assign this push message.
// iOS related parameters
"ios_badges" : 5 , // optional. 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_sound_off" : true , // optional. Enable/disable sound set by "ios_sound" field.
"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. iOS8 category ID from Pushwoosh.
"ios_category_custom" : " category " , // optional. Custom APNS category.
"ios_root_params" : { // optional. Root level parameters to the aps dictionary.
"content-available" : " 1 " ,
"mutable-content" : 1 // required for iOS10+ Media attachments.
"attachment" : " YOUR_ATTACHMENT_URL " , // iOS10+ media attachment URL.
"data" : {} // optional. User supplied data, max of 4KB
"apns_trim_content" : 1 , // optional. (0|1) Trims the exceeding content strings with ellipsis.
"ios_title" : { // optional. Adds title for iOS push notification.
"ios_subtitle" : { // optional. Adds subtitle for iOS push notification.
"ios_content" : { // optional. Adds content for iOS push notification.
// Android related parameters
"android_root_params" : { // optional. Custom key-value object.
"key" : " value " // 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_sound_off" : true , // optional. Enable/disable sound set by "android_sound" field
"android_header" : { // optional. Object OR string. Android notification header.
"android_content" : { // optional. Object OR string. Android notification content.
"android_icon" : " icon.png " ,
"android_custom_icon" : " URL.png " , // optional. Full path URL to the image file.
"android_banner" : " URL.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 , // optional. Android force-vibration for high-priority pushes.
"android_led" : " #rrggbb " , // optional. LED hex color, device will do its best approximation.
"android_priority" : -1 , // optional. 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 " , // optional. "normal" or "high". Enables notification’s delivery
// when the device is in the power saving mode.
"android_ibc" : " #RRGGBB " , // optional. 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 parameters
"adm_root_params" : { // optional. Custom key-value object
"adm_sound_off" : true , // optional. Enable/disable sound set by "adm_sound" field
"adm_custom_icon" : " URL.png " ,
"adm_ttl" : 3600 , // optional. Time to live parameter — the maximum message
"adm_priority" : -1 , // optional. Priority of the push in Amazon push drawer,
// valid values are -2, -1, 0, 1 and 2.
// Mac OS X related parameters
"mac_sound" : " sound.caf " ,
"mac_ttl" : 3600 , // optional. Time to live parameter — maximum message lifespan in seconds.
"mac_title" : { // optional. Adds Title for push notification.
"mac_subtitle" : { // optional. Adds subtitle for MacOS push notification.
"mac_content" : { // optional. Adds content for MacOS push notification.
// Windows related parameters
"wns_content" : { // required. Content (XML or raw) of notification encoded
// in MIME's base64 in form of Object 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 parameters
"safari_title" : { // optional. Object OR string. Title of the notification.
"safari_content" : { // optional. Object OR string. Content of the notification.
"safari_action" : " Click here " , // optional.
"safari_url_args" : [ // required. but the value may be empty
"safari_ttl" : 3600 , // optional. Time to live parameter — the maximum
// lifespan of a message in seconds.
// Chrome related parameters
"chrome_title" : { // optional. You can specify the header of the message in this parameter.
"chrome_content" : { // optional. You can specify the content of the message in this parameter.
"chrome_icon" : " icon_URL " , // optional. 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" : { // optional. Set parameters specific to messages sent to Chrome.
"chrome_button_text1" : " text1 " , // optional.
"chrome_button_url1" : " button1_URL " , // optional. Ignored if chrome_button_text1 is not set.
"chrome_button_text2" : " text2 " , // optional.
"chrome_button_url2" : " button2_url " , // optional. Ignored if chrome_button_text2 is not set.
// Firefox related parameters
"firefox_title" : { // optional. Object OR string. You can specify message header here.
"firefox_content" : { // optional. Object OR string. You can specify message content here.
"firefox_icon" : " icon_URL " , // optional. Full path URL to the icon or path
// to the file in extension resources.
"firefox_root_params" : { // optional. Set parameters specific to messages sent to Firefox.
The basics are very simple – all filters are performed on the sets of entities.
Sets
Sets are defined as:
1. Devices subscribed to the particular app (A);
2. Devices that match the specified tag values (T) or app-specific tag value (AT);
3. Devices subscribed to one app of the app group (G).
Syntax
Let’s try with some samples according to the list above.
Targeting app subscribers
The “A” filter defines a set of devices subscribed to a particular app:
A(\"XXXXX-XXXXX\", [\"iOS\", \"Android\", \"OsX\", \"Windows\", \"Amazon\", \"Safari\", \"Chrome\", \"Firefox\"])
where
“XXXXX-XXXXX” – Pushwoosh Application Code
[“iOS”, “Android”, …] – array of targeted platforms. If omitted, the message will be sent to all platforms available for this app.
Filtering by tag values
The “T” filter defines a set of devices that have specified tag values assigned.
T(\"Age\", IN, [17,20])
Defines the set of the devices that have the “age” tag set to one of the values: 17, 18, 19, 20.
Caution
For app-specific tags , the “AT” filter is applied. Make sure to specify a corresponding Application Code as the first value in an AT set:
AT(“XXXXX-XXXXX”, “TagName”, EQ, “VALUE”)
Filtering by app groups
The “G” set targets devices subscribed to any of the apps in a specified app group.
G(\"11111-11111\", [\"iOS\",\"Android\"])
where
“11111-11111” – Pushwoosh App Group Code
[“iOS”, “Android”, …] – array of targeted platforms. If omitted, the message will be sent to all platforms available for this app.
The very important thing to understand is that tags are shared between the apps, and it presents a very powerful instrument for segmenting and filtering your target users without binding yourself to a particular app.
The tag could be one of the three different types: String, Integer, List . The tag type defines what operators you can use for a particular tag.
Applicable operators:
EQ – targets devices with a specified tag value
IN – targets devices with any of the specified tag values
NOTIN – targets devices with no specified tag values
NOTEQ – targets devices with a tag value not equal to a specified one
NOTSET – targets devices with no value for a specified tag
ANY – targets devices with any value set for a specified tag
Examples:
T (\"Age\", EQ, 30)
– filters users in the age of 30
T (\"favorite_color\", IN, [\"red\",\"green\",\"blue\"])
– filters users who have chosen red, green, or blue as their favorite color.
T (\"Name", NOTSET, \"\")
– target devices with no value for the Name tag.
You can use numeric values with the string tags, but such values will be converted to a string.
Applicable operators:
GTE – greater than or equal to a specified value
LTE – less than or equal to a specified value
EQ – equal to a specified value
BETWEEN – between the min and max specified values
IN – any of specified values
NOTIN – no specified values assigned to a device
NOTEQ – devices with a tag value not equal to a specified one
NOTSET – devices with no value for a specified tag
ANY – devices with any value set for a specified tag
Examples:
T (\"Level\", EQ, 14)
– filters users on the 14 level only.
T (\"Level\", BETWEEN, [1,5)
– filters users on 1, 2, 3, 4, and 5 levels.
T (\"Level", GTE, 29)
– targets users who have reached at least 29 level.
Applicable operators:
IN – devices with any of the specified tag values
Example: T("Category", IN, ["breaking_news","business","politics"])
Applicable operators:
GTE – greater than or equal to a specified value
LTE – less than or equal to a specified value
EQ – equal to a specified value
BETWEEN – between the min and max specified values
NOTEQ – devices with a tag value not equal to a specified one
NOTSET – devices with no value for a specified tag
ANY – devices with any value set for a specified tag
Examples:
AT("7777D-322A7","Last Application Open", BETWEEN, ["2022-02-28", "2022-03-02"])
AT("7777D-322A7","Last Application Open", GTE, "90 days ago")
Operations
“+” – joins two sets (equals OR)
“*” – intersects two sets (equals AND)
“\” – subtracts one set from another (equals NOT)
All the operations are left-associative. “+” and “*” have the same priority. “\” has greater priority. You can use brackets to define the priorities of the calculations.
Note that “\” operation is not commutative. A("12345-12345") \ A("67890-67890")
is not the same as A("67890-67890") \ A("12345-12345")
.
Examples
Easy:
A(\"00000-00000\", [\"iOS\"])
– all iOS devices subscribed to the app 00000-00000.
A(\"00000-00000\") * T(\"Gender\",EQ,\"F\")
– all devices subscribed to the app 00000-00000, which have the gender tag set to “female”.
A(\"00000-00000\") + G(\"11111-11111\")
– all devices subscribed to the app 00000-00000 or any of the 11111-11111 app group.
Hard:
( A(\"00000-00000\") + A(\"11111-11111\") ) \ A(\"12345-12345\")
– all devices subscribed to the app 00000-00000 or 11111-11111, which don’t have the app 12345-12345 installed.
Hardcore:
( A(\"00000-00000\") * T(\"gender\", EQ, \"M\") ) + ( A(\"12345-12345\") * T(\"gender\", EQ, \"F\") )
– targets all men with the app 00000-00000 and all girls with the app 12345-12345
getPushHistory
POST
https://api.pushwoosh.com/json/1.3/getPushHistory
Gets message history with push details.
Request Body
Name Type Description auth* string API Access token from Pushwoosh Control Panel. limitMessages integer Limits the number of messages in a response. Possible values from 10 to 1000. source string Push history source. Can be null or: “CP”, “API”, “GeoZone”, “RSS”, “AutoPush”, “A/B Test”. searchBy string Possible values to search by. Can be null or: “notificationID”, “notificationCode”, “applicationCode”, “campaignCode”. value string Search value set according to the “searchBy” field. lastNotificationID string Used for pagination. Last messageId from the previous /getPushHistory call. See details below.
"code" : " 8071-07AD1171-77238AD1 " ,
"createDate" : " 2020-09-14 12:26:21 " ,
"sendDate" : " 2020-09-14 12:26:21 " ,
"android_root_params" : null ,
"conditions_operator" : " AND " ,
"filter_code" : " E3A64-A5F3C " ,
"filter_conditions" : " #In-app Purchase(≠0) " ,
"filter_name" : " Purchased something " ,
"subscription_segments" : null ,
"code" : " 41CA-83F8E0D7-7A63822B " ,
"createDate" : " 2020-09-14 12:25:55 " ,
"sendDate" : " 2020-09-14 12:25:55 " ,
"android_root_params" : null ,
"conditions_operator" : " AND " ,
"filter_conditions" : null ,
"subscription_segments" : {
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"source" : null , // optional. Possible values are null, "CP", "API", "GeoZone",
// "RSS", "AutoPush", "A/B Test"
"searchBy" : " applicationCode " , // optional. Possible values are "", "notificationID",
// "notificationCode", "applicationCode", "campaignCode"
"value" : " C8717-703F2 " , // optional. Search value set according to the "searchBy" field.
"lastNotificationID" : 0 , // optional. Used for pagination. Last messageId from the
// previous /getPushHistory call. See details below.
"limitMessages" : 1000 // optional. Possible value from 10 to 1000.
This method will return 1000 messages from the account sorted by message Id. To get the second page, specify the last message Id of previous response in the lastNotificationId parameter.
Response data types
createDate -- string (date: %Y-%m-%d %H:%M:%S)
sendDate -- string (date: %Y-%m-%d %H:%M:%S)
content -- array ( dict {lang: value} | list [])
title -- array ( dict {lang: value} | list [])
subtitle -- array ( dict {lang: value} | list [])
ios_title -- string | array ( dict {lang: value} ) | null
ios_subtitle -- string | array ( dict {lang: value} ) | null
ios_root_params -- dict (JSON) | null
android_header -- string | array ( dict {lang: value} ) | null
android_root_params -- dict (JSON) | null
conditions -- list (JSON) | null
conditions_operator -- string | null
filter_code -- string | null
filter_name -- string | null
filter_conditions -- string | null
campaignId -- string | ""
campaignName -- string | ""
subscription_segments (obsolete) -- list (JSON) | null
data -- dict (JSON) | null
open -- dict [dict [string: int]] | "" Example: 'open': {'AAAAA-BBBBB': {'IOS': 1, 'ANDROID': 1}}
sent -- dict [dict [string: int]] | "" Example: 'sent': {'AAAAA-BBBBB': {'IOS': 10, 'ANDROID': 10}}
ctr -- dict [string: int] | "" Example: {'AAAAA-BBBBB': 1}
errors -- dict [string: int] | "" Example: {'ANDROID': 1, 'IOS': 1}
cancelMessage
POST
https://api.pushwoosh.com/json/1.3/cancelMessage
Deletes a scheduled message.
Request Body
Name Type Description auth* string API access token from Pushwoosh Control Panel. message* string The message code obtained in /createMessage response.
"auth" : " yxoPUlwqm…………pIyEX4H " , // required. API access token from Pushwoosh Control Panel
"message" : " xxxx-xxxxxxx-xxxxxx " // required. The message code obtained in /createMessage response
Status codes:
HTTP Status code status_code Description 200 200 Message successfully canceled 200 210 Argument error. See status_message for more info. 400 N/A Malformed request string 500 500 Internal error