Use this endpoint to create an asynchronous background job to import contacts and any associated properties in binary form using the multipart content-type. CSV files are currently the only supported file type.
Click a method to view its documentation
Privileges required: contacts:write
You can add contacts to a user's Constant Contact account by importing a file containing the contact information. Use an HTTP multipart request in a POST to this endpoint. The multipart request contains three parameters:
data, defined in the Structure section below. The file with the contact information must contain at least the email addresses for the contacts being imported.
NOTE: Set the Content-Type header to multipart/form-data.
The import file is constructed of columns containing contact properties, with rows for each contact. It needs to contain at least the email address for each contact. The following is a list of the contact properties (column headings in a spreadsheet) that can be included in the import file (these are not case sensitive):
NOTE: For Import Contacts bulk activities only, the state field is a 50 character free-form text field.
The following columns have been deprecated as of the May 5, 2014 update:
Existing integrations using these column names will not return errors, but the API ignores these columns and any values.
The size of the request payload (import file) must be less than 4 megabytes. Also, the number of contacts that you can import in a single POST is limited to 40,000. The activity request will fail if the payload is greater than 4 MBs or if there are more 40,000 contacts. Remember, the more columns or properties that you include with the imported contact, the bigger the request payload will be.
Here's an example of a multipart encoded post written in Java that adds contacts to contact list 1 (listId=1) by importing a file (contacts.txt):
final HttpClient httpclient = new DefaultHttpClient();
final HttpPost httppost = new HttpPost("https://api.constantcontact.com/v2/activities/addcontacts");
httppost.addHeader("Authorization", "Bearer 5e35af38-7b63-47cac-b484-20c4ff4d09c8");
final File fileToUse = new File("/path_to_file/contacts.txt"); //e.g. /temp/contact.txt
final FileBody data = new FileBody(fileToUse);
final String listIds = "1";
final StringBody lists = new StringBody(listIds);
final StringBody fileName = new StringBody(fileToUse.getName());
final MultipartEntity reqEntity = new MultipartEntity();
final HttpResponse response = httpclient.execute(httppost);
final HttpEntity resEntity = response.getEntity();
See a Ruby example in our Github respository here.
To see the status of an activity, make a GET call to the URI returned in the response's location header:
Poll this URI to monitor the activity status until the status is either COMPLETE or ERROR, indicating that the activity has completed processing. The response structure for this GET call is detailed here.
See also Summary Activity Reports endpoint.