UpdateContactWithConsentAndPreferences

This method updates a contact with ConsentInsight data and marketing preferences if that contact has a given ID in your account . This information replaces any existing information for the contact.

Setting the OptInType to 'VerifiedDouble' will result in a double opt-in confirmation email being sent to the contact. The result will state that the contact's OptInType is 'Double' and Status is 'PendingOptIn'. These will only update to 'VerifiedDouble' and 'Subscribed' respectively once the contact has clicked the link in the confirmation email, at which point they will be added to the account.

To opt in contacts to preferences, set the isOptedIn key to true

To opt out contacts from preferences, set the isOptedIn key to false, or do not specify those preferences in the request body.

Note that this method can also be used to create a contact. To do this, enter an email address that doesn't already exist in your account. The contact will be created (with a valid ID) in the 'All contacts' address book.

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

📘

Input and output parameters

The input and output parameters for this method are:

Input parameters

  • 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>
  • ConsentFields - optional; array of ContactData
    ContactData
    Key - string ('Text', 'DateTimeConsented', 'URL', 'IPAddress', 'UserAgent')
    _ Value - _anyType* (please note: the data type needs to be defined for the value, such as 'string', 'numeric', 'date' or 'boolean'; e.g., for 'Text', the XML would need to be as follows - <apic:Value xsi:type="xsd:string">Your consent text goes here</apic:Value>
  • Preferences - optional; array of Preferences
    Preference
    Key - string ('id', 'isPreference', 'preferences', 'isOptedIn')
    _ Value - _anyType* (please note: the data type needs to be defined for the value, such as 'string', 'numeric', 'date' or 'boolean'; e.g., for 'isOptedIn', the XML would need to be as follows - <apic:Value xsi:type="xsd:boolean">true</apic:Value>

Output parameters

  • CreateContactResult
    • Id - integer
    • Email - string
    • OptInType - string ('Unknown', 'Single', 'Double', 'VerifiedDouble')
    • EmailType - string ('PlainText', 'Html')
    • DataFields - optional; array of ContactData
      • ContactData
        • Key - string
        • Value - anyType
    • ConsentFields - optional; array of ContactData
      • ContactData
        • Key - string
        • Value - anyType
    • Preferences- optional; array of Preferences
      • Preference
        • 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 ApiContactWithConsentAndPreferences
    {
        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" }
            }
        },
        ConsentFields = new[]
        {
            new ApiConsent
            {
                Fields = new[]
                {
                    new ApiContactData() { Key = "text", Value = "Your consent text goes here." },
                    new ApiContactData() { Key = "datetimeconsented", Value = "2020-01-01T09:40:18.527Z" },
                    new ApiContactData() { Key = "url", Value = "https://www.example.com/signup/" },
                    new ApiContactData() { Key = "ipaddress", Value = "127.0.0.1" },
                    new ApiContactData() { Key = "useragent", Value = "Mozilla/5.0 (X11; OpenBSD i386) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36" },
                }
            }
        },
        Preferences = new[]
        {
            new ApiPreference
            {
                Id = 1,
                IsPreference = false,
                Preferences = new[]
                {
                    new ApiPreference { Id = 2, IsPreference = true, IsOptedIn = false },
                    new ApiPreference { Id = 3, IsPreference = true, IsOptedIn = false },
                }
            },
            new ApiPreference
            {
                Id = 4,
                IsPreference = true,
                IsOptedIn = true
            }
        }
    };

    var createdContact = client.UpdateContactWithConsentAndPreferencesAsync(contact).Result;
}