List campaigns


https://us.stannp.com/api/v1/campaigns/list
Request
$ curl https://us.stannp.com/api/v1/campaigns/list \
-u {API_KEY}:
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://us.stannp.com/api/v1/campaigns/list?api_key=" . API_KEY, false, $context);
$response = json_decode($result, true);

print_r($response);
import requests

response = requests.get('https://us.stannp.com/api/v1/campaigns/list?api_key={API_KEY}')
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/list?api_key={API_KEY}");

var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);

Console.WriteLine(response.Content);
Toggle Response
{
   "success":true,
   "data":[
      {
         "id":"22222",
         "account_id":"123",
         "name":"4x6 Postcard test",
         "template_id":"0",
         "type":"4x6-postcard",
         "trigger_date":null,
         "send_date":null,
         "trigger_offset":null,
         "created":"2019-04-26T10:40:00Z",
         "updated":"2019-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":"6x9-postcard",
         "trigger_date":null,
         "send_date":null,
         "trigger_offset":null,
         "created":"2019-04-26T10:15:40Z",
         "updated":"2019-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.jpg"
      }
   ]
}

Get a single campaign


https://us.stannp.com/api/v1/campaigns/get/:id
Request
$ curl https://us.stannp.com/api/v1/campaigns/get/1234 \
-u {API_KEY}:
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://us.stannp.com/api/v1/campaigns/get/1234?api_key=" . API_KEY, false, $context);
$response = json_decode($result, true);

print_r($response);
import requests

response = requests.get('https://us.stannp.com/api/v1/campaigns/get/1234?api_key={API_KEY}')
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/get/1234?api_key={API_KEY}");

var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);

Console.WriteLine(response.Content);
Toggle Response
{
   "success":true,
   "data":{
      "id":"126",
      "name":"Stannp Test Campaign",
      "template_id":"111",
      "type":"4x6-postcard",
      "trigger_date":null,
      "send_date":null,
      "trigger_offset":null,
      "created":"2019-03-17 11:04:19",
      "updated":"2019-03-20 10:57:05",
      "status":"dispatched",
      "recipients_group":"15",
      "recipients_filter":"",
      "recipients_validated":"valid",
      "recipients":"232",
      "recipients_not_valid":"0",
      "updated":"2019-03-21 09:10:05",
      "cost":"0.00",
      "voucher_code":"",
      "image":"https://dash.stannp.com/api/v1/uploads/9/image-1426590259.jpg",
      "size":"4x6"
   }
}

Create a new campaign


https://us.stannp.com/api/v1/campaigns/create

Parameters

name string Name your campaign for reference.
type 4x6-postcard | 6x9-postcard | us-letter The type of campaign this will be.
template_id int A template ID to make a copy of. If left out or set to "0" then a blank template of the correct format will be used.
group_id int A group id
what_recipients all | valid | not_valid | int What recipients do you want this campaign to go to?
"all" is every recipient in the group
"valid" send to only UK / US validated addresses
"not_valid" send to only UK / US non validated addresses
"int" send to only other international addresses
code string If you have a voucher code.
Request
$ curl https://us.stannp.com/api/v1/campaigns/create \
-u {API_KEY}: \
-d "name=My Campaign" \ 
-d "type=4x6-postcard" \ 
-d "template_id=12345" \ 
-d "group_id=12345"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/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' => "4x6-postcard",
        'template_id' => "12345",
        'group_id' => "12345"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
import requests

data = {
    'name': 'My Campaign',
    'type': '4x6-postcard',
    'template_id': '12345',
    'group_id': '12345'
}

response = requests.post('https://us.stannp.com/api/v1/campaigns/create?api_key={API_KEY}', data=data)
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/create?api_key={API_KEY}");

var request = new RestRequest(Method.POST);

request.AddParameter("name", "My Campaign");
request.AddParameter("type", "4x6-postcard");
request.AddParameter("template_id", "12345");
request.AddParameter("group_id", "12345");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content)
Response
{
   "success":true,
   "data": {
      "id":"266"
   }
}

Campaign Cost


https://us.stannp.com/api/v1/campaigns/cost

Parameters

