List Recipients
Use the API to obtain a list of recipient objects. Include group_id to only return recipients in the specified group. You can use the offset and limit parameters for pagination.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-eu1.stannp.com/v1/recipients/list?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(
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
[ { "id": "1943", "account_id": "5", "title": "Mr", "firstname": "John", "lastname": "Example", "company": "Example Co", "address1": "123 Example street", "city": "Example Town", "country": "UK", "postcode": "EX12 3AB" }, { "id": "1944", "account_id": "5", "title": "Mrs", "firstname": "Jane", "lastname": "Example", "company": "Example Co", "address1": "123 Example street", "city": "Example Town", "country": "UK", "postcode": "EX12 3AB" } ]
Get a Single Recipient
Obtain the recipient object for the recipient ID specified.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-eu1.stannp.com/v1/recipients/get/1234?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(
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "id": "1943", "account_id": "5", "title": "Mr", "firstname": "John", "lastname": "Example", "company": "Example Co", "address1": "123 Example street", "city": "Example Town", "country": "UK", "postcode": "EX12 3AB" }
Create a New Recipient
Use the API to create a new recipient.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-eu1.stannp.com/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(
'firstname' => "Steve",
'lastname' => "Parish",
'address1' => "Unit 12 Taw Trade Park",
'address2' => "Suite 100",
'address3' => "Building A",
'city' => "Barnstaple",
'postcode' => "EX31 1JZ",
'country' => "GB",
'email' => "steve.parish@example.com",
'phone_number' => "+441234567890",
'ref_id' => "SP12345",
'group_id' => "123",
'on_duplicate' => "update",
'test_level' => "fullname"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "id": "1941", "valid": true }
Delete a Recipient
Use the API to permanently delete a recipient from your account.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-eu1.stannp.com/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);
?>
Response
{ "success": true }
Import a Data File
Use the API to import a data file into your account.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-eu1.stannp.com/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(
'file' => "/home/user/Desktop/data.csv",
'group_id' => "123",
'duplicates' => "update",
'no_headings' => "",
'mappings' => "title,firstname,lastname,company,address1,address2,city,postcode,country,custom,custom,skip"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true }