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
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/recipients/list?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
[ { "id": "1943", "account_id": "5", "title": "Mr", "firstname": "John", "lastname": "Example", "company": "Example Co", "address1": "123 Example street", "city": "Example Town", "country": "CA", "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": "CA", "postcode": "EX12 3AB" } ]
Get a Single Recipient
Obtain the recipient object for the recipient ID specified.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/recipients/get/1234?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
{ "id": "1943", "account_id": "5", "title": "Mr", "firstname": "John", "lastname": "Example", "company": "Example Co", "address1": "123 Example street", "city": "Example Town", "country": "CA", "postcode": "EX12 3AB" }
Create a New Recipient
Use the API to create a new recipient.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/recipients/new?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
request.AddParameter("firstname", "Steve");
request.AddParameter("lastname", "Parish");
request.AddParameter("address1", "Unit 12 Taw Trade Park");
request.AddParameter("address2", "Suite 100");
request.AddParameter("address3", "Building A");
request.AddParameter("city", "Barnstaple");
request.AddParameter("postcode", "EX31 1JZ");
request.AddParameter("country", "US");
request.AddParameter("email", "steve.parish@example.com");
request.AddParameter("phone_number", "+11234567890");
request.AddParameter("ref_id", "SP12345");
request.AddParameter("group_id", "123");
request.AddParameter("on_duplicate", "update");
request.AddParameter("test_level", "fullname");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
{ "id": "1941", "valid": true }
Delete a Recipient
Use the API to permanently delete a recipient from your account.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/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 }
Import a Data File
Use the API to import a data file into your account.
Request
using RestSharp;
var client = new RestClient("https://api-us1.stannp.com/v1/recipients/import?api_key={API_KEY}");
var request = new RestRequest(Method.POST);
request.AddParameter("file", "/home/user/Desktop/data.csv");
request.AddParameter("group_id", "123");
request.AddParameter("duplicates", "update");
request.AddParameter("no_headings", "");
request.AddParameter("mappings", "title,firstname,lastname,company,address1,address2,city,postcode,country,custom,custom,skip");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Response
{ "success": true }