Adding a Contact to a List


You manage a particular contact's subscription to contact lists by modifying the contact's detail data.  The contact list subscriptions are described in <ContactLists> element of a contact's details.  Each contact list to which the contact has subscribed is described in <ContactList> element inside <ContactLists>. You add a contact to a contact list by adding another <ContactList> element for the contact list to which you are adding the contact.  You remove a contact from a contact list by removing the corresponding <ContactList> element for the contact list from <ContactLists> group node.


NOTE: The various elements in the Contact XML used to create and update contacts are subject to field length limitations. Please see the Contacts Collection and Resource reference for details. XML that violates these field length constraints will be rejected.


After manipulating the XML to contain only the contact lists in which you want to keep the contact, you need to issue the PUT method against the contact resource:{username}/contacts/{contact-id}

See below an example of the XML required to associate existing contact with contact lists 1, 11, 12 and 14 in the joesflowers account. Note that after the PUT, contact will be on ONLY contact lists 1, 11, 12 and 14 and will be removed from any other lists the contact was on previously.  in other words, you want to include contact lists on which you want to leave the contact after the update.


<entry xmlns="">
<title type="text">Contact:</title>
<author> </author>
<content type="application/vnd.ctct+xml">
<Contact xmlns="" id="">
<ContactList id=""></ContactList>
<ContactList id=""></ContactList>
<ContactList id=""></ContactList>
<ContactList id=""></ContactList>


Note that <OptInSource> element is required, and must be ACTION_BY_CUSTOMER for any contact list that was not included in a sign up form.  In other words, if the user is subscribing to a list, you can use ACTION_BY_CONTACT, but if the account owner is adding a user on his or her behalf through this API, then you must use ACTION_BY_CUSTOMER


Setting the Opt In Source to ACTION_BY_CONTACT will trigger any applicable emails to go out to the contact, such as welcome emails or change of interest emails.  Setting the Opt In Source to ACTION_BY_CUSTOMER  will suppress those emails, but will still trigger Autoresponder emails, if applicable (please note that autoresponder emails are only triggered for contacts that are not on any existing lists at the time that they are added to a list that is set to receive autoresponders).