List campaigns
Use the API to get a list of your campaigns.
Request
<?php
define("API_KEY", "YOUR API KEY");
$opts = array(
'http' => array(
'method' => 'GET',
'header' => 'Content-type: application/x-www-form-urlencoded'
)
);
$context = stream_context_create($opts);
$result = file_get_contents("https://api-us1.stannp.com/v1/campaigns/list?api_key=" . API_KEY, false, $context);
$response = json_decode($result, true);
print_r($response);
?>
Response
{ "success": true, "data": [ { "id": "222", "account_id": "9", "name": "a5 test", "template_id": "0", "type": "a5-postcard", "trigger_date": null, "send_date": null, "trigger_offset": null, "created": "2015-04-26T10:40:00Z", "updated": "2015-04-26T10:40:00Z", "status": "draft", "recipients_group": "0", "recipients_filter": "", "recipients_validated": "valid", "recipients": "0", "recipients_not_valid": "0", "dispatched": "0", "cost": "0.00", "voucher_code": "", "image": null }, { "id": "221", "account_id": "9", "name": "April Campaign", "template_id": "195", "type": "a6-postcard", "trigger_date": null, "send_date": null, "trigger_offset": null, "created": "2015-04-26T10:15:40Z", "updated": "2015-04-26T10:15:40Z", "status": "draft", "recipients_group": "0", "recipients_filter": "", "recipients_validated": "valid", "recipients": "0", "recipients_not_valid": "0", "dispatched": "0", "cost": "0.00", "voucher_code": "", "image": "https:\/\/dash.stannp.com\/api\/v1\/uploads\/9\/image-1430044053.webp" } ] }
Get a single campaign
Use the API to get the details for a campaign specified with id.
Request
<?php
define("API_KEY", "YOUR API KEY");
$opts = array(
'http' => array(
'method' => 'GET',
'header' => 'Content-type: application/x-www-form-urlencoded'
)
);
$context = stream_context_create($opts);
$result = file_get_contents("https://api-us1.stannp.com/v1/campaigns/get/:id?api_key=" . API_KEY, false, $context);
$response = json_decode($result, true);
print_r($response);
?>
Response
{ "success": true, "data": { "id": "126", "name": "Stannp Test Campaign", "template_id": "111", "type": "a6-postcard", "trigger_date": null, "send_date": null, "trigger_offset": null, "created": "2015-03-17 11:04:19", "updated": "2015-03-21 09:10:05", "status": "dispatched", "recipients_group": "15", "recipients_filter": "", "recipients_validated": "valid", "recipients": "232", "recipients_not_valid": "0", "cost": "0.00", "voucher_code": "", "image": "https:\/\/dash.stannp.com\/api\/v1\/uploads\/9\/image-1426590259.webp", "size": "A6" } }
Create a new campaign
Use the API to create a campaign on our platform.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/campaigns/create?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'name' => "My Campaign",
'type' => "A6-postcard",
'template_id' => "12345",
'group_id' => "12345"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": { "id": "266" } }
Produce a sample
Use the API to produce a PDF sample of your campaign. This link will be valid for 30 minutes.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/campaigns/sample?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'id' => "0"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": "https:\/\/stannpstorage.blob.core.windows.net\/pdf-samples\/12345_12345678_sample_11234567890-GDBNYWVCJBJIBVGGVC.pdf" }
Approve a campaign
When approving a campaign you take full responsibility for any spelling mistakes or design flaws. Once approved we will select all recipient data at this point and future changes to the same data will not apply to this campaign. This campaign will then be locked so you will be unable to make changes to the design or recipient selection.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/campaigns/approve?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'id' => "0"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": true }
Campaign Cost
Use the API to obtain the rates of your campaign and the breakdown of recipients.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/campaigns/cost?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'id' => "0"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": { "rate": "0.41", "non_valid_rate": "0.51", "delivery_rate": "0.00", "international_rate": "0.00", "valid": "14.35", "not_valid": "191.25", "international": "0.00", "delivery_charge": "0.00", "net": "205.60", "vat": "41.12", "total": "246.72" } }
Available Booking Dates
Use the API to get the available dates you can use to book your campaign.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/campaigns/availableDates?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'start' => "2024-11-21",
'end' => "2024-12-21"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": [ "2024-10-09", "2024-10-10", "2024-10-11", "2024-10-12", "2024-10-13", "2024-10-14", "2024-10-15", "2024-10-16", "2024-10-17", "2024-10-18", "2024-10-19" ] }
Book a campaign
When booking your campaign, payment will be taken from your balance.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/campaigns/book?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'id' => "0",
'send_date' => "2024-11-21",
'use_balance' => "1"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": true }
Delete a campaign
Use the API to delete a campaign. You can only delete campaigns that have not been booked. Note that this will permanently delete the campaign.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/campaigns/delete?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'id' => "0"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": 1 }