List recipients


https://dash.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.

Request
$ curl https://dash.stannp.com/api/v1/recipients/list/1234?api_key={API_KEY}&offset=0&limit=100
define("API_KEY","YOUR API KEY");
$result = file_get_contents("https://dash.stannp.com/api/v1/recipients/list?api_key=".API_KEY);
$response = json_decode($result,true);
print_r($response);
define("API_KEY","YOUR API KEY");
$result = file_get_contents("https://dash.stannp.com/api/v1/recipients/list?api_key=".API_KEY);
$response = json_decode($result,true);
print_r($response);
Toggle Response
{
   "success":true,
   "data":[
      {
         "id":"1943",
         "account_id":"5",
         "email":null,
         "title":"Mr",
         "firstname":"John",
         "lastname":"Example",
         "company":"Example Co",
         "job_title":null,
         "address1":"123",
         "address2":"Example street",
         "address3":null,
         "city":"Example Town",
         "county":null,
         "country":"GB",
         "postcode":"EX12 3AB",
         "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":"GB",
         "postcode":"EX12 3AB",
         "dps":"1A",
         "checksum":"3",
         "ref_id":null,
         "blacklist":"0",
         "paffed_by":"auto"
      }
   ]
}

Get a single recipient


https://dash.stannp.com/api/v1/recipient/get/:id
Request
$ curl https://dash.stannp.com/api/v1/recipients/get/1234?api_key={API_KEY}
define("API_KEY","YOUR API KEY");
$result = file_get_contents("https://dash.stannp.com/api/v1/recipients/get/1234?api_key=".API_KEY);
$response = json_decode($result,true);
print_r($response);
Toggle Response
{
   "success":true,
   "data":{
         "id":"1943",
         "account_id":"5",
         "email":null,
         "title":"Mr",
         "firstname":"John",
         "lastname":"Example",
         "company":"Example Co",
         "job_title":null,
         "address1":"123",
         "address2":"Example street",
         "address3":null,
         "city":"Example Town",
         "county":null,
         "country":"GB",
         "postcode":"EX12 3AB",
         "dps":"1A",
         "checksum":"3",
         "ref_id":null,
         "blacklist":"0",
         "paffed_by":"auto"
    }
}

Create a new recipient


https://dash.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
postcode string Address postal code
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://dash.stannp.com/api/v1/recipients/new?api_key={API_KEY} \
-d "group_id=1" \
-d "on_duplicate=update" \
-d "firstname=Steve" \
-d "lastname=Parish" \
-d "address1=Unit 12 Taw Trade Park" \
-d "address2=Braunton Road" \
-d "city=Barnstaple" \
-d "postcode=EX31 1JZ" \
-d "country=GB" \
-d "voucher=GT4523"
define("API_KEY","YOUR API KEY");
$postdata = http_build_query(
  array(
  	'group_id' => "1",
  	'on_duplicate' => "update",
  	'firstname' => "Steve",
  	'lastname' => "Parish",
        'address1' => "Unit 12 Taw Trade Park",
  	'address2' => "Braunton Road",   
  	'city' => "Barnstaple",
  	'postcode' => "EX31 1JZ",
  	'country' => "GB",
  	'voucher' => "GT4523"
  )
);
$opts = array('http' => array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
  )
);
$context  = stream_context_create($opts);
$result = file_get_contents("https://dash.stannp.com/api/v1/recipients/new?api_key=".API_KEY, false, $context);
$response = json_decode($result,true);
print_r($response);
Return
{
   "success":true,
   "data":{
      "id":"1941",
      "valid":true
   }
}

Delete a recipient


https://dash.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://dash.stannp.com/api/v1/recipients/delete?api_key={API_KEY} \
-d "id=123" \
Response
{
   "success":true,
   "data":{}
}

Delete all recipients from whole account


https://dash.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://dash.stannp.com/api/v1/recipients/delete?api_key={API_KEY} \
-d "id=123" \
Response
{
   "success":true,
   "data":{}
}

Validate an address

We currently can only validate UK addresses.
https://dash.stannp.com/api/v1/recipients/validate

Parameters

company string Company name
address1 string Address line 1
address2 string Address line 2
address3 string Address line 3
city string Address city
postcode string Address postal code
country string ISO 3166-1 Alpha 2 Country Code (GB,US,FR...)
Request
$ curl https://dash.stannp.com/api/v1/recipients/validate?api_key={API_KEY} \
-d "company=Stannp" \
-d "address1=Unit 1 Willow Tree Court" \
-d "address2=Roundswell Business Park" \
-d "city=Barnstaple" \
-d "postcode=EX31 3TD" \
-d "country=GB" \
Response
{
   "success":true,
   "data":{"is_valid":true}
}

Import a data file


https://dash.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://dash.stannp.com/api/v1/recipients/import?api_key={API_KEY} \
-F "file=@/home/user/Desktop/data.csv" \
-d "group_id=123"
define("API_KEY","YOUR API KEY");
$path_to_csv = "@"."/csv_file.csv"; // at symbol represents file
$post_fields = array(
   'group_id' => '123',
   'file'=> $path_to_csv
);

// using php_curl extension
$ch = curl_init();
curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER , 0 );
curl_setopt( $ch , CURLOPT_FOLLOWLOCATION , 0 );
curl_setopt( $ch , CURLOPT_URL , "https://dash.stannp.com/api/v1/recipients/import?api_key=".API_KEY );
curl_setopt( $ch , CURLOPT_POST , 1 );
curl_setopt( $ch , CURLOPT_POSTFIELDS , $post_fields );
curl_setopt( $ch , CURLOPT_RETURNTRANSFER , 1 );
curl_setopt( $ch , CURLOPT_VERBOSE , 0 );
$response = curl_exec($ch);
curl_close($ch);

$response = json_decode($result,true);
print_r($response);
Response
{
    "success": true,
    "data": true
}