Trigger API
Introduction
The Splio Trigger API allows authorized users to send a message from their universe to a group of users.
Messages are identified by their ID in Splio (9 alpha-numeric characters) and recipient by their email. System fields (firstname
, lastname
…) and custom fields to be used in the message can also be specified.
There will be a campaign per day (French time) per message in Splio allowing users to check statistics.
You can also refer to this page for a summary of our messaging features.
Access
Base URL
Like other Splio APIs, the base URL depends on the hosting location of the universe.
If you’re unsure about the hosting location of your universe, please ask your Customer Success Manager.
The API is available at the following URLs using the GET or the PUT method.
- Europe hosting: https://s3s.fr/api/trigger/nph-10.pl
- Authentication
To access the API, a Splio universe is needed along with a Trigger API-specific key, which will be created upon request.
Parameters
Hereafter is a list of mandatory and supported parameters which can be used with the API:
Pre-requisite | Details | Kind |
---|---|---|
universe | Marketing Automation universe | Mandatory |
key | API key | Mandatory |
message | message ID | Mandatory |
rcpts | JSON array containing each recipient | Mandatory |
opcode | Campaign operation code | Optional |
category | Campaign category | Optional |
pool | Allows you to define the IP pool that will send your triggered emails: If you don’t mention the pool parameter, the Trigger API will use the IP pool set on your universe by default.Note: to be available, the pool you’ll set on your API call must have been made available on Splio side: if there is a doubt, contact Splio support to ensure your setup is complete. | Optional, only if you use several IP pools |
Values containing special characters should be URL-encoded.
The rcpts JSON array must at least contain one element. This must be a JSON object which can have the following properties. The values must be UTF8 encoded and JSON formatted.
Field | Details | Kind |
---|---|---|
Mandatory | ||
firstname | Optional | |
lastname | Optional | |
cellphone | Numbers only, international format without leading + | Optional |
cx | Where x is the custom field id (usually between 0 and 31) | Optional |
Remarks
The recipient's list should not contain duplicate emails. If so, only one of them will be sent randomly. However if subsequent calls to the API contain the same email, each of them will be sent.
Example
If your universe is "customer", the message id is "6HIb4XwaP" and you want to send it to two contacts
named John Doe, email "[email protected]" with a custom field (id=0) "client id" of "123456"
named Jane Doe email "[email protected]" with a custom field (id=0) "client id" of "123457"
The JSON array should be like this one:
[
{
"firstname": "John",
"email": "[email protected]", "c0": "123456",
"lastname": "Doe"
},
{
"firstname": "Jane",
"email": "[email protected]", "c0": "123457",
"lastname": "Doe"
}
]
Resulting in the URL:
https://s3s.fr/api/trigger/nph- 9.pl?universe=customer&key=954ac5fbfab5760dc62b04238b1157027e65a599&opco de=O12345&category=category&message=6HIb4XwaP&rcpts=%5B%7B%22firstname%22%3A%22John%22%2C%22email%22%3A%22test%40customer.com%22%2C%22c0% 22%3A%22123456%22%2C%22lastname%22%3A%22Doe%22%7D%2C%7B%22firstname%22%3A%22Jane%22%2C%22email%22%3A%22test2%40customer.com%22%2C%22c0%22%3A%22123457%22%2C%22lastname%22%3A%22Doe%22%7D%5D
PHP example, method GET
<?php
$universe = 'customer';
$pass = '954ac5fbfab5760dc62b04238b1157027e65a599'
$service_url = 'https://s3s.fr/api/trigger/nph-9.pl';
// Build a json array of recipient using data from DB or csv file
$rcpts = array ( array (
'email' => '[email protected]', 'firstname' => 'John',
'lastname' => 'Doe', 'c0' => '123456'
),
array (
'email' => '[email protected]', 'firstname' => 'Jane',
'lastname' => 'Doe',
'c0' => '123457'
),
);
// declare other sending parameters
$params = array(
'universe' => $universe, // your universe
'key' => $pass, // your secret key
'opcode' => 'O12345', // operation code to be used
'message' => '6HIb4XwaP', // EF4 message id
'rcpts' => json_encode($rcpts), // recipients
);
// encode all parameters including JSON array
$url = $service_url . '?'. http_build_query($params);
// API call using curl library
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
// turn of SSL check just for the example. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// can solve problems with curl
curl_setopt($curl, CURLOPT_HTTPHEADER,array("Expect:"));
// actual call
$curl_response = curl_exec($curl); curl_close($curl);
// print the server response var_dump($curl_response);
// and the json received var_dump(json_decode($curl_response, true))
?>
PHP example, method POST
<?php
$universe = 'customer';
$pass = '954ac5fbfab5760dc62b04238b1157027e65a599';
$service_url = 'https://s3s.fr/api/trigger/nph-9.pl';
// Build a json array of recipient using data from DB or csv file
$rcpts = array ( array (
'email' => '[email protected]', 'firstname' => 'John',
'lastname' => 'Doe', 'c0' => '123456'
),
array (
'email' => '[email protected]',
'firstname' => 'Jane',
'lastname' => 'Doe', 'c0' => '123457'
),
);
// declare other sending parameters
$params = array(
'universe' => $universe, // your universe
'key' => $pass, // your secret key
'opcode' => 'O12345', // operation code to be used
'message' => '6HIb4XwaP', // EF4 message id
'rcpts' => json_encode($rcpts), // recipients
);
// encode all parameters including JSON array
$params_str = http_build_query($params);
// API call using curl library
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $service_url);
// turn of SSL check just for the example. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// can solve problems with curl
curl_setopt($curl, CURLOPT_HTTPHEADER,array("Expect:"));
// setup POST request curl_setopt($curl,CURLOPT_POST, count($params)); curl_setopt($curl,CURLOPT_POSTFIELDS, $params_str);
// actual call
$curl_response = curl_exec($curl); curl_close($curl);
// print the server response var_dump($curl_response);
// and the json received var_dump(json_decode($curl_response, true))
?>
Return values and error codes
The Trigger API returns with an HTTP code of 200 (ok), 400 (error, typically missing/wrong parameters), or 500 (internal server error, please contact us if this happens).
It also provides a JSON message containing the code, status, and message.
Results properties
Status | Result |
---|---|
todo | email received count |
done | valid email count |
campaign_id | Splio campaign id of this call |
Examples
If everything is ok:
{"status":"ok","result":{"done":2,"campaign_id":"6VS8HJtyH","todo":2},"message":"ok","code": 200}
If a parameter is missing, the key is incorrect, etc.:
{"status":"error","message":"incorrect/missing parameters","code":400}
Updated 5 months ago