https://<subdomain>.sendsmaily.net/api/history.php


Parameters

All parameters must be URL encoded.



         

Parameter

Value

start_at

History range start date. Required. Value has to be in UNIX timestamp.

end_at

History range end date. Required. Value has to be in UNIX timestamp, must not be less than start_at value.

offsetSo-called “page” number, which begins at 0. 0 gives contacts from 0 to 10000. 1 gives 10001 to 20000 etc. If not specified, 0 will be set.
limitNumber of subscribers on one “page”. If not specified, no limit will be applied. Value cap is set at 10000. If a larger value is specified, no error will be given.
actionsThis parameter is optional. If not set, all actions are included. By defining this parameter, you can choose which actions to include, by using comma separated values. Possible values: view,send,click,bounce,complaint,optin,optout,modify. Do not use spaces.

Response data

Response is returned as array of contacts’ actions that contains entries with following structure. Entries are sorted by time field in ascending order.



         

Field

Value

email

Contact’s email address.

time

Action date and time.

campaign_id

Campaign ID.

campaign_name

Campaign name.

value

Additional information about the action.

action

Action type. Possible values are - optinmodifyviewsendclickoptoutcomplaintbounce.


Example query:

  

$username = 'YOUR_USERNAME';
$password = 'YOUR_PASSWORD';
$location = 'https://<subdomain>.sendsmaily.net/api/history.php';
$dateTimeZoneTallinn = new DateTimeZone('Europe/Tallinn');
$start_at = '-15 minutes';
$end_at = 'now';

// Start date in Europe/Tallinn timestamp.
$dateTimeTallinn = new DateTime($start_at, $dateTimeZoneTallinn);
$tallinnOffset = $dateTimeZoneTallinn->getOffset($dateTimeTallinn);
$start_at = $dateTimeTallinn->getTimestamp() + $tallinnOffset;

// End date in Europe/Tallinn timestamp.
$dateTimeTallinn = new DateTime($end_at, $dateTimeZoneTallinn);
$tallinnOffset = $dateTimeZoneTallinn->getOffset($dateTimeTallinn);
$end_at = $dateTimeTallinn->getTimestamp() + $tallinnOffset;

$params = array(
  'start_at' => $start_at,
  'end_at' => $end_at,
  'offset' => 0,
  'limit' => 10000,
  'actions' => 'click,optin',
);

$query = urldecode(http_build_query($params));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $location . '?' . $query);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "{$username}:{$password}");

$result = curl_exec($ch);
curl_close($ch);

print_r($result);

 


Action types



                                        

Action

Description

bounce
Delivery to contact's email address failed. Field value contains the SMTP response code received. The most common response codes 
 

click 

Contact clicked on a link. Field value contains URL of the link.  

complaint 

Contact reported email as spam.

modify 

Contact’s data was changed. Field value contains new values of contact’s extra data.

optin 

Contact was added to Smaily database.

optout 

Contact unsubscribed.

send 

Contact received an email.

view 

Contact viewed/opened an email. Field value contains information about contact’s OS, email client, IP-address and country.