AddContactToAddressBook

Adds a contact to a given address book

This method adds a contact to a given address book. The contact can be new or existing. If the contact already exists, then any data provided in your request that is already held for the contact will be overwritten and updated in the system.

📘

Are you importing multiple contacts?

If you're looking to import or update multiple contacts to an address book at once, then we highly recommend using ImportContactsToAddressBook instead.

It allows you to import a file and has the benefit of being a single API call only, making it far less likely that your account will exceed its API calls per hour limit.

SOAP action: http://apiconnector.com/v2/ApiService/AddContactToAddressBook

📘

Input and output parameters

The input and output parameters for this method are:

Input parameters

  • AddressBook Id - required; integer
  • Email - required; string
  • OptInType - optional; string ('Unknown', 'Single', 'Double', 'VerifiedDouble')
  • EmailType - optional; string ('PlainText', 'Html')
  • DataFields - optional; array of ContactData
    • ContactData
      • Key - string
      • Value - anyType (please note: the data type needs to be defined for the value, such as 'string', 'numeric', 'date' or 'boolean'; e.g., for 'Firstname', the XML would need to be as follows - <apic:Value xsi:type="xsd:string">John</apic:Value>)

Output parameters

  • AddContactToAddressBookResult
    • Id - integer
    • Email - string
    • OptInType - string ('Unknown', 'Single', 'Double', 'VerifiedDouble')
    • EmailType - string ('PlainText', 'Html')
    • DataFields - optional; array of ContactData
      • ContactData
        • Key - string
        • Value - anyType
    • Status - string ('Subscribed', 'Unsubscribed', 'SoftBounced', 'HardBounced', 'IspComplained', 'MailBlocked', 'PendingOptIn', 'DirectComplaint', 'Deleted', 'SharedSuppression', 'Suppressed', 'NotAllowed', 'DomainSuppression', 'NoMxRecord')

Example

using (var client = new ApiServiceClient())
{
	client.ClientCredentials.UserName.UserName = "username";
	client.ClientCredentials.UserName.Password = "password";

		var contact = new ApiContact {
	    Email = "[email protected]",
	    OptInType = ApiContactOptInTypes.Single,
	    EmailType = ApiContactEmailTypes.Html,
	    DataFields = new[] {
			new ApiContactData { Key = "FirstName", Value = "John" },
      new ApiContactData { Key = "FullName", Value = "John Smith" }, 
      new ApiContactData { Key = "Gender", Value = "Male" },  
      new ApiContactData { Key = "LastName", Value = "Smith" },  
			new ApiContactData { Key = "Postcode", Value = "N5 1DP" }
		}
	};
	var addressBookId = 1;
	var createdContact = client.AddContactToAddressBook(addressBookId, contact);
}