X

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.


[GET] https://api-us1.stannp.com/v1/recipients/list

Parameters

group_id int ID of the group to filter the recipients.
offset int Offset for pagination.
limit int Limit for pagination.

Request

                import requests

data = {

}

response = requests.post("https://api-us1.stannp.com/v1/recipients/list?api_key={API_KEY}", data=data)
print(response.text)
            

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.


[GET] https://api-us1.stannp.com/v1/recipients/get/1234

Parameters

id int ID of the recipient to fetch.

Request

                import requests

data = {

}

response = requests.post("https://api-us1.stannp.com/v1/recipients/get/1234?api_key={API_KEY}", data=data)
print(response.text)
            

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.


[POST] https://api-us1.stannp.com/v1/recipients/new

Parameters

firstname string Recipient's first name.
lastname string Recipient's 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...).
email string The recipient's email address.
phone_number string The recipient's phone number.
ref_id string This is an alternative ID. You can use an ID from a different service so you can always match a recipient across multiple services.
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).
test_level string This is how we test to see if this recipient is a duplicate record. You can choose from the following. Defaults to 'fullname'. - 'email' - This will match a duplicate based on the email address. - 'fullname' - This will match a duplicate based on the full name and address. - 'initial' - This will match a duplicate based on the initial of the first plus last name and address. - 'ref_id' - This will match a duplicate on any alternative ID you have stored. If you have added custom fields to your recipients you can also add them as parameters when adding new recipient records.

Request

                import requests

data = {
    "firstname": "Steve",\n    "lastname": "Parish",\n    "address1": "Unit 12 Taw Trade Park",\n    "address2": "Suite 100",\n    "address3": "Building A",\n    "city": "Barnstaple",\n    "postcode": "EX31 1JZ",\n    "country": "US",\n    "email": "steve.parish@example.com",\n    "phone_number": "+11234567890",\n    "ref_id": "SP12345",\n    "group_id": "123",\n    "on_duplicate": "update",\n    "test_level": "fullname",\n
}

response = requests.post("https://api-us1.stannp.com/v1/recipients/new?api_key={API_KEY}", data=data)
print(response.text)
            

Response

{
    "id": "1941",
    "valid": true
}


Delete a Recipient

Use the API to permanently delete a recipient from your account.


[POST] https://api-us1.stannp.com/v1/recipients/delete

Parameters

id int ID of the recipient to delete.

Request

                import requests

data = {
    "id": "12345",\n
}

response = requests.post("https://api-us1.stannp.com/v1/recipients/delete?api_key={API_KEY}", data=data)
print(response.text)
            

Response

{
    "success": true
}


Import a Data File

Use the API to import a data file into your account.


[POST] https://api-us1.stannp.com/v1/recipients/import

Parameters

file string A CSV or XLS file as binary format, a base64 encoded string of a CSV file, or a URL to a file.
group_id int ID of the group you wish to import data into.
duplicates string 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 bool 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 string 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

                import requests

data = {
    "file": "/home/user/Desktop/data.csv",\n    "group_id": "123",\n    "duplicates": "update",\n    "no_headings": "",\n    "mappings": "title,firstname,lastname,company,address1,address2,city,postcode,country,custom,custom,skip",\n
}

response = requests.post("https://api-us1.stannp.com/v1/recipients/import?api_key={API_KEY}", data=data)
print(response.text)
            

Response

{
    "success": true
}