This method creates a contact in your 'All contacts' address book and gives that contact ConsentInsight data and marketing preferences.
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 be used to update an existing contact. If the contact already exists, a duplicate contact will not be created, and any data provided in your request that is already held for the contact will be overwritten and updated in the system.
SOAP action: http://apiconnector.com/v2/ApiService/CreateContactWithConsentAndPreferences
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 = true },
new ApiPreference { Id = 3, IsPreference = true, IsOptedIn = true },
}
},
new ApiPreference
{
Id = 4,
IsPreference = true,
IsOptedIn = false
}
}
};
var createdContact = client.CreateContactWithConsentAndPreferencesAsync(contact).Result;
}