evoMailer Subscriber API
General
Below you will find PHP code ready to copy-paste and use.
In these samples make sure you replace $myapiKey and $baseURL with your own api key and evoMailer installation url.
In these samples make sure you replace $myapiKey and $baseURL with your own api key and evoMailer installation url.
You will find your api key in your administrator page. Go to: Menu>Configuration>Administrator
Check also the file examples.php in the /api/ folder in your package. It includes all available methods so you can test in a very convenient way.
Response format
In most of the following examples the Accept header determines the response type.
In most of the following examples the Accept header determines the response type.
"Accept: application/json" //Returns the data as a json string
"Accept: text/html" //Returns data in a table
What's common in all methods
First define your evoMailer installation URL and your api key.
First define your evoMailer installation URL and your api key.
$myapiKey = "your_own_api_key"; //From your administrators table
$baseURL = "https://mydomain.com/mailer"; //Your evoMailer installation URL
In each method you change the endpoint accordingly. You will see all available endpoints below.
PHP code for GET
$endpoint = "/api/v1/subscribers/"; //Change here
$url = $baseURL.$endpoint;
$request = curl_init($url);
curl_setopt($request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($request, CURLOPT_FRESH_CONNECT, true);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_POST, 0);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_TIMEOUT, 30);
curl_setopt($request, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($request, CURLOPT_HTTPHEADER, array(
"X-Apikey: ".$myapiKey,
"Accept: application/json", //Or text/html to rerurn data in a table.
"Content-type: application/json"
));
$response = curl_exec($request);
//if($errno = curl_errno($request)) {$error_message = curl_strerror($errno);echo "CURL error ({$errno}):\n {$error_message}"; }
echo $response;
PHP code for POST
With a POST we are sending data so we must also define $DataToUse. You will see examples below specific to each case.
With a POST we are sending data so we must also define $DataToUse. You will see examples below specific to each case.
$endpoint = "/api/v1/subscribers"; //Change here
$url = $baseURL.$endpoint;
$request = curl_init($url);
curl_setopt($request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($request, CURLOPT_FRESH_CONNECT, true);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_POST, 1);
curl_setopt($request, CURLOPT_POSTFIELDS, $DataToUse); //Change here
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_TIMEOUT, 5);
curl_setopt($request, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($request, CURLOPT_HTTPHEADER, array(
"X-Apikey: ".$myapiKey,
"Accept: application/json",
"Content-Type: application/json",
"Content-Length: " . strlen($DataToUse) //Change here
));
$response = curl_exec($request);
//if($errno = curl_errno($request)) {$error_message = curl_strerror($errno);echo "CURL error ({$errno}):\n {$error_message}"; }
echo $response;
PHP code for DELETE
$endpoint = "/api/v1/subscribers/email@domain.com"; //Change here
$url = $baseURL.$endpoint;
$request = curl_init($url);
curl_setopt($request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($request, CURLOPT_HTTPHEADER, array("X-Apikey: ".$myapiKey));
$response = curl_exec($request);
//if($errno = curl_errno($request)) {$error_message = curl_strerror($errno);echo "CURL error ({$errno}):\n {$error_message}"; }
echo $response;
PHP code for PUT
With a PUT we are also sending details about what to update so we must also define $DataToUse. You will see examples below specific to each case.
With a PUT we are also sending details about what to update so we must also define $DataToUse. You will see examples below specific to each case.
$endpoint = "/api/v1/subscribers"; //Change here
$url = $baseURL.$endpoint;
$request = curl_init($url);
curl_setopt($request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_POST, 1);
curl_setopt($request, CURLOPT_POSTFIELDS, $DataToUse); //Change here
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($request, CURLOPT_HTTPHEADER, array(
"X-Apikey: ".$myapiKey,
"Content-Type: application/json",
"Accept: application/json",
"Content-Length: " . strlen($DataToUse) //Change here
));
$response = curl_exec($request);
//if($errno = curl_errno($request)) {$error_message = curl_strerror($errno);echo "CURL error ({$errno}):\n {$error_message}"; }
echo $response;
Subscribers
HTTP method | Endpoint | Function | Notes | Api versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v1/subscribers | Get all subscribers | Html (tabular) or Json depending on the accept headers sent. | v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The response is an array of all subscribers that includes all fixed and custom subscriber fields:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v1/subscribers/email@domain.com | Get one subscriber by email | Same as above but for a specific subscriber | v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v1/subscribers/email@domain.com/lists | Get one subscriber's lists | v1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response includes list IDs, names, opt-in dates and verified status.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v1/subscribers/email@domain.com?list=ID | Is the subscriber in this list? | false: not in list. 0: yes but unverified -1: yes and verified. |
v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v1/subscribers?list=ID | All subscribers (emails) under a list. | It is like a GET for all subscribers but in this case it is limited to a specific list. | v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /apiv3/fields | Custom subscriber fields | Returns a json string with the idCustomField as id, reference name (key) and display name (label) of all active custom subscriber fields. | v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DELETE | /api/v1/subscribers/email@domain.com | Delete a subscriber | If the subscriber does not exist the "Result" is "not-found" | v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
POST | /api/v1/subscribers/ | Add a new subscriber. But in addition you can, Remove globally or from list(s). Create a transactional email. Update existing. With or w/o double opt-in. With or w/o sending greeting emails. The post is rerouted to optIn.php (or optOut.php). For a complete list of arguments and features see below. |
v1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PUT | /api/v1/subscribers/ | Suppress subscriber | v1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|