id int The id of the campaign to find out the cost of booking
Request
$ curl https://us.stannp.com/api/v1/campaigns/cost \
-u {API_KEY}: \
-d "id=12345"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/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' => "12345"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
import requests

data = {
    'id': '12345'
}

response = requests.post('https://us.stannp.com/api/v1/campaigns/cost?api_key={API_KEY}', data=data)
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/cost?api_key={API_KEY}");

var request = new RestRequest(Method.POST);

request.AddParameter("id", "12345");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content)
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",
    "total": "205.60"
}
}

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 makes changes to the design or recipient selection.
https://us.stannp.com/api/v1/campaigns/approve

Parameters

id int The id of the campaign to delete
Request
$ curl https://us.stannp.com/api/v1/campaigns/approve \
-u {API_KEY}: \
-d "id=12345"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/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' => "12345"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
import requests

data = {
    'id': '12345'
}

response = requests.post('https://us.stannp.com/api/v1/campaigns/approve?api_key={API_KEY}', data=data)
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/approve?api_key={API_KEY}");

var request = new RestRequest(Method.POST);

request.AddParameter("id", "12345");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content)
Response
{
   "success":true,
   "data":{}
}

Available Booking Dates


https://dash.stannp.com/api/v1/campaigns/availableDates

Parameters

start date YYYY-mm-dd (defaults to today)
end date YYYY-mm-dd (defaults to 30 days time)
Request
$ curl https://us.stannp.com/api/v1/campaigns/availableDates \
-u {API_KEY}: \
-d "start=2021-10-25" \ 
-d "end=2021-11-25"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/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' => "2021-10-25",
        'end' => "2021-11-25"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
import requests

data = {
    'start': '2021-10-25',
    'end': '2021-11-25'
}

response = requests.post('https://us.stannp.com/api/v1/campaigns/availableDates?api_key={API_KEY}', data=data)
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/availableDates?api_key={API_KEY}");

var request = new RestRequest(Method.POST);

request.AddParameter("start", "2021-10-25");
request.AddParameter("end", "2021-11-25");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content)
Response
{
   "success":true,
   "data": {
        "2020-07-15",
        "2020-07-16",
        "2020-07-17",
        "2020-07-20",
        "2020-07-21",
        "2020-07-22",
        "2020-07-23",
        "2020-07-24",
        "2020-07-27",
        "2020-07-28",
        "2020-07-29"
   }
}

Book a campaign

When booking your campaign payment will be taken from your balance.
https://us.stannp.com/api/v1/campaigns/book

Parameters

id int The id of the campaign to book
send_date string The dispatch date of the campaign. Must be in a YYYY-MM-DD format. eg: 2021-10-25
next_available_date bool Default as true. We will book the campaign on the next available date if your send date is not available. Set to false if you want to receive an error if the date is not available.
use_balance bool Set to true to use your balance to pay for the campaign. Default is true. If you do not pay for the campaign using balance the campaign will be scheduled but will not be posted till payment.
Request
$ curl https://us.stannp.com/api/v1/campaigns/book \
-u {API_KEY}: \
-d "id=123" \ 
-d "send_date=2021-10-25"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/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' => "123",
        'send_date' => "2021-10-25"
    ),
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
import requests

data = {
    'id': '123',
    'send_date': '2021-10-25'
}

response = requests.post('https://us.stannp.com/api/v1/campaigns/book?api_key={API_KEY}', data=data)
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/book?api_key={API_KEY}");

var request = new RestRequest(Method.POST);

request.AddParameter("id", "123");
request.AddParameter("send_date", "2021-10-25");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content)
Response
{
   "success":true,
   "data":{}
}

Delete a campaign


https://us.stannp.com/api/v1/campaigns/delete

Parameters

id int The id of the campaign to delete
Note that this will permanently delete the campaign.
Request
$ curl https://us.stannp.com/api/v1/campaigns/delete \
-u {API_KEY}: \
-d "id=0"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/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);
import requests

data = {
    'id': '0'
}

response = requests.post('https://us.stannp.com/api/v1/campaigns/delete?api_key={API_KEY}', data=data)
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/campaigns/delete?api_key={API_KEY}");

var request = new RestRequest(Method.POST);

request.AddParameter("id", "0");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content)
Response
{
   "success":true,
   "data":{}
}