CreateContactWithConsent

Creates a contact with their consent information

This method creates a new contact within the account with their consent information, and adds it to the 'All contacts' address book.

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.

Note that it is possible to update an existing contact using this method. A duplicate contact will not be created. 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 with consent?

If you're looking to import or update multiple contacts with consent information at once, then we highly recommend using ImportContacts 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.

However, when using the 'ImportContacts' call with consent information, you'll need to specify the following additional column headers in your file in order to successfully import consent:

  • CONSENTTEXT
  • CONSENTURL
  • CONSENTDATETIME
  • CONSENTIP
  • CONSENTUSERAGENT

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

πŸ“˜

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 ConsentData
    • ConsentData
      • 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>)

Output parameters

  • CreateContactWithConsentResult
    • 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')
    • ConsentFields - optional; array of ConsentData
      • ConsentData
        • Key - string ('Text', 'DateTimeConsented', 'URL', 'IPAddress', 'UserAgent', 'DateTimeCreated')
        • Value - anyType

Example

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

	var contact = new ApiContactWithConsent
	{
		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" },
				}
			}
		}
	};
	var createdContact = client.CreateContactWithConsent(contact);
}