Wooxy API v.3.0

Send Triggered Web Push

The Send Triggered Web Push method allows sending Web Push notifications to contacts added to our system and saved to a specific list. The Web Push notifications are sent from the domain where the list was created, and templates previously created and saved within our system are used.

Request

POST
https://api.wooxy.com/v3/web-push/trigger

IMPORTANT: Do not send more than 10 concurrent API requests.

Body Example

                                        {
  "contactListId": "YOUR_CONTACT_LIST_ID",
  "contact": "user@example.com",
  "templateId": "YOUR_PUSH_TEMPLATE_ID", 
  "tags": [
     "triggerTag"
  ], 
  "variables": [ 
     { 
        "name": "variableName", 
        "value": "variableValue"
     } 
  ],
  "device": "desktop or mobile", 
  "ttl": "3600" 
}
                                    

Parameters

Title Type Default Description

contactListId

required
string

ID of the contact list which the contact belongs to.  
The list should be already created in your account on Lists page:  
https://app.wooxy.com/email-list

contact

required
string

The 'email' address, 'userId' or 'phoneNumber' of the recipient stored in the corresponding contactList.

templateId

optional
string

The Push template you want to send. The template should be already created in your account on the Templates page:    
https://app.wooxy.com/templates

variables

optional
array null

You can add an associative array of custom variables that will be placed in your template which we host.
Please take into account variables usage priorities is case of conflicting variables:

  • First Priority: Variable from API request;
  • Second Priority: Variable from the Content Custom Variables;
  • Third Priority: Variable from the selected list.

variables.name

required
string

Variable name in lowerCamelCase format
WARNING: Please use only Latin lowerCamelCase format. No numbers or other symbols are allowed.

variables.value

required
string

Variable value in 'ENUM_STRING' or 'ENUM_DATE' format correspondingly

tags

optional
array null

You can add custom tags to your messages to ease stats collections (mark templates, campaigns, etc). A single tag – must not start with an underscore.

device

required
string

Add kinds of browsers to the parameter. Available options.
Important:By default, we send to both browsers:

  • desktop: Notifications will only be shown on the desktop version of the browser;
  • mobile: Notifications will only be shown on the mobile version of the browser.

ttl

optional
string "3600"

Time to live must be specified in seconds. Between 30 minutes to  72 hours.

Response

                                        {
"result": true,
"notifications": ["5e1c888bd132d5e7d00f17f8"]
}
                                    

Parameters

Title Type Description

result

boolean

The value indicates that the triggered message was successfully sent out:

  • true: The message was successfully sent out.

notifications

string

The message unique identification number in the Wooxy system. This ID number allows you to get all the statistics on each message sent.

Method Errors

                                        {
   "result": false,
   "errors": [
      "Error description text"
   ]
}
                                    
Error

“Argument contactListId must be a non-empty string”

“Argument contact must be a non-empty string”

“Argument templateId must be a non-empty string”

“Argument tags must be an array”

“Tag name must be a non-empty string”

“Tags should be 50 characters or less”

“Any tags starting with an underscore are reserved for internal use and will cause errors”

“Argument variables must be an array of arrays with \”name\” and \”value\” fields”

“name of variable must be a string”

“name of variable can not be empty”

“variable \”{name}\” is reserved and can not be added as custom variable”

“invalid name of variable {name}”

“Argument device must be a non-empty string”

“Argument device must be mobile or desktop”

“Argument ttl must be a numeric”

“Argument ttl must be between 30 minutes and 72 hours reproduced by seconds value”

“Payment required”

“Contact list with id {contactListId} not found”

“Template with id {templateId} not found”

“Contact {contact} not found in list {contactListId}”

“Contact {contact} is not active”

“Contact {contact} is not subscribed to email”

“Unable to create content from template”

“fail to publish message”

“Invalid authorization token!”

“Internal server error”

“Bad Request”

“no matches found for access token {accessToken}”

“user {id} not enabled”

“no data found for key {userId}”

“access token check failed for key\/secret $key\/$accessToken”

“Argument {argument} required”

Code Examples

PHP
                $accessToken = "YOUR_API_KEY";
$url = 'https://api.wooxy.com/v3/web-push/trigger';
$body = json_encode([
    'contactListId'=> 'YOUR_CONTACT_LIST_ID',
    'domain'=> 'senderDomain.com',
    'contact'=> 'user@example.com',
    'templateId'=> 'YOUR_TEMPLATE_ID',
    'tags'=> [
'triggerTag'
],
'variables'=> [
   [
      'name'=> 'variableName',
      'value'=>'variableValue' 
   ],
],
  'device'=> 'desktop',
  'ttl' => '3600'
]);

/**
 * Request Example
 */
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_INFILESIZE, null);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Access-Token: $accessToken",
    'Content-Type: application/json',
    'Content-Length: ' . strlen($body),
]);

$result = curl_exec($ch);
if ($result === false) {
    echo 'cURL error:' . curl_error($ch) . PHP_EOL;
} else {
    echo strval($result) . PHP_EOL;
}
curl_close($ch);