Jump to content

AddSubscriber

Adds a new subscriber's email address to a contact list. To add a subscriber and specify custom field data at the same time, To add a subscriber with custom field data, use the AddSubscriberWithCustomFields method.

Parameters

ApiKey (Required)
    Your application authentication key. Click here to find out more.
ListID (Required)
    The ID number of the list to which the subscriber should be added. Click here to find out more.
Email (Required)
    The email address of the new subscriber.

Return Value

On success, this method returns a "success" response (code 0). On failure, a SOAP fault exception is thrown with one of the fault codes below.

Usage Notes

AddSubscriber should be used to add new subscribers. If the specified email is already in the list, regardless of their status (even if "unsubscribed"), the method will return a fault response to that effect, and you should use ModifySubscriber to update their information instead.

New subscribers added through the API are always automatically saved with the Confirmed status (i.e. no double opt-in).  If you wish to add a subscriber and mark them as Unconfirmed, use the AddSubscriber method to add them, and invoke the ModifySubscriber (or ModifySubscriberWithCustomFields) method to update their status.

Fault Codes

1 - Invalid Email Address
    The email value is malformed or invalid
2 - Subscriber Already Exists
    The email already exists in the specified list
20 - Invalid ListID
    The Associated List is not valid
100 - Invalid API Key
    The API key is not valid or expired

SOAP Sample Request


    
    
        
            
                STRING
                INT
                STRING
            
        
    

SOAP Sample Response


    
    
        
            
                INT
                STRING
            
        
    

Code Sample - PHP

// Import the eConnect Email API Toolkit
require_once('eConnectEmail_API_Toolkit.php');

$eConnectEmailApi = TheKeyMakerClient('YOUR_API_KEY');

$result = $eConnectEmailApi->AddSubscriber(LIST_ID, 'EMAIL_ADDRESS');

// Show the results
print 'Response: <pre>';
print_r($result);
print '</pre>';

Code Sample - ASP.NET C#

string apiKey = "YOUR_API_KEY";
int ListID = LIST_ID;
string Email = "EMAIL_ADDRESS";
string RetVal = "";
TheKeyMaker_v20 api = new TheKeyMaker_v20();
try
{
    // Set up input parameters
    EmailParams emailParams = new EmailParams();
    emailParams.ApiKey = apiKey;
    emailParams.ListID = ListID;
    emailParams.Email = Email;

    // Invoke method and store result
    CodeReturnValues addsubReturn = api.AddSubscriber(emailParams);

    // Display results
    RetVal = FormatValue("Code", addsubReturn.Code.ToString())
        + FormatValue("Response", addsubReturn.Response);
}
catch (Exception ex)
{
    RetVal = "ERROR: " + ex.Message + "

" + ex.StackTrace;
}