List recipients


https://us.stannp.com/api/v1/recipients/list/:group_id

group_idOptionally only return recipients in a group.

You can use the offset and limit parameters for pagination as seen in the example request.

Returns

A list of recipient objects.
Request
$ curl https://us.stannp.com/api/v1/recipients/list/123 \
-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/recipients/list/123?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/recipients/list/123?api_key={API_KEY}')
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/recipients/list/123?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":"1943",
         "account_id":"5",
         "email":null,
         "title":"Mr",
         "firstname":"John",
         "lastname":"Example",
         "company":"Example Inc",
         "job_title":null,
         "address1":"123",
         "address2":"Example street",
         "address3":null,
         "city":"Example Town",
         "county":null,
         "country":"US",
         "postcode":"12345",
         "dps":"1A",
         "checksum":"3",
         "ref_id":null,
         "blacklist":"0",
         "paffed_by":"auto"
      },
      {
         "id":"1944",
         "account_id":"5",
         "email":null,
         "title":"Mrs",
         "firstname":"Jane",
         "lastname":"Example",
         "company":"Example Co",
         "job_title":null,
         "address1":"123",
         "address2":"Example street",
         "address3":null,
         "city":"Example Town",
         "county":null,
         "country":"US",
         "postcode":"12345",
         "dps":"1A",
         "checksum":"3",
         "ref_id":null,
         "blacklist":"0",
         "paffed_by":"auto"
      }
   ]
}

Get a single recipient


https://us.stannp.com/api/v1/recipient/get/:id

Returns

A recipient objects.
Request
$ curl https://us.stannp.com/api/v1/recipients/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/recipients/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/recipients/get/1234?api_key={API_KEY}')
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/recipients/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":"1943",
         "account_id":"5",
         "email":null,
         "title":"Mr",
         "firstname":"John",
         "lastname":"Example",
         "company":"Example Inc",
         "job_title":null,
         "address1":"123",
         "address2":"Example street",
         "address3":null,
         "city":"Example Town",
         "county":null,
         "country":"US",
         "postcode":"12345",
         "dps":"1A",
         "checksum":"3",
         "ref_id":null,
         "blacklist":"0",
         "paffed_by":"auto"
    }
}

Create a new recipient


https://us.stannp.com/api/v1/recipients/new

Parameters

firstname string Recipients first name
lastname string Recipients last name
address1 string Address line 1
address2 string Address line 2
address3 string Address line 3
city string Address city
state string Address state
postcode string Address postal code (zip code / postcode)
country string ISO 3166-1 Alpha 2 Country Code (GB,US,FR...)
group_id int The group ID you wish to add the data to.
on_duplicate string What to do if a duplicate is found (update/ignore/duplicate)
? ? If you have added custom fields to your recipients you can also add them as parameters when added new recipient records
Request
$ curl https://us.stannp.com/api/v1/recipients/new \
-u {API_KEY}: \
-d "group_id=1" \ 
-d "on_duplicate=update" \ 
-d "firstname=Steve" \ 
-d "lastname=Parish" \ 
-d "address1=1000 N West Street" \ 
-d "address2=Suite 1200 #1939" \ 
-d "city=Wilmington" \ 
-d "state=DE" \ 
-d "zipcode=EX31 1JZ" \ 
-d "country=US"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/v1/recipients/new?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(
        'group_id' => "1",
        'on_duplicate' => "update",
        'firstname' => "Steve",
        'lastname' => "Parish",
        'address1' => "1000 N West Street",
        'address2' => "Suite 1200 #1939",
        'city' => "Wilmington",
        'state' => "DE",
        'zipcode' => "EX31 1JZ",
        'country' => "US"
    ),
));

$response = curl_exec($curl);

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

data = {
    'group_id': '1',
    'on_duplicate': 'update',
    'firstname': 'Steve',
    'lastname': 'Parish',
    'address1': '1000 N West Street',
    'address2': 'Suite 1200 #1939',
    'city': 'Wilmington',
    'state': 'DE',
    'zipcode': 'EX31 1JZ',
    'country': 'US'
}

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

var request = new RestRequest(Method.POST);

request.AddParameter("group_id", "1");
request.AddParameter("on_duplicate", "update");
request.AddParameter("firstname", "Steve");
request.AddParameter("lastname", "Parish");
request.AddParameter("address1", "1000 N West Street");
request.AddParameter("address2", "Suite 1200 #1939");
request.AddParameter("city", "Wilmington");
request.AddParameter("state", "DE");
request.AddParameter("zipcode", "EX31 1JZ");
request.AddParameter("country", "US");

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

Delete a recipient


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

Parameters

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

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/v1/recipients/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' => "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/recipients/delete?api_key={API_KEY}', data=data)
print(response.text)
var client = new RestClient("https://us.stannp.com/api/v1/recipients/delete?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":{}
}

Delete all recipients from whole account


https://us.stannp.com/api/v1/recipients/deleteAll

Parameters

delete_all bool Set to true to confirm.
WARNING: This will completely delete all recipients in your account. This can not be reversed.
Request
$ curl https://us.stannp.com/api/v1/recipients/deleteAll \
-u {API_KEY}: \
-d "delete_all=1"
$curl = curl_init();

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

$response = curl_exec($curl);

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

data = {
    'delete_all': '1'
}

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

var request = new RestRequest(Method.POST);

request.AddParameter("delete_all", "1");

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

Import a data file


https://us.stannp.com/api/v1/recipients/import

Parameters

file mandatory A CSV or XLS file as binary format, a base64 encoded string of a CSV file or a URL to a file.
group_id mandatory Id of the group you wish to import data into.
duplicates optional What to do if a duplicate is found (update/ignore/duplicate) update = [default] Updates the duplicated record with newest data. ignore = do not add the new duplicated record. duplicate = Add all duplicate records.
no_headings optional True or false. If your CSV file hasn't got a row of heading names at the top you can set this value to true. If you do not have a heading row then you must supply the headings by using the following mappings parameter.
mappings optional If your CSV file has a heading row with names that differ to our names then you can pass a comma separated string here to remap the headings. eg: title, firstname, lastname, company, address1, address2, city, postcode, country, custom, custom, skip
"custom" means we will create a new field name matching your heading name
"skip" will ignore the column so it is not imported.

If you do not use this parameter then your heading names must match ours exactly.
title, firstname, lastname, company, job_title, address1, address2, address3, city, postcode, country
Request
$ curl https://us.stannp.com/api/v1/recipients/import \
-u {API_KEY}: \
-d "group_id=123" \ 
-F "file=@/home/user/Desktop/data.csv"
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://us.stannp.com/api/v1/recipients/import?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(
        'group_id' => "123",
        'file' => new CURLFILE('@/home/user/Desktop/data.csv')
    ),
));

$response = curl_exec($curl);

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

data = {
    'group_id': '123'
}

files = {
    file: open('@/home/user/Desktop/data.csv','rb')
}

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

var request = new RestRequest(Method.POST);

request.AddParameter("group_id", "123");
request.AddFile("file", "@/home/user/Desktop/data.csv");

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