nuevoMailer API
General
For nuevoMailer SB/MB/WP and ESP v.4.
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 nuevoMailer installation url.
In these samples make sure you replace $myapiKey and $baseURL with your own api key and nuevoMailer installation url.
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 nuevoMailer installation URL and your api key.
First define your nuevoMailer installation URL and your api key.
$myapiKey = "your_own_api_key"; //From your administrators table
$baseURL = "https://mydomain.com/mailer"; //Your nuevoMailer installation URL
In each method you change the endpoint accordingly. You will see all available endpoints below.
PHP code for GET
$endpoint = "/api/v7/admin/"; //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/v7/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/v7/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/v7/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;
Administrator
HTTP method | Endpoint | Function | Notes | Api versions |
GET | /api/v7/admin | Get admin account details | Returns the administrator details owner of the api key used | 3-7 |
[
{
"idAdmin":"1",
"email":"admin@admin.com",
"name":"Master admin",
"role":"Administrator"
}
]
Subscribers
HTTP method | Endpoint | Function | Notes | Api versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/subscribers | Get all subscribers | Html (tabular) or Json depending on the accept headers sent. | 2-7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The response is an array of all subscribers that includes all fixed and custom subscriber fields:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/subscribers/email@domain.com | Get one subscriber by email | Same as above but for a specific subscriber | 2 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/subscribers/email@domain.com/lists | Get one subscriber's lists | 2 - 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response includes list IDs, names, opt-in dates and verified status.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/subscribers/email@domain.com?list=ID | Is the subscriber in this list? | false: not in list. 0: yes but unverified -1: yes and verified. |
2 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/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. | 2 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/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. | 3 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DELETE | /api/v7/subscribers/email@domain.com | Delete a subscriber | If the subscriber does not exist the "Result" is "not-found" | 2 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
POST | /api/v7/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. |
2 - 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PUT | /api/v7/subscribers/ | Suppress subscriber | 2 - 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sample response:
|
Mailing lists
HTTP method | Endpoint | Function | Notes | Api versions |
GET | /api/v7/lists | Get all lists including subscribers in total | Html (tabular) or Json depending on the accept headers sent. Response is an array of all lists fields/values including total subscribers, verified_subscribers, unverified_subscribers. |
2 - 7 |
GET | /api/v7/lists/ID | Get one list by its ID including subscribers in total | Same as above but for a specific list. | 2 - 7 |
GET | /api/v7/lists/list_name | Get one list by its name including subscribers in total | Same as above. | 2 - 7 |
DELETE | /api/v7/lists/ID | Delete a list | Response is {"result":"success"} | 2 - 7 |
POST | /api/v7/lists/ | Create a new list | Will return data about the newly created list. | 2 - 7 |
Sample data for creating a new list with POST or updating an existing list with a PUT:
So if you want to create a new list with custom settings, do a POST, grab the id of the new list and update it with a PUT.
|
||||
PUT | /api/v7/lists/ | Update a list | Will return data about the updated list in Html (tabular) or Json depending on the accept headers sent. | 2 - 7 |
Newsletters
HTTP method | Endpoint | Function | Notes | Api versions |
GET | /api/v7/newsletters | A list of titles of public newsletters | Html with a link to the newsletter page or Json depending on the accept headers sent. | 2 - 7 |
GET | /api/v7/newsletters/?format=html |
Format can be html or text. Only public newsletters are loaded. Accept: text/html => Returns a list of clickable newsletter titles. Accept: application/json => A json array of all newsletters data. |
5 - 7 | |
GET | /api/v7/newsletters/menu | Creates a drop-down menu of titles: on selection it loads the newsletter underneath in an iframe. | Html | 2 - 7. Not in ESP v.4 |
GET | /api/v7/newsletters/ID | Display a newsletter in an iframe |
Accept: text/html => Complete Html display (v1-v5)
Accept: application/json => json array of this newsletter data (v5)
|
2 - 7 |
GET |
/api/v7/newsletters/ID/links
Or /api/v7/newsletters/ID/links?start=2023-05-04&end=2023-05-29 |
Returns all clicked links for a specific newsletter with their "apiEndPoint" to retrieve subscribers (see below) | start/end dates are optional and can be used independently. If given use YYYY-MM-DD. | 2 - 7 Since v.9.9 and ESP v.4 |
GET |
/api/v7/newsletters/ID/links/subscribers
Or /api/v7/newsletters/ID/links/subscribers?start=2023-05-04&end=2023-05-29 |
Same as above but will also include subscribers. | start/end dates are optional and can be used independently. If given use YYYY-MM-DD. | 2 - 7 Since v.9.9 and ESP v.4 |
GET |
/api/v7/newsletters/ID/links?link=base64Encoded(linkURL)
Or /api/v7/newsletters/ID/links?link=base64Encoded(linkURL)?start=2023-05-04&end=2023-05-29 |
Returns all subscribers who clicked a specific link with date, IP and other data for this particular newsletter.
Sample apiEndPoint: "http://domain.com/mailer/api/v7/newsletters/ID/links?link=aHR0cHM6Ly93d3cubnVldm9tYWlsZXIuY29tL2RvY3MvaGVscF8zLnBocCNwcmVoZWFkZXJz" |
start/end dates are optional and can be used independently. If given use YYYY-MM-DD.
The linkURL should be base64 encoded. You can take it from the apiEndPoint (2 steps above) |
2 - 7 Since v.9.9 and ESP v.4 |
POST | /api/v7/newsletters/ | Create/add a newsletter | Will return the ID of the newly created newsletter. The body as string should be properly escaped. You will find an example in the file newsletter.php in your api folders. | 2 - 7 |
Sample data for creating a newsletter with POST or updating it with a PUT:
|
||||
PUT | /api/v7/newsletters/ | Update an existing newsletter | See code above. Requires ID, body, name as strings, properly escaped. Check the file newsletter.php in your api folders. | 2 - 7 |
DELETE | /api/v7/newsletters/ID | Delete a newsletter by its ID | Returns {"result":"success"} | 2 - 7 |
Campaigns
HTTP method | Endpoint | Function | Notes | Api versions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/campaigns | Returns all fields from all campaigns | 2 - 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/campaigns/ID | Returns all fields from a specific campaign | 2 - 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET | /api/v7/campaigns/ID/stats | Get campaign key statistics like in summary report | 2 - 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET |
/api/v7/campaigns/ID/links
Or /api/v7/campaigns/ID/links?start=2023-05-04&end=2023-05-29 |
Returns all clicked links in a campaign with their "apiEndPoint" to retrieve subscribers (see below) | start/end dates are optional and can be used independently. If given use YYYY-MM-DD. | 2 - 7 Since v.9.9 and ESP v.4 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET |
/api/v7/campaigns/ID/links/subscribers
Or /api/v7/campaigns/ID/links/subscribers?start=2023-05-04&end=2023-05-29 |
Same as above but will also include subscribers. | start/end dates are optional and can be used independently. If given use YYYY-MM-DD. | 2 - 7 Since v.9.9 and ESP v.4 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GET |
/api/v7/campaigns/ID/links?link=base64Encoded(linkURL)
Or /api/v7/campaigns/ID/links?link=base64Encoded(linkURL)?start=2023-05-04&end=2023-05-29 |
Returns all subscribers who clicked a specific link with date, IP and other data.
Sample apiEndPoint: "http://domain.com/mailer/api/v7/campaigns/ID/links?link=aHR0cHM6Ly93d3cubnVldm9tYWlsZXIuY29tL2RvY3MvaGVscF8zLnBocCNwcmVoZWFkZXJz" |
start/end dates are optional and can be used independently. If given use YYYY-MM-DD.
The linkURL should be base64 encoded. You can take it from the apiEndPoint (2 steps above) |
2 - 7 Since v.9.9 and ESP v.4 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
POST | /api/v7/campaigns/ | Creates a new campaign | Returns the newly created campaign details (like a GET). | 2 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PUT | /api/v7/campaigns/ | Updates a campaign. You can use all the campaign data presented below. The ID is requited. Updates all details (content, lists etc), pauses or resumes a campaign | Returns the newly created campaign details (like a GET). | 2 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
POST & PUT parameters for creating/updating a campaign
|
Sample data for creating a new campaign with POST or updating an existing campaign with PUT:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DELETE | /api/v7/campaigns/ID | Delete a campaign by its ID | Returns {"result":"success"} | 2 - 7 |
Opt-outs
HTTP method | Endpoint | Function | Notes | Api versions |
GET | /api/v7/optouts?start=2023-01-01&end=2023-02-19 | Give start-end dates in YYYY-MM-DD format.
Return in json or as a table depending on the "Accept" header. |
7 (in v.9.7) |
Subscriber tags
HTTP method | Endpoint | Function | Notes | Api versions |
GET | /api/v7/subscribertags | Response includes tag id and name.
Return in json or as a table depending on the "Accept" header. |
4 - 7 |
Sender profiles
HTTP method | Endpoint | Function | Notes | Api versions |
GET | /api/v7/senderprofiles | Response includes profile id and name.
Return in json or as a table depending on the "Accept" header. |
7
Not applicable to ESP v.4 |
API keys
You will find your api keys in your administrators page. Go to: Menu>Tools>Administrator accounts>View & edit
Make sure that the Api key belongs to an active administrator account.