X

List Groups

Use the API to obtain a list of the mailing groups on your account. You can use the offset and limit parameters for pagination.


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

Parameters

offset int Offset for pagination.
limit int Limit for pagination.

Request

                <?php
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://api-us1.stannp.com/v1/groups/list?api_key=" . API_KEY, false, $context);
$response = json_decode($result, true);

print_r($response);
?>
            

Response

{
    "success": true,
    "data": [
        {
            "id": "398",
            "account_id": "1",
            "name": "Test Group",
            "created": "2015-09-25 11:57:35",
            "recipients": "100",
            "valid": "98",
            "international": "0",
            "skipped": "0",
            "status": "ready",
            "import_progress": "0",
            "is_seeds": "0"
        },
        {
            "id": "390",
            "account_id": "1",
            "name": "My Data",
            "created": "2015-09-23 10:50:48",
            "recipients": "6000",
            "valid": "5872",
            "international": "0",
            "skipped": "0",
            "status": "ready",
            "import_progress": "0",
            "is_seeds": "0"
        }
    ]
}

Create a New Group

Use the API to create a new empty mailing list.


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

Parameters

name string Name of the new group to be created.

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-us1.stannp.com/v1/groups/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(
        'name' => "My Group"
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
?>
            

Response

{
    "success": true,
    "data": "39"
}

Add Recipients to Group

Use the API to add recipients from your account to an existing mailing list.


[POST] https://api-us1.stannp.com/v1/groups/add/:group_id

Parameters

recipients string Comma-separated recipient IDs.

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-us1.stannp.com/v1/groups/add/:group_id?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(
        'recipients' => "45112,45113"
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
?>
            

Response

{
    "success": true,
    "data": 2
}

Remove Recipients from Group

Remove recipients from the group. Note that this only removes the recipient from the group and does not completely delete the recipient.


[POST] https://api-us1.stannp.com/v1/groups/remove/:group_id

Parameters

recipients string Comma-separated recipient IDs.

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-us1.stannp.com/v1/groups/remove/:group_id?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(
        'recipients' => "45112,45113"
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
?>
            

Response

{
    "success": true,
    "data": 2
}

Purge a Group

Use the API to remove all recipients from the mailing list. The recipients will remain on your account if delete_recipients is set to false.


[POST] https://api-us1.stannp.com/v1/groups/purge

Parameters

id int ID of the group to purge.
delete_recipients bool True or false. Delete all recipients in this group if true. Defaults to false. WARNING: If true this will completely delete the recipients so they will not exist in any other groups if the recipient was in multiple groups.

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-us1.stannp.com/v1/groups/purge?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' => "123"
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
?>
            

Response

{
    "success": true,
    "data": true
}

Recalculate Group

Will recalculate a group to make sure stats are up to date.


[POST] https://api-us1.stannp.com/v1/groups/calculate/:group_id

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-us1.stannp.com/v1/groups/calculate/:group_id?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

{
    "success": true,
    "data": true
}

Delete a Group

Use the API to delete a mailing list. The recipients will remain on your account if delete_recipients is set to false.


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

Parameters

id int ID of the group to delete.
delete_recipients bool True or false. Defaults to false. WARNING: If true this will completely delete the recipients so they will not exist in any other groups if the recipient was in multiple groups.

Request

                <?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-us1.stannp.com/v1/groups/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' => "123"
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);
?>
            

Response

{
    "success": true,
    "data": true
}