Send Triggered Email
The Send Triggered Email method allows sending email messages to contacts that have been added to our system and saved to a list. The emails are sent from the domain where the list was created, and templates previously designed and saved within our system are used.
Request
IMPORTANT: Do not send more than 10 concurrent API requests.
Body Example
{
"contactListId": "YOUR_CONTACT_LIST_ID",
"contact": "user@example.com",
"templateId": "YOUR_TEMPLATE_ID",
"ignoreBlackList": false,
"tags": [
"triggerTag"
],
"variables": [
{
"name": "newVariableName1",
"value": "newVariableValue1"
},
{
"name": "newVariableName2",
"value": "YYYY-MM-DD"
}
]
}
Parameters
Title | Type | Default | Description |
---|---|---|---|
contactListId required
|
string |
ID of the contact list to which the contact belongs. |
|
contact required
|
string |
The |
|
templateId required
|
string |
The template you want to send. The template should be already created in your account on Templates page: https://app.wooxy.com/templates. |
|
ignoreBlackList optional
|
boolean | false |
By setting the filter to true, your message will bypass all unsubscribes and suppressions in all lists.
|
tags optional
|
array | null |
An array of string to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors. |
variables optional
|
array | null |
You can add an associative array of custom variables which will be placed in your template which we host.
|
variables.name required
|
string |
Variable name in lowerCamelCase format. |
|
variables.value required
|
string |
Variable value in |
Response
{
"result": true,
"messageId": "5d91513fd132d5f462796870"
}
Parameters
Title | Type | Description |
---|---|---|
result |
boolean |
The value indicates that the triggered message was successfully sent out:
|
messageId |
string |
The message unique identification number is 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"
]
}
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}” |
“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” |
“Contact {contact} has not email address” |
“Unable to create html and text versions form 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
$accessToken = "YOUR_API_KEY";
$url = 'https://api.wooxy.com/v3/mailer/trigger';
$body = json_encode([
'contactListId' => 'YOUR_CONTACT_LIST_ID',
'contact' => 'user@example.com',
'templateId' => 'YOUR_TEMPLATE_ID',
'tags' => [
'triggerTag'
],
'variables' => [
[
'name' => 'newVariableName1',
'value' => 'newVariableValue1'
],
[
'name' => 'newVariableName2',
'value' => 'YYYY-MM-DD'
]
],
]);
/**
* 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);