Constant Contact Web Service APIs

What APIs Exist?

Constant Contact offers several interrelated APIs as follows:

REST APIs - These APIs provide the ability to access and manage contacts individually or in bulk operations and provide access to summary campaign results. These APIs are intended to be the primary APIs for accessing and managing the information associated within an Account Owner (Constant Contact User). Specifically, the APIs provide the ability to:

Learn more about the REST APIs...

Site Visitor APIs - This set of legacy APIs provide the ability to manage individual contacts. These APIs provide a subset of the functionality of the REST APIs discussed above. For new development projects, the REST APIs should be used rather than these APIs.
Learn more about the Site Visitor APIs...

Partner / Site Owner Management APIs - These APIs provide Constant Contact designated Partner Organizations to programmatically create and manage Constant Contact accounts. Access to the Partner/Subscriber APIs is exclusive to designated partners.
Learn more about the Site Owner Management APIs...

The above APIs vary in their structure and access control restrictions. The APIs can be used individually or in any combination.

Accessing and Using the APIs

The Constant Contact Web Services APIs are designed to enable customers, software developers and third parties secured access to key Constant Contact services and data. Access to any of the API is subject to a set of Constant Contact API Terms and Conditions.

In order to leverage the APIs, you will need to:

Once you have an API key, you are free to explore and experiment with the API (Be careful if you are working with real account data!).

Other Resources:

If you are looking for software developers who may be able to use the APIs on these pages to build an integration between Constant Contact and your website or application for a fee, consider the resources described here.

Please check out the Constant Contact ConnectUp! Community for customer related discussions around Constant Contact usage.

Questions and Support

Support of the API is provided primarily via the API user forums which you can access here.

Suggestions and input

We welcome your input. Send us an email or contact us.

REST API Reference

API How-To Guides

Below you will find guides on how to perform various actions using the API's.  Currently, only the campaigns documentation has been re-written to have separate how-to guide from the API technical reference, but we will be updating the rest of the sections soon.  For now, you will find that links other than those on campaigns point to our existing documentation that combines both how-to guides and API reference.

 

API Reference

The API consists of a set of available API URLs ("Resources") which expose select account access and update data. The API resources are protected by an Authentication Model, described below. This table describes the top level URIs, or resources that are supported:

Service Description
https://api.constantcontact.com/ws/customers/{UserName}/
The service document. This URI returns information describing the collections that are accessible for the customer identified by UserName.
Contact Lists Collection
https://api.constantcontact.com/ws/customers/{UserName}/lists
Information about Contact Lists for the customer identified by UserName. This resource is used to discover what Contact Lists exist and to modify and delete Contact Lists.
Contact List Members Collection
https://api.constantcontact.com/ws/customers/{UserName}/lists/{ListId}/members
The set of Contacts that belongs to a contact list identified by {ListId} for the Account Owner {UserName}. This resource currently allows only the retrieval of a list of Contacts.
Activities Collection (BULK OPERATIONS)
https://api.constantcontact.com/ws/customers/{UserName}/activities
Batch Contact and download operations, including the ability to add, update or remove sets of Contacts. Upload and download operations on multiple records are performed by batch operations. This Activity resource can be used to submit these batch activities and to access the activities and their results. Currently supported activities include adding contacts to a contact list, updating contact details, removing contacts from a list, clearing a list of all contacts and downloading the contacts in a user or system-defined Contact List.
This resource is also used to check the status of submitted batch jobs. (Note: to upload or unsubscribe individual contacts see the contactsCollection resource.)
Contacts Collection
https://api.constantcontact.com/ws/customers/{UserName}/contacts
The set of Contacts for the Account Owner {UserName}. This resource can be used to create, retrieve or update a Contact and to associate or disassociate the Contact with Contact Lists. A query parameter can be used to search for a contact with a specified email address.
Campaigns Collection
https://api.constantcontact.com/ws/customers/{UserName}/campaigns
This resource answers the question, "For this account, what campaigns (emails) exist?" and it provides summary campaign results for sent campaigns.

The resource provies the set of Email Campaigns which exist for the Account Owner {UserName}. For each campaign, information about the Campaign Status (Draft, Scheduled, Sent) is available. For Sent campaigns, summary Campaign Results, including Sends, Opens and Clicks, are available.

Account Settings Email Collection
https://api.constantcontact.com/ws/customers/{UserName}/settings/emailaddresses

This resource returns a list of email addresses that are registered to an account, specified by {UserName}, and whether they have been confirmed or not.  This resource is typically used in conjunction with campaigns resource to be used as From/Reply-To email addresses.
Contact Events Service
https://api.constantcontact.com/ws/customers/{UserName}/contacts/{ContactId}/events/
This resource answers the question, "For this Contact what email campaign actions have occurred?"

The resource provides the set of Campaign Events such as 'sends', 'opens', and 'clicks' associated with an individual Contact. For each Contact, the service provides a set of events (Open, Click...). Each Event includes event specific details including timestamp, link details and other related data.

Campaign Events Service
https://api.constantcontact.com/ws/customers/{UserName}/campaigns/{CampaignId}/events/
This resource answers the question - "For this campaign, which Contacts took action X (Open, Click...)?"

Supported 'actions' (event types) include 'sends', 'opens', and 'clicks'.
The service provides a collection of events (Open, Click...) associated with that Campaign. Each collection includes further details including the Contact that performed the event, the timestamp, and event specific information including link details and other related data.

 

Error Codes

To see a complete list of error codes returned by our API's, you can reference this document.

 

Atom

The Constant Contact Web Services API is based on the Atom Publishing Protocol (Atompub for short), a simple HTTP-based protocol for creating and updating web resources. Atompub is standardized as RFC 5023, and serves as the basis of both Google's GData and Microsoft's ADO.NET Data Services (codename "Project Astoria") web service efforts.

 

Using the API (Authentication and Access)

Accessing the APIs requires use of one of the supported Authentication models. The Authentication models each require:

Examples showing rudimentary access to information in Constant Contact user accounts are included in the Authentication Details pages referenced from the Authentication Overview.

Atom

Atom and Atompub

Atom consists of two parts:

The Atom Publishing Protocol (AtomPub)
is an application-level protocol
for publishing and editing Web resources. The protocol is based on HTTP
transfer of Atom-formatted representations. It is specified in
RFC 5023.
The Atom Syndication Format
is an XML-based Web content and metadata
syndication format. It is specified in
RFC 4287.

The Web Service API uses Atom-formatted XML documents to transfer data and
Atompub as the protocol that specifies how to create, retrieve, update and delete the
Atom-formatted resources.

Data Format

The Web Service API represents individual items of data as Atom
Entries
and collections of items as Atom
Feeds.
Within an Entry, a data item is stored as an XML document within the Entry's
Content element.
Additional information is stored in other Atom elements,
and can be used for tasks like paging through a Feed.

Atom content Element

The API stores each entry's data as a well-formed XML fragment inside the
content element. The element's type attribute has a value of
"application/vnd.ctct+xml". All of the XML is in the
http://ws.constantcontact.com/ns/1.0/ namespace.

The fragment's top-level element indicates the type of the entry, e.g.
ContactList or Activity. The top-level element
also has an id attribute. Its value serves as a unique identifier
for the entry, and can be used to refer to the entry. Each property of the entry
is represented as an element and value inside the top-level element.

Other Atom Elements

Some required Atom element values are populated with values from the underlying
Constant Contact data. For example, in a Contact List entry, the Atom title
element contains the list's name. These values are populated for convenience when
using Atom-aware tools, and because they are required by the Atom specification.
The definitive value is always that in the XML fragment inside the Atom
content element. In particular, on create and update operations values are
always read from the content XML.

Paging and Links

Collections may contain large numbers of entries. To avoid problems with handling large
amounts of data with a single request, the server may elect to provide paged collections.
When it does, it will return an Atom feed containing a subset of the data along
with a link to get the next chunk of data. Specifically,the feed will contain Atom
link elements with rel attributes indicating what the
link is pointing to.

<feed xmlns="http://www.w3.org/2005/Atom">
  ...
  <link href="lists?next=50" rel="next" />
  <link href="lists" rel="first" />
  <link href="lists?next=25" rel="current" />
  <entry>
    ...
  </entry>
  ...
</feed>

In the example above, the first link element has rel="next",
indication that it points to the next page of the collection. The other two links point
to the first and current pages respectively. All links are relative to the current document.

Protocol

This article
gives a good introduction to Atompub.

Service Document

The service document describes the resources available for a particular account. Each Constant Contact account has its own service document because the resources available may vary depending on which applications the account uses and what permissions have been granted to the application using the API.

The service document is retrieved by issuing an HTTP GET to the account's Base URI. The Base URI is http://api.constantcontact.com/ws/customers/{UserName}/, where {UserName} is the account owner's Constant Contact user name. The {UserName} value must be in lower case, and any character(s) that are not permitted in a URI must be escaped. (Most languages/platforms have a function to do the escaping; in Javascript, it's encodeURIComponent(), in .NET, it's System.Web.HttpUtility.UrlEncode(), in PHP it's urlencode() and in Java, it's java.net.URLEncoder.encode().)

Example

Here is a service document for an account with the user name joesflowers. This document could be retrieved by doing an HTTP GET on http://api.constantcontact.com/ws/customers/joesflowers/ and presenting the proper credentials:

 

<?xml version='1.0' encoding='UTF-8'?>
<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
  <workspace>
    <atom:title type="text">Constant Contact Web Services Customer Workspace</atom:title>
    <collection href="/ws/customers/joesflowers/lists">
      <atom:title type="text">Contact Lists</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/activities">
      <atom:title type="text">Bulk Activity</atom:title>
      <accept>application/x-www-form-urlencoded</accept>
      <accept>multipart/form-data</accept>
    </collection>
  </workspace>
</service>

In Atom terminology, a service document describes a Workspace. This one describes the Constant Contact Web Services Customer Workspace. This workspace contains two Collections, called Contact Lists and Bulk Activity. For each collection, the href attribute specifies the collection's URI and the accept element(s) specify the type(s) of documents the collection will accept when creating a new entry. Section 8 of RFC 5023 describes the format of a service document in detail. The documentation page for each collection type will describe the detailed HTTP request and response formats.

Contact Lists Collection

The Contact Lists collection is used to list, create, modify and delete Contact Lists. Contact Lists are names for groups of Contacts. The Contact Lists collection manipulates the lists themselves. It does not perform any operations on a list's member Contacts.

Retrieving a Collection

To retrieve the collection of contact lists for the UserName joesflowers, you perform an HTTP GET on the collection URI, http://api.constantcontact.com/ws/customers/joesflowers/lists in this example, which returns the following XML document: 

<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/lists</id>
  <title type="text">Contact Lists</title>
  <link href="" />
  <link href="" rel="self" />
  <author>
    <name>Constant Contact Web Services</name>
  </author>
  <updated>2008-04-16T13:07:13.453Z</updated>
  <link href="lists?next=6" rel="next" />
  <link href="lists" rel="first" />
  <link href="lists" rel="current" />
  <entry>
    <link href="/ws/customers/joesflowers/lists/1" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/lists/1</id>
    <title type="text">General Interest</title>
    <updated>2008-04-16T13:07:14.057Z</updated>
    <content type="application/vnd.ctct+xml">
      <ContactList xmlns="http://ws.constantcontact.com/ns/1.0/" 
          id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1">
        <OptInDefault>false</OptInDefault>
        <Name>General Interest</Name>
        <ShortName>General Interest</ShortName>
        <SortOrder>1</SortOrder>
      </ContactList>
    </content>
  </entry>
  <entry>
    <link href="/ws/customers/joesflowers/lists/2" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/lists/2</id>
    <title type="text">Recent Signups</title>
    <updated>2008-04-16T13:07:14.061Z</updated>
    <content type="application/vnd.ctct+xml">
      <ContactList xmlns="http://ws.constantcontact.com/ns/1.0/" 
          ?id="http://api.constantcontact.com/ws/customers/joesflowers/lists/2">
        <OptInDefault>false</OptInDefault>
        <Name>Recent Signups</Name>
        <ShortName>Recent Signups</ShortName>
        <SortOrder>2</SortOrder>
      </ContactList>
    </content>
  </entry>
</feed>

 

The response is made up of a feed element which contains some metadata about the feed followed by a series of entry elements. Each entry is made up of some metadata followed by a content element. Inside the content element is a ContactList element which describes the attributes of a particular contact list. The structure of the Atom elements is described in detail by RFC 4287. The structure of the ContactList element is described below.

Retrieving an Individual List

An individual list entry may be retrieved by issuing an HTTP GET to the entry's URI. The URI may be obtained from the Location header after creating a new entry or from the link element with rel="edit" attribute in an existing entry. A typical entry looks like this: 

<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/lists/1" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/lists/1</id>
  <title type="text">General Interest</title>  
  <updated>2008-04-16T18:39:35.710Z</updated>
  <content type="application/vnd.ctct+xml">
    <ContactList xmlns="http://ws.constantcontact.com/ns/1.0/" 
        id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1">
      <OptInDefault>false</OptInDefault>
      <Name>General Interest</Name>
      <ShortName>General Interest</ShortName>
      <SortOrder>1</SortOrder>
    </ContactList>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/lists</id>
    <title type="text">Contact Lists</title>
    <link href="" />
    <link href="" rel="self" />
    <author>
      <name>Constant Contact Web Services</name>
    </author>
    <updated>2008-04-16T18:39:35.717Z</updated>
  </source>
</entry>

 

Creating a New List

A new Contact list is created by making an HTTP POST to the collection URI. The POST body must contain an Atom entry element that includes the content for the new list.   The Content-Type of the request must be set to application/atom+xml.  Here is a representative entry: 

<entry xmlns="http://www.w3.org/2005/Atom">
  <id>data:,</id>
  <title/>
  <author/>
  <updated>2008-04-16</updated>
  <content type="application/vnd.ctct+xml">
    <ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">
      <OptInDefault>false</OptInDefault>
      <Name>A New List</Name>
      <SortOrder>99</SortOrder>
    </ContactList>
  </content>
</entry>

 

Note that the id, title, author and updated elements must be present in the XML in order to conform to the Atom specification, even though their values will be replaced by the server. The <id> element must have an acceptable format (<id>data:,<id> will work). The title and author elements may be empty. The id must contain a URI, but since the value is not used by the server, any URI will work. The server does not check for uniqueness. The updated element must contain a date or date/time value, but again the value is not used by the server.

If the new list is created successfully, the server will return an HTTP status of 201 Created. The HTTP Location header in the response will contain the URI of the newly created List, and the entity body returned will be the entry for the list, including server-generated values like ids and links: 

<entry xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/lists/15</id>
  <title type="text">A New List</title>
  <author />
  <updated>2008-04-16T15:28:09.757Z</updated>
  <content type="application/vnd.ctct+xml">
    <ContactList xmlns="http://ws.constantcontact.com/ns/1.0/" 
        id="http://api.constantcontact.com/ws/customers/joesflowers/lists/15">
      <OptInDefault>false</OptInDefault>
      <Name>Test list 5</Name>
      <SortOrder>1</SortOrder>
      <ShortName>Test list 5</ShortName>
    </ContactList>
  </content>
  <link href="/ws/customers/joesflowers/lists/15" rel="edit" />
</entry>

 

Updating a List

A Contact List is updated by issuing an HTTP PUT to the entry's URI. The PUT body must contain an Atom entry element with the changed content for the list.

The Atom entry must include an <id> tag and that id must reflect the URI of the list you are updating, for example, if you want to update the list in the 'Create' example above, this line is required:
<id>http://api.constantcontact.com/ws/customers/joesflowers/lists/15</id>

As a general rule, your "PUT" entry should include all of the content you receive in "GET" for the resource you are updating. It may be simplest to "GET" the resource you would like to update, then change only the fields you want to update and "PUT" the updated resource back. The API will ignore read only fields (such as update time) and your entry will be complete.

 

Clearing All Contacts From a List

To clear all contacts from a list, you need to create a bulk activity to do.  Please refer to the bulk activity documentation for more details.

 

Deleting a List

A Contact List is deleted by issuing an HTTP DELETE to the entry's URI. The call will return 204 No Content if it succeeds.

 

Contact List Data Format

Name Allowed values Description
OptInDefault true, false If true, Contacts who sign-up or change their settings may add themselves to this list.
Name string(255) The list name.
ShortName read-only string System-calculated display name for the list for use where space is limited.
SortOrder integer Relative position of this Contact List in the full set of Contact Lists. This parameter is used when a group of Contact Lists are presented in a UI such as the Site Visitor SignUp. The values are arbitrary relative values. A List with SortOrder=25 will be shown after a List with Sort Order 15.

 

Bulk Activity: Collection of Activities

Constant Contact encourages the use of asynchronous background jobs to manage large collections of data. The Bulk Activity collection is used to create and manage those jobs, called Activities. Currently, the collection allows you to create jobs to add, remove and download contacts from contact lists. It also allows you to check the status of a customer's activities and to see when an activity is completed and whether it succeeded or failed. A single "call" to the "Activities" resource generally operates on a set of contacts. The data for that set of contacts is held in a formatted file, described below.

The Activities resource is designed to be used only with large sets of contacts (ie. 25 or more). To manage individual contacts or small sets of contacts, use the Contacts Collection API resource. (As discussed in the Constant Contact API Terms and Conditions, intentional and unintentional misuse of this bulk API to frequently manage individual contacts or small sets of contacts is subject to API access or account termination).

Retrieving a Collection of Activities

To retrieve the collection of activities for the UserName joesflowers, you perform an HTTP GET on the collection URI, https://api.constantcontact.com/ws/customers/joesflowers/activities. For the fictional joesflowers in this example, this returns the following XML document, showing a single activity: 

<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/activities</id>
  <title type="text">Bulk Activity</title>
  <link href="" />
  <link href="" rel="self" />
  <author>
    <name>joesflowers</name>
  </author>
  <updated>2008-04-29T19:31:00.545Z</updated>
  <entry>
    <link href="/ws/customers/joesflowers/activities/a07e1ffaxjxffmvj6qd" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1ffaxjxffmvj6qd</id>
    <title type="text"></title>
    <updated>2008-04-29T19:30:15.637Z</updated>
    <content type="application/vnd.ctct+xml">
      <Activity xmlns="http://ws.constantcontact.com/ns/1.0/"
        id="http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1ffaxjxffmvj6qd">
        <Type>ADD_CONTACT_DETAIL</Type>
        <Status>COMPLETE</Status>
        <Errors>
          <Error>
            <LineNumber>3</LineNumber>
            <EmailAddress>test2@test.com</EmailAddress>
            <Message>Unknown US/Canadian state/prov "Test2"</Message>
          </Error>
          <Error>
            <LineNumber>4</LineNumber>
            <EmailAddress>test3@test.com</EmailAddress>
            <Message>Unknown US/Canadian state/prov "Test3"</Message>
          </Error>
        </Errors>
        <FileName></FileName>
        <TransactionCount>1</TransactionCount>
        <RunStartTime>2008-06-25T15:48:01.615Z</RunStartTime>
        <RunFinishTime>2008-06-25T15:48:03.040Z</RunFinishTime>
        <InsertTime>2008-06-25T15:47:37.199Z</InsertTime>
      </Activity>
    </content>
  </entry>
</feed>

The response is made up of a feed element which contains some metadata about the feed followed by a series of entry elements. Each entry is made up of some metadata followed by a content element. Inside the content element is a Activity element which describes the attributes of a particular activity. The structure of the Activity element is described below.

Retrieving the Details of an Individual Activity

An individual activity entry may be retrieved by issuing an HTTP GET to the entry's URI. The URI may be obtained from the Location header after creating a new entry or from the link element with rel="edit" attribute in an existing entry. A typical entry looks like this: 

<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz</id>
  <title type="text"></title>
  <updated>2008-04-29T19:36:10.948Z</updated>

  <content type="application/vnd.ctct+xml">
    <Activity xmlns="http://ws.constantcontact.com/ns/1.0/"
      id="http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz">
      <Type>ADD_CONTACT_DETAIL</Type>
      <Status>COMPLETE</Status>
      <Errors>
        <Error>
          <LineNumber>3</LineNumber>
          <EmailAddress>test2@test.com</EmailAddress>
          <Message>Unknown US/Canadian state/prov "Test2"</Message>
        </Error>
        <Error>
          <LineNumber>4</LineNumber>
          <EmailAddress>test3@test.com</EmailAddress>
          <Message>Unknown US/Canadian state/prov "Test3"</Message>
        </Error>
      </Errors>
      <FileName></FileName>
      <TransactionCount>1</TransactionCount>
      <RunStartTime>2008-04-29T19:36:08.894Z</RunStartTime>
      <RunFinishTime>2008-04-29T19:36:10.948Z</RunFinishTime>
      <InsertTime>2008-04-29T19:35:54.923Z</InsertTime>
    </Activity>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/activities</id>
    <title type="text">Bulk Activity</title>
    <link href="" />
    <link href="" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2008-04-29T19:45:24.131Z</updated>
  </source>
</entry>

Creating an Add Contacts/Remove Contacts Activity

A new Activity is created by making an HTTP POST to the activity collection URI. In contrast to the Contact List, the Activity POST body is not an Atom Entry. Instead it is several named parameters encoded with one of the HTML FORM content types, either application/x-www-form-urlencoded or multipart/form-data. So the data passed in the POST body is the same as that produced by a FORM with the ENCTYPE attribute set to that type.

Constructing an application/x-www-form-urlencoded Request

The basics of how to construct an application/x-www-form-urlencoded request are simple:

  1. Parameter names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
  2. The parameter name is separated from the value by `=' and name/value pairs are separated from each other by `&'.
  3. To use paramter values that contain delimiter characters, such as a comma, you need to enclose the value in double quotes, then encode the value.  For example, to use a parameter value of 'Boston, MA', you need to use '%22Boston%2C%20MA%22'. 

Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below. More details on how to make an application/x-www-form-urlencoded request are in the HTML specification.

The following example shows the parameters used to upload the Email Address, First Name and Last Name of three contacts (Fred Test, Joan Test and Ann Test) to two Contact Lists in the joesflowers account. Note that the three contacts are submitted in a single invocation of the Activities resource.

  activityType=SV_ADD
  &data=Email+Address%2CFirst+Name%2CLast+Name%0A
  wstest3%40example.com%2C+Fred%2C+Test%0A
  wstest4%40example.com%2C+Joan%2C+Test%0A
  wstest5%40example.com%2C+Ann%2C+Test
  &lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F2
  &lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F5
  

application/x-www-form-urlencoded Parameters

Name Allowed values Description
activityType ADD_CONTACTS, SV_ADD, ADD_CONTACT_DETAIL, REMOVE_CONTACTS_FROM_LISTS The type of activity to create. NOTE: When adding subscribers, the system will determine, based upon the data being uploaded, whether the Activity is an ADD_CONTACTS (which=SV_ADD) or ADD_CONTACT_DETAIL, but a type must still be specified.
data string The data to be uploaded. This will usually include data for multiple contacts. (If you are submitting a single contact, please see the Contacts Collection resource). The uploaded data for the Activities resource may be in Notepad (.TXT), or Other (.CSV) format. MS Excel (.XLS) file data must be uploaded using multipart/form-data. The format of the upload data is described in a support FAQ.
lists URI (one or more) The list to which data is uploaded. The list should be a list id URI as referenced in the Contact Lists collection.

Constructing a multipart/form-data Request

When using FORMs, you must use enctype="multipart/form-data" when using <input type="file">. Similarly, when uploading a complete file of data, particularly binary data like MS Excel spreadsheets, you must use a multipart/form-data request. Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below. More details on how to make an multipart/form-data request are in the HTML specification and RFC 2388.

multipart/form-data Parameters

Name Allowed values Description
activityType ADD_CONTACTS, SV_ADD, ADD_CONTACT_DETAIL, REMOVE_CONTACTS_FROM_LISTS The type of activity to create. NOTE: When adding subscribers, the system will determine, based upon the data being uploaded, whether the Activity is an ADD_CONTACTS (which=SV_ADD) or ADD_CONTACT_DETAIL, but a type must still be specified.
dataFile file The data to be uploaded. This will usually include data for multiple contacts. (If you are submitting a single contact, please see the Contacts Collection resource). The uploaded data for the Activities resource may be in Notepad (.TXT), or Other (.CSV) format. MS Excel (.XLS) file data must be uploaded using multipart/form-data. The format of the upload data is described in a support FAQ.
lists URI (one or more) The list the data is to uploaded to. The list should be a list id URI as referenced in the Contact Lists collection.

If the new activity is created successfully, the server will return an HTTP status of 201 Created. The HTTP Location header in the response will contain the URI of the newly created activity, and the entity body returned will be the minimal entry for the activity, including server-generated values like ids and links: 

<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz</id>
  <title type="text"></title>
  <updated>2008-04-29T19:35:54.923Z</updated>
</entry>

Creating a Clear Contacts Activity

A new Activity is created by making an HTTP POST to the activity collection URI. In contrast to the Contact List, the Activity POST body is not an Atom Entry. Instead it is several named parameters encoded with one of the HTML FORM content types, either application/x-www-form-urlencoded or multipart/form-data. So the data passed in the POST body is the same as that produced by a FORM with the ENCTYPE attribute set to that type.

The "Clear Contacts" function works like the "Remove" function, except that you don't have to provide a list of email addresses that you wish to remove.  Select the lists you wish to clear carefully. If you clear contacts from all lists, you will not have any contacts left in your Constant Contact account.

You should refrain from additional operations on the list you are clearing until the job is complete. For example, adding contacts to the list before the clear contacts activity is complete may result in those new contacts being cleared when the activity is run.

Constructing an application/x-www-form-urlencoded Request

The basics of how to construct an application/x-www-form-urlencoded request are simple:

  1. Parameter names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
  2. The parameter name is separated from the value by `=' and name/value pairs are separated from each other by `&'.
  3. To use paramter values that contain delimiter characters, such as a comma, you need to enclose the value in double quotes, then encode the value.  For example, to use a parameter value of 'Boston, MA', you need to use '%22Boston%2C%20MA%22'.

Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below. More details on how to make an application/x-www-form-urlencoded request are in the HTML specification.

The following example shows the parameters used to clear two contact lists, identified by ID's 2 and 5. Note that two contact lists are submitted in a single invocation of the Activities resource.

  activityType=CLEAR_CONTACTS_FROM_LISTS
  &lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F2
  &lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F5
  

application/x-www-form-urlencoded Parameters

Name Allowed values Description
activityType CLEAR_CONTACTS_FROM_LISTS The type of activity to create.  When clearing subscribers from the list, they will not be deleted, only removed from the list(s) specified. NOTE:  "Named" lists cannot be cleared. These incldude "Do-Not-Mail", "Removed", "Awaiting Confirmation", "All" and "Active". If an attempt to clear one of these lists (or another non-existant list) is made, the request will fail with a "400 Bad Request"
lists URI (one or more) The list to clear The list should be a list id URI as referenced in the Contact Lists collection.

Constructing a multipart/form-data Request

When using FORMs, you must use enctype="multipart/form-data" when using <input type="file">. Similarly, when uploading a complete file of data, particularly binary data like MS Excel spreadsheets, you must use a multipart/form-data request. Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below. More details on how to make an multipart/form-data request are in the HTML specification and RFC 2388.

multipart/form-data Parameters

Name Allowed values Description
activityType CLEAR_CONTACTS_FROM_LISTS The type of activity to create.  When clearing subscribers from the list, they will not be deleted, only removed from the list(s) specified. NOTE:  "Named" lists cannot be cleared. These incldude "Do-Not-Mail", "Removed", "Awaiting Confirmation", "All" and "Active". If an attempt to clear one of these lists (or another non-existant list) is made, the request will fail with a "400 Bad Request"
lists URI (one or more) The list to clear. The list should be a list id URI as referenced in the Contact Lists collection.

If the new activity is created successfully, the server will return an HTTP status of 201 Created. The HTTP Location header in the response will contain the URI of the newly created activity, and the entity body returned will be the minimal entry for the activity, including server-generated values like ids and links: 

<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz</id>
  <title type="text"></title>
  <updated>2008-04-29T19:35:54.923Z</updated>
</entry>

Creating an Export Contacts Activity

A new Activity is created by making an HTTP POST to the activity collection URI. In contrast to the Contact List, the Activity POST body is not an Atom Entry. Instead it is several named parameters encoded with one of the HTML FORM content types, either application/x-www-form-urlencoded or multipart/form-data. So the data passed in the POST body is the same as that produced by a FORM with the ENCTYPE attribute set to that type.

Constructing an application/x-www-form-urlencoded Request

The basics of how to construct an application/x-www-form-urlencoded request are simple:

  1. Parameter names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
  2. The parameter name is separated from the value by `=' and name/value pairs are separated from each other by `&'.
  3. To use paramter values that contain delimiter characters, such as a comma, you need to enclose the value in double quotes, then encode the value.  For example, to use a parameter value of 'Boston, MA', you need to use '%22Boston%2C%20MA%22'.

Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below. More details on how to make an application/x-www-form-urlencoded request are in the HTML specification.

The following example shows the parameters used to export the Email Address, First Name and Last Name of three contacts (Fred Test, Joan Test and Ann Test) from a list in the joesflowers account.

    activityType=EXPORT_CONTACTS&fileType=CSV&exportOptDate=true&exportOptSource=true
    &exportListName=true&sortBy=DATE_DESC
    &columns=EMAIL%20ADDRESS&columns=FIRST%20NAME&columns=LAST%20NAME
    &listId=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F2
  

application/x-www-form-urlencoded Parameters

Name Allowed values Description
activityType EXPORT_CONTACTS The type of activity to create.
listId URI The list the data is exported from. The list should be a list id URI as referenced in the Contact Lists collection. System defined lists, such as 'do-not-mail' are supported.
fileType CSV, TXT Type of file to be exported
exportOptDate true, false true to include the Add/Remove Date in the export file, false to not include it
exportOptSource true, false true to include the Added/Removed By (source of add or remove) in the export file, false to not include it
exportListName true, false true to include the List Name in the export file, false to not include it
sortBy EMAIL_ADDRESS, DATE_DESC EMAIL_ADDRESS to sort the list by email address in ascending order. DATE_DESC will sort the contacts by the Date in descending order
columns FIRST NAME, MIDDLE NAME, LAST NAME, JOB TITLE, COMPANY NAME, WORK PHONE, HOME PHONE, ADDRESS LINE 1, ADDRESS LINE 2, ADDRESS LINE 3, CITY, STATE, STATE/PROVINCE (US/CANADA), COUNTRY, POSTAL CODE, SUB POSTAL CODE, CUSTOM FIELD 1, CUSTOM FIELD 2, CUSTOM FIELD 3, CUSTOM FIELD 4, CUSTOM FIELD 5, CUSTOM FIELD 6, CUSTOM FIELD 7, CUSTOM FIELD 8, CUSTOM FIELD 9, CUSTOM FIELD 10, CUSTOM FIELD 11, CUSTOM FIELD 12, CUSTOM FIELD 13, CUSTOM FIELD 14, CUSTOM FIELD 15 URL encoded, multi-valued list of which optional fields to include in the exported file. (EMAIL ADDRESS is always included in the exported file). The names are the same as those used in files for upload. See the support FAQ for details. Note that the field names include spaces, which must be properly encoded in the request. Comma-separated list of all the fields to be included in the exported file.

Constructing a multipart/form-data Request

When using FORMs, you must use enctype="multipart/form-data" when using <input type="file">. Similarly, when uploading a complete file of data, particularly binary data like MS Excel spreadsheets, you must use a multipart/form-data request. Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below. More details on how to make an multipart/form-data request are in the HTML specification and RFC 2388.

multipart/form-data Parameters

Name Allowed values Description
activityType EXPORT_CONTACTS The type of activity to create.
listId URI The list the data is exported from. The list should be a list id URI as referenced in the Contact Lists collection. System defined lists, such as 'do-not-mail' are supported.
fileType CSV, TXT Type of file to be exported
exportOptDate true, false true to include the Add/Remove Date in the export file, false to not include it
exportOptSource true, false true to include the Added/Removed By (source of add or remove) in the export file, false to not include it
exportListName true, false true to include the List Name in the export file, false to not include it
sortBy EMAIL_ADDRESS, DATE_DESC EMAIL_ADDRESS to sort the list by email address in ascending order. DATE_DESC will sort the contacts by the Date in descending order
columns FIRST NAME, MIDDLE NAME, LAST NAME, JOB TITLE, COMPANY NAME, WORK PHONE, HOME PHONE, ADDRESS LINE 1, ADDRESS LINE 2, ADDRESS LINE 3, CITY, STATE, STATE, STATE/PROVINCE (US/CANADA), COUNTRY, POSTAL CODE, SUB POSTAL CODE, CUSTOM FIELD 1, CUSTOM FIELD 2, CUSTOM FIELD 3, CUSTOM FIELD 4, CUSTOM FIELD 5, CUSTOM FIELD 6, CUSTOM FIELD 7, CUSTOM FIELD 8, CUSTOM FIELD 9, CUSTOM FIELD 10, CUSTOM FIELD 11, CUSTOM FIELD 12, CUSTOM FIELD 13, CUSTOM FIELD 14, CUSTOM FIELD 15 URL encoded, multi-valued list of which optional fields to include in the exported file. (EMAIL ADDRESS is always included in the exported file). The names are the same as those used in files for upload. See the support FAQ for details. Note that the field names include spaces, which must be properly encoded in the request.

If the new activity is created successfully, the server will return an HTTP status of 201 Created. The HTTP Location header in the response will contain the URI of the newly created activity, and the entity body returned will be the minimal entry for the activity, including server-generated values like ids and links.

After the system has finished processing the Export activity, retrieving the activity entry will return a complete entry that includes the status of the job. If the job completed successfully, it will also contain a link to the exported file. See the example below: 

<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/activities/a07e1gpfcd3fhysynnp" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1gpfcd3fhysynnp</id>
  <title type="text">EXPORT_CONTACTS: http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1...
  <updated>2008-06-27T13:10:59.944Z</updated>
  <content type="application/vnd.ctct+xml">
    <Activity xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1gpfcd3fhysynnp">
      <Type>EXPORT_CONTACTS</Type>
      <Status>COMPLETE</Status>
      <FileName>http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1gpfcd3fhysynnp.csv</FileName>
      <TransactionCount>0</TransactionCount>
      <Errors></Errors>
      <RunStartTime>2008-06-27T13:10:59.321Z</RunStartTime>
      <RunFinishTime>2008-06-27T13:10:59.944Z</RunFinishTime>
      <InsertTime>2008-06-27T13:10:57.349Z</InsertTime>
    </Activity>
  </content>
  <link href="http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1gpfcd3fhysynnp.csv" rel="edit-media" />
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/activities</id>
    <title type="text">Activity Collection for customer: joesflowers</title>
    <link href="" />
    <link href="" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2008-06-27T16:29:26.723Z</updated>
  </source>
</entry>

Updating an Activity

Activity updates are not currently permitted.

Deleting an Activity

Activity deletes are not currently permitted.

Activity Data Format

Name Allowed values Description
Type ADD_CONTACTS, ADD_CONTACT_DETAIL, REMOVE_CONTACTS_FROM_LISTS, EXPORT_CONTACTS, CLEAR_CONTACTS_FROM_LISTS The type of activity.
Status UNCONFIRMED, PENDING, QUEUED, RUNNING, COMPLETE, ERROR The current status of the activity.
FileName string The file name associated with the activity (may be empty).
TransactionCount integer For completed jobs, the number of addresses processed.
Error string  
RunStartTime Date/Time The time the activity started to run.
RunFinishTime Date/Time The time the activity completed its run.
InsertTime Date/Time The time the activity was created.

 

Contacts Collection (find, create, modify or delete individual contacts)

The Contacts collection is used to list, create, modify and delete Contacts (also known as subscribers) and to associate and disassociate Contacts and Contact Lists.

The Contacts collection resource is designed to be used only with small sets of contacts (ie. 24 or less). To manage large groups of contacts, use the Activities API resource. (As discussed in the Constant Contact API Terms and Conditions, intentional and unintentional misuse of this discrete API to frequently manage large sets of contacts is subject to API access or account termination).

Retrieving a Collection

To retrieve the collection of contacts for the UserName joesflowers, you perform an HTTP GET on the collection URI, http://api.constantcontact.com/ws/customers/joesflowers/contacts in this example, which returns the following XML document:

<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts</id>
  <title type="text">Contacts for Customer joesflowers</title>
  <link href="" />
  <link href="" rel="self" />
  <author>
    <name>joesflowers</name>
  </author>
  <updated>2008-07-15T17:40:28.374Z</updated>
  <link href="/ws/customers/joesflowers/contacts?next=fihuckra" rel="next" />
  <link href="/ws/customers/joesflowers/contacts" rel="first" />
  <link href="/ws/customers/joesflowers/contacts" rel="current" />
  <entry>
    <link href="/ws/customers/joesflowers/contacts/1806" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts/1806</id>
    <title type="text">Contact: u92204@example.com</title>
    <updated>2008-07-15T17:40:28.544Z</updated>
    <content type="application/vnd.ctct+xml">
      <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/1806">
        <Status>Active</Status>
        <EmailAddress>u92204@example.com</EmailAddress>
        <EmailType>HTML</EmailType>
        <Name></Name>
        <OptInTime>2008-07-15T15:14:53.219Z</OptInTime>
        <OptInSource>ACTION_BY_CONTACT</OptInSource>
      </Contact>
    </content>
  </entry>
  <entry>
    <link href="/ws/customers/joesflowers/contacts/1805" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts/1805</id>
    <title type="text">Contact: u89439@example.com</title>
    <updated>2008-07-15T17:40:28.548Z</updated>
    <content type="application/vnd.ctct+xml">
      <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/1805">
        <Status>Active</Status>
        <EmailAddress>u89439@example.com</EmailAddress>
        <EmailType>HTML</EmailType>
        <Name></Name>
        <OptInTime>2008-07-15T15:14:51.172Z</OptInTime>
        <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
      </Contact>
    </content>
  </entry>
</feed>

 

The response is made up of a feed element which contains some metadata about the feed followed by a series of entry elements. Each entry is made up of some metadata followed by a content element. Inside the content element is a Contact element which describes some of the important attributes of a particular contact.

Note that in order to get all the data about a particular contact, you must get the individual entry, which contains the complete entry data.

The structure of the Atom elements is described in detail by RFC 4287. The structure of the Contact element is described below.

 

Querying the Contacts Collection

To find particular Contacts you can query the collection by adding a query parameter to the collection's URI. So to look up the entry for the Contact with email address u89439@example.com, you would GET http://api.constantcontact.com/ws/customers/joesflowers/contacts?email=u89439%40example.com. (Note that the '@' sign in the email address must be properly URL encoded.) If a contact with that email exists, the query will return a feed containing the Contact entry for that email address, including a reference to the URI for the Contact details. If no Contact with that email address exists, the API will return either a 500 error (Server Error) code or will return an empty feed (i.e. a feed with no entries).

You can find multiple contacts with a single query by simply adding additional parameters: http://api.constantcontact.com/ws/customers/joesflowers/contacts?email=u89439%40example.com&email=u10432%40example.com. Just like before, the returned feed will contain entries for any Contacts that are found. Any that don't exist will simply be skipped.

Note that the email must be an exact match, including case! Since all email addresses in Constant Contact are stored in lowercase, please lowercase the email address you use for your query parameter.

The email parameter is the only query currently supported. More query types may be added in the future.

 

Retrieving an Individual Contact

An individual Contact entry may be retrieved by issuing an HTTP GET to the entry's URI. The URI may be obtained from the Location header after creating a new entry or from the link element with rel="edit" attribute in an existing entry.

If you don't have a link to an entry, you can find it by querying the collection.

A typical entry looks like this:

<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/contacts/1454" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts/1454</id>
  <title type="text">Contact: u86597@example.com</title>
  <updated>2008-06-23T06:46:30.078Z</updated>
  <content type="application/vnd.ctct+xml">
    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/1454">
      <Status>Active</Status>
      <EmailAddress>u86597@example.com</EmailAddress>
      <EmailType>HTML</EmailType>
      <Name>First Last</Name>
      <FirstName>First</FirstName>
      <MiddleName></MiddleName>
      <LastName>Last</LastName>
      <JobTitle></JobTitle>
      <CompanyName></CompanyName>
      <HomePhone></HomePhone>
      <WorkPhone></WorkPhone>
      <Addr1></Addr1>
      <Addr2></Addr2>
      <Addr3></Addr3>
      <City></City>
      <StateCode></StateCode>
      <StateName></StateName>
      <CountryCode></CountryCode>
      <CountryName></CountryName>
      <PostalCode></PostalCode>
      <SubPostalCode></SubPostalCode>
      <Note></Note>
      <CustomField1></CustomField1>
      <CustomField2></CustomField2>
      <CustomField3></CustomField3>
      <CustomField4></CustomField4>
      <CustomField5></CustomField5>
      <CustomField6></CustomField6>
      <CustomField7></CustomField7>
      <CustomField8></CustomField8>
      <CustomField9></CustomField9>
      <CustomField10></CustomField10>
      <CustomField11></CustomField11>
      <CustomField12></CustomField12>
      <CustomField13></CustomField13>
      <CustomField14></CustomField14>
      <CustomField15></CustomField15>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.com/ws/customers/joesflowers/lists/1" rel="self" />
          <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
          <OptInTime>2008-06-23T06:46:30.000Z</OptInTime>
        </ContactList>
      </ContactLists>
      <Confirmed>false</Confirmed>
      <InsertTime>2008-06-23T06:46:29.984Z</InsertTime>
      <LastUpdateTime>2008-06-23T06:46:30.078Z</LastUpdateTime>
    </Contact>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts</id>
    <title type="text">Contacts for Customer joesflowers</title>
    <link href="" />
    <link href="" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2008-07-16T16:54:49.524Z</updated>
  </source>
</entry>

 

Creating a New Contact

A new contact is created by making an HTTP POST to the collection URI. The POST body must contain an Atom entry element that includes the content for the new contact. The Content-Type of the request must be set to application/atom+xml.

<entry xmlns="http://www.w3.org/2005/Atom">
  <title type="text"> </title>
  <updated>2008-07-23T14:21:06.407Z</updated>
  <author></author>
  <id>data:,none</id>
  <summary type="text">Contact</summary>
  <content type="application/vnd.ctct+xml">
    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/">
      <EmailAddress>test101@example.com</EmailAddress>
      <FirstName>First</FirstName>
      <LastName>Last</LastName>
      <OptInSource>ACTION_BY_CONTACT</OptInSource>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1" />
      </ContactLists>
    </Contact>
  </content>
</entry>

Note that the id, title, author and updated elements must be present in the XML in order to conform to the Atom specification, even though their values will be replaced by the server. The title and author elements may be empty. The id must contain a URI, but since the value is not used by the server, any URI will work. The server does not check for uniqueness. The updated element must contain a date or date/time value, but again the value is not used by the server.

If the new Contact is created successfully, the server will return an HTTP status of 201 Created. The HTTP Location header in the response will contain the URI of the newly created Contact, and the entity body returned will be the entry for the Contact, including server-generated values like ids and links, with the result being that the returned response looks very much like what would be returned by a GET of the newly created contact's URI. Note that valid State Codes can be found here. State Code and Country must be consistent.

 

Updating a Contact

A Contact is updated by issuing an HTTP PUT to the entry's URI. The PUT body must contain an Atom entry element with the changed content for the contact.  The best way to achieve a successful update is to use the XML from a GET operation on the contact you want to update, modify the contents, and use it as the XML body in your PUT request.

 

Adding or Removing a Contact from a List

Contacts are added to or removed from lists by adding or removing ContactList elements from the ContactLists element, then PUT'ting the entry back to its edit URI. See below an example of the XML required to associate existing contact u86597@example.com with Contact Lists 1, 11, 12 and 14 in the joesflowersaccount. Note that after the PUT, contact u86597@example.com will be on ONLY Contact Lists 1, 11, 12 and 14 and will be removed from any other lists the contact was on previously.

<entry xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts/101</id>
  <title type="text">Contact: u86597@example.com</title>
  <updated>2008-04-25T19:29:06.096Z</updated>
  <author> </author>
  <content type="application/vnd.ctct+xml">
    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/101">
      <EmailAddress>u86597@example.com</EmailAddress>
      <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1"></ContactList>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/11"></ContactList>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/12"></ContactList>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/14"></ContactList>
      </ContactLists>
    </Contact>
  </content>
</entry>

Note that the OptInSource element is required, and must be ACTION_BY_CUSTOMER for any Contact List which is not included on the SignUp Form for the Account Owner.

 

Removing a Contact

To remove a contact from all lists, simply remove all of the ContactList elements from the ContactLists element.  Removing a contact does not mean that the contact has unsubscribed or opted out of receiving emails.  It means the contact simply does not belong to any particular contact list, and can be added back to a list by the account owner.  However, this API should not be used if the contact has unsubscribed from receiving all emails.  Instead, you should follow the instructions below in "Opting-out a Contact" section.

Opting-out a Contact

A Contact is opted-out by issuing an HTTP DELETE to the entry's URI. The call will return 204 No Content if it succeeds. This should be used if the contact has decided to unsubscribe from receiving all emails or has asked to stop sending all emails.  Opted-out Contacts become members of the do-not-mail special list.

Opting-in a Contact

Contacts who have opted out of receiving all mails and have been placed on Do-Not-Mail list must opt themselves in.  The account owner cannot add a contact in Do-Not-Mail list back to a different list.  When using the API, that means that the OptInSource must be ACTION_BY_CONTACT. Applications may only use the ACTION_BY_CONTACT OptInSource when the API call is the direct result of an action performed by the Contact (e.g. clicking a Subscribe button in an application). It is a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API in any other way.

Contact Data Format

Name Allowed values Description
Status Active, Unconfirmed, Removed, or Do Not Mail (read-only) Describes the current status of the Contact.
EmailAddress string(80) A valid email address
EmailType HTML or Text The preferred type of email
Name string (read-only) Read-only concatenation of FirstName and LastName
FirstName string(50)  
MiddleName string(50)  
LastName string(50)  
JobTitle string(50)  
CompanyName string(50)  
HomePhone string(50)  
WorkPhone string(50)  
Addr1 string(50)  
Addr2 string(50)  
Addr3 string(50)  
City string(50)  
StateCode string(2) Must be a valid US/Canada State Code and must be consistent with CountryCode. See: http://ui.constantcontact.com/CCSubscriberAddFileFormat.jsp#states.
StateName string(50)  
CountryCode string(2) Must be a valid two character, lower case, Country Code. See: http://constantcontact.custhelp.com/cgi-bin/constantcontact.cfg/php/enduser/std_adp.php?p_faqid=3614
CountryName string(50)  
PostalCode string(25)  
SubPostalCode string(25)  
Note string(500) Customer notes field. This field should only be visible to the Customer but not to the Contact.
CustomField[1-15] string(50)  
ContactLists 0 or more ContactList elements (see table below) Indicates which lists the Contact belongs to
OptInTime Date/Time (read-only) The time the Contact opted-in
OptInSource ACTION_BY_CUSTOMER, ACTION_BY_CONTACT The source of the opt-in
OptOutTime Date/Time (read-only) The time the Contact opted-in
OptOutSource ACTION_BY_CUSTOMER, ACTION_BY_CONTACT Source of the opt-out
OptOutReason Text (read-only) The time the Contact opted-out, if provided
Confirmed true or false (read-only)  
InsertTime Date/Time (read-only)  
LastUpdateTime Date/Time (read-only)  

ContactList Data Format

Name Allowed values Description
atom:link   atom:link identifies the href attribute of this element links to a contact list
OptInTime Date/Time (read-only) OptInTime identifies the time the Contact opted-in to this list
OptInSource ACTION_BY_CUSTOMER, ACTION_BY_CONTACT OptInSource identifies the source of the opt-in to this list as either the "CUSTOMER" (the Account Owner) or the "CONTACT" (the subscriber themself).

Contacts who are added with "ACTION_BY_CUSTOMER" do not receive a welcome email. This value MUST be used whenever the contact is being added by anyone other than the contact themselves. Contacts who are added with "ACTION_BY_CUSTOMER" will receive AutoResponder sequences based on the settings of the list they are being added to. Contacts who are added with "ACTION_BY_CUSTOMER" are not included on your "Visitor Signup Report".

Contacts who are added with "ACTION_BY_CONTACT" receive a welcome email. This value *CAN ONLY* be used if the contact is being added as a direct result of an action by the contact themselves (ie they are adding themselves via a public web form). Contacts who are added with "ACTION_BY_CONTACT" will receive AutoResponder sequences. Contacts who are added with "ACTION_BY_CONTACT" are included on your "Visitor Signup Report".

Invalid values for OptInSource, including providing incorrect case of the constant values (ACTION_BY_CUSTOMER, ACTION_BY_CONTACT) may result in an http response of "500: Server Error".

 

Managing Email Campaigns

Constant Contact provides API's that allow you to get details of email campaigns, to create an email campaign based on custom HTML code, and to update details of email campaigns.

You can get a list of campaigns, and query individual campaigns to get more details for each one.  If you want to create a new campaign, the best way is to get the details of a campaign, then make changes to the returned XML and use the modified XML to create a new one.

The following tasks are supported currently:

 

Listing Campaigns

You can get a list of campaigns avaialble in your account by using the GET method on the campaigns collection: 

https://api.constantcontact.com/ws/customers/{user-name}/campaigns

The GET on the campaigns collection returns a list of campaigns as described in the Campaigns Collection Reference.

Each campaign is returned in <entry> tags, and if there are multiple campaigns, there will be multiple <entry> elements.  Each entry provides only the basic information about a campaign, such as the name or title of the campaign, its author and status.  To get more details for a particular campaign, you need to  use the <link> provided inside <entry> to construct a new URI and query the campaign itself, and the resulting URI would look like the following:

https://api.constantcontact.com/ws/customers/{user-name}/campaigns/1100549626893

If you call the above URI with GET, you should be able to get more details about the campaign.  This action is described in more detail in Obtaining a Campaign's Information section.

 

Obtaining a Campaign's Information

You can obtain details of both template-based campaigns and custom-code campaigns.  For custom-code campaigns, you will get attributes of a campaign, such as subject, from email address, etc., as well as the actual content of the campaign, both HTML/XHTML and text.  For template-based campaigns, you will only get attributes of a campaign.

To obtain a campaign's information, call the following URI with GET method:

https://api.constantcontact.com/ws/customers/{user-name}/campaigns/{campaign-id}

The GET on the campaign resource returns the details of a campaign as described in the Campaigns Collection Reference.  The response body would return XML elements according to the Campaign Data Elements section of the Campaigns Collection Reference.  The details should include whether the campaign is based on templates or custom HTML/XHTML, whether the campaign is HTML or XHTML based if it's based on custom code, the campaign's status, details of the email itself, and settings on "View As Webpage" or "Permission Reminder" features.

<CampaignType> signifies whether the campaign is based on templates (STOCK) or on custom HTML/XHTML code (CUSTOM).  If the campaign is template-based, then the XML would not contain <EmailContent>, <TextContent> and <StyleSheet> elements.

If the campaign is based on custom code, then the returned elements depend on whether the campaign is HTML or XHTML based, described by <EmailContentFormat> element, whose valid values are HTML and XHTML.  If the custom campaign is based on HTML, then the XML would contain only <EmailContent> and <TextContent> elements.  If the custom campaign is based on XHTML, then the XML would contain <EmailContent>, <TextContent> and <StyleSheet>.

The email addresses used in <FromEmail> and <ReplyToEmail> are based on the email addresses of the account, which are represented through Account Settings Email Addresses collection and resource.  Please note that email addresses are represented as ID's and not actual email addresses.

The user's organization information is represented by <OrganizationName>, <OrganizationAddress1>, <OrganizationAddress2>, <OrganizationAddress3>, <OrganizationCity>, <OrganizationState>, <OrganizationInternationalState> and <OrganizationCountry> elements.  If you already entered organization information in your settings, or if you specified them when you created the campaign through the API, then these elements will return the organization information.  If they have not been set, they will not have any values.

  

Creating a Campaign

There are two types of email campaigns in Constant Contact: template-based emails that use email templates provided by Constant Contact and custom-code campaigns that use HTML/XHTML provided by the users, which is equivalent to using "Use My Own Code" option when creating a campaign in Constant Contact.

We only provide an ability to create a custom-code campaign through the API.  You can create either an HTML-based campaign or an XHTML-based campaign.  In both cases, you need to provide the details of the campaign you are trying to create, such as subject, from email address, reply-to email address, etc.

To create a campaign, call the following URI with POST method:

https://api.constantcontact.com/ws/customers/{user-name}/campaigns 

You also need to ensure that Content-Type HTTP header is set to application/atom+xml.  The body of the request should contain the elements of a campaign, as described in the Campaigns Collection Reference.  The following XML contains all the required elements to create a campaign and you just need to change the values to create a campaign.

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/campaigns" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
  <title type="text">API Test Email</title>
  <updated>2009-10-19T18:34:53.105Z</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/"
id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100546096289">
      <Name>API Test Email</Name>
      <Status>Draft</Status>
      <Date>2009-10-19T18:34:53.105Z</Date>
      <Subject>Enter email subject here</Subject>
      <FromName>joesflowers@example.com</FromName>
      <ViewAsWebpage>NO</ViewAsWebpage>
      <ViewAsWebpageLinkText></ViewAsWebpageLinkText>
      <ViewAsWebpageText></ViewAsWebpageText>
      <PermissionReminder>YES</PermissionReminder>
      <PermissionReminderText>You're receiving this email because of your relationship with ctct. 
Please &lt;ConfirmOptin>&lt;a style="color:#0000ff;">confirm&lt;/a>&lt;/ConfirmOptin> 
your continued interest in receiving email from us.</PermissionReminderText>
      <GreetingSalutation>Dear</GreetingSalutation>
      <GreetingName>FirstName</GreetingName>
      <GreetingString>Greetings!</GreetingString>
      <OrganizationName>ctct</OrganizationName>
      <OrganizationAddress1>123 wsw st</OrganizationAddress1>
      <OrganizationAddress2></OrganizationAddress2>
      <OrganizationAddress3></OrganizationAddress3>
      <OrganizationCity>Ashland</OrganizationCity>
      <OrganizationState>MA</OrganizationState>
      <OrganizationInternationalState></OrganizationInternationalState>
      <OrganizationCountry>us</OrganizationCountry>
      <OrganizationPostalCode>32423</OrganizationPostalCode>
      <IncludeForwardEmail>NO</IncludeForwardEmail>
      <ForwardEmailLinkText></ForwardEmailLinkText>
      <IncludeSubscribeLink>NO</IncludeSubscribeLink>
      <SubscribeLinkText></SubscribeLinkText>
      <EmailContentFormat>HTML</EmailContentFormat>
      <EmailContent>&lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" 
xmlns:cctd="http://www.constantcontact.com/cctd">
&lt;body>&lt;CopyRight>Copyright (c) 1996-2009 Constant Contact. All rights reserved.  Except as permitted under a
separate
written agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on any
Constant Contact site,
including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, or
distributed without the
prior written permission of Constant Contact.  For inquiries regarding reproduction or distribution of any Constant
Contact material, please
contact joesflowers@example.com.&lt;/CopyRight>
&lt;OpenTracking/>
&lt;!--  Do NOT delete previous line if you want to get statistics on the number of opened emails -->
&lt;CustomBlock name="letter.intro" title="Personalization">
    &lt;Greeting/>
&lt;/CustomBlock>
&lt;/body>
&lt;/html></EmailContent>
      <EmailTextContent>&lt;Text>This is the text version.&lt;/Text></EmailTextContent>
      <StyleSheet></StyleSheet>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/lists/1" rel="self" />
        </ContactList>
      </ContactLists>
      <FromEmail>
        <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/settings/emailaddresses/1"
          rel="self" />
        </Email>
        <EmailAddress>joesflowers@example.com</EmailAddress>
      </FromEmail>
      <ReplyToEmail>
        <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/settings/emailaddresses/1"
          rel="self" />
        </Email>
        <EmailAddress>joesflowers@example.com</EmailAddress>
      </ReplyToEmail>
    </Campaign>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
    <title type="text">Campaigns for customer: joesflowers</title>
    <link href="campaigns" />
    <link href="campaigns" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2009-10-19T19:36:12.622Z</updated>
  </source>
</entry>

Because we use the Atom specification for XML, there are several elements that are required even though they are not used by the server and are replaced upon a successful contact creation.  These elements are <id>, <title>, <author>, and <updated> elements. The <title> and <author> elements may be empty. The <id> must contain a URI, but since the value is not used by the server, any URI will work. The server does not check for uniqueness when creating a contact because a new unique ID will be created anyway. The <updated> element must contain a date or date/time value, but again the value is not used by the server.

Since the API only supports creating a custom-code campaign, there is no reason to specify <CampaignType>, which will be ignored.

You need to ensure to specify the correct value in <EmailContentFormat> element.  If it is set to HTML, then the values in <EmailContent> will be treated like HTML the same was it is treated in our UI.  Since we do not validate the correctness of HTML, you will be able to create a HTML-based campaign with invalid HTML so it is imperative that you ensure your HTML is correct.

If it is set to XHTML, then the values in <EmailContent> will be treated like XHTML the same way it is treated in our UI, which means it will be subject to a more strict validation to ensure the XHTML is valid.  If it is not valid, you will receive an error and the campaign will not be created.  In addition, <TextContent> also needs to be in valid XHTML format and any text content you pass in must be enclosed by <Text></Text> tags.

<FromEmail> and <ReplyToEmail> must be set with the account's confirmed email addresses and their values must be valid ID's from Account Settings Email Addresses collection and resource.

There are three sets of elements that go together:

  • <ViewAsWebpage>, <ViewAsWebpageLinkText> and <ViewAsWebpageText>
    If <ViewAsWebpage> is set to 'YES', then values in <ViewAsWebpageLinkText> and <ViewAsWebpageText> will be used, and a link to view the campaign as a webpage will be included in the campaign.  If <ViewAsWebpage> is set to 'NO', then values in the other two elements will be ignored. 
     
  • <IncludeFowardEmail> and <ForwardEmailLinkText>
    If <IncludeFowardEmail> is set to 'YES', then the value in <ForwardEmailLinkText> will be used to insert a link in the campaign.  This is the same as "Forward Email to Friend" feature in the UI.  If <IncludeForwardEmail> is set to 'NO', then <FowardEmailLinkText> will be ignored.
     
  • <IncludeSubscribeLink> and <SubscribeLinkText>
    If <IncludeSubscribeLink> is set to 'YES', then the value in <SubscribeLinkText> will be used to insert a link in the forwarded email for "Forward Email to Friend" feature in the UI.  If <IncludeSubscribeLink> is set to 'NO', then <SubscribeLinkText> will be ignored.

The elements <GreetingSalutation>, <GreetingName> and <GreetingString> ared used to specify how the greeting in the campaign should be set.  <GreetingSalutation> and <GreetingName> are combined to create a recipient-specific greeting; if the value specified in <GreetingName> does not exist for a particular contact, such as missing FirstName, then <GreetingString> will be used.  The valid values for <GreetingName> are 'FirstName', 'LastName', 'FirstAndLastName' or 'NONE'.

The user's organization information is represented by <OrganizationName>, <OrganizationAddress1>, <OrganizationAddress2>, <OrganizationAddress3>, <OrganizationCity>, <OrganizationState>, <OrganizationInternationalState> and <OrganizationCountry> elements.  You can specify values in these elements that will be applied speicfically to the campaign you are creating.  They do not overwrite the default settings for the user.

The actual content of the campaign is described by <EmailContent>, <TextContent> and <StyleSheet> elements.  For HTML campaign, you need to specify <EmailContent> and <TextContent>  For XHTML, you need to specify <EmailContent>, <TextContent> and optionally <StyleSheet>.  Any values passed through these elements, in both HTML and XHTML, must be HTML-encoded in order for the API to work properly.  For example, '<' must be converted to '&lt;', etc.  Most programming languages offer ways to perform HTML-encoding so you must utilize such functionality to do this.  If you are creating an XHTML campaign, invalid XHTML in <EmailContent> will give you an error and the campaign will not be created.

To learn more about how to use HTML and XHTML in your custom code campaign, please consult the Advanced Editor User Guide.

<PermissionReminder> and <PermissionReminderText> specify whether you want to include a link for a confirmed opt-in in your email.  Please note that because the text is part of an email, you must HTML-encode any tags you choose to use in <PermissionReminderText>, such as <ConfirmOptIn> tag.

For more details on the XML specification of the request body, please refer to the Campaign Collection and Resource Reference.

 

Updating a Campaign

You can update both template-based campaign and custom-code campaign.  For template-based campaign, you can only update properties associated with the campaign, but not the actual email content itself.  For custom-code campaign, you can update properties as well as update the HTML/XHTML associated with the campaign.  A campaign can only be updated in DRAFT status.

To update a campaign, the easiest way is to get details of a campaign, as described in Obtaining a Campaign's Information, and modify only the elements you would like to change, and use the resulting XML through a PUT operation on the campaign URI.

When updating a campaign, you can change values of elements that are marked as editable in the Campaign Collection Reference.

For a custom-code campaign, <EmailContent> is required.  If you have <EmailContent> in your request but do not have any values, then the content of the campaign will be deleted.  If <EmailContent> element is not included in the XML, then the HTML content of the campaign will not be touched.

To learn more about how to use HTML and XHTML in your custom code campaign, please consult the Advanced Editor User Guide.

The body of the request should contain the elements of a campaign, as described in the Campaigns Collection Reference.  Please note that values in non-editable elements do not matter when  you are creating a new campaign, but we advise you keep all the elements from a GET operation when you are creating a new campaign using the returned XML in order to make sure you can successfully create a campaign at all times.  Any editable elements that do not have any values specified during an update will overwrite any existing values with an empty field.  For example, if you had set <GreetingString> in your campaign, and then if you PUT <GreetingString></GreetingString>, then any value you had as your greeting string will be deleted.

 

Searching for a Campaign

You can search for campaigns based on their status.  In order to search for campaigns, use the campaigns collection and pass in the status as a parameter.  For example, to search for campaigns that have been sent, you can call GET on the following URI:

https://api.constantcontact.com/ws/customers/{user-name}/campaigns?status=SENT

The valid statuses are: DRAFT, RUNNING, SENT and SCHEDULED, and the case does not matter.

If there are no campaigns with the requested status, the API will return an empty feed with no <entry>.

 

Removing a Campaign

You can remove a campaign by issuing DELETE directly on a specific campaign.  This operation is the same as removing a campaign from the UI and will exclude the removed campaign from overall statistics.

For example, calling DELETE on the following URI will remove the campaign:

https://api.constantcontact.com/ws/customers/{user-name}/campaigns/{campaign-id}

 

Campaign Collection and Resource Reference

You can use campaigns collection list campaigns and create a new campaign, and use a specific campaign resource to modify or delete a campaign.  To find out more about how to use the campaign collection and resource, refer to Managing Email Campaigns.

The campaign resource utilizes another resource that represents the user's email addresses, in order to specify "From Eamil" and "Reply To Email" fields in a campaign.  To find out more about this resource, refer to Using Account Settings Email Addresses.  To read up on technical reference for the resource, refer to Account Settings Email Address Reference.

 

Campaigns Collection

The campaigns collection refers to a group of campaigns available to a particular user.  By performing GET on the collection itself, you retrieve a list of campaigns.  By performing a POST on the collection, you can add a new campaign to the collection.

Request Format

GET https://api.constantcontact.com/ws/customers/{user-name}/campaigns

For more detailed information about the URI, refer to the URI Format description.

For more information about listing campaigns, refer to Managing Email Campaigns.

Response Format

<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
  <title type="text">Campaigns for customer: joesflowers</title>
  <link href="campaigns" />
  <link href="campaigns" rel="self" />
  <author>
    <name>joesflowers</name>
  </author>
  <updated>2009-10-19T18:55:01.918Z</updated>
  <link href="/ws/customers/joesflowers/campaigns?next=2" rel="next" />
  <link href="/ws/customers/joesflowers/campaigns" rel="current" />
  <link href="/ws/customers/joesflowers/campaigns" rel="first" />
  <entry>
    <link href="/ws/customers/joesflowers/campaigns/1100546096289" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100546096289</id>
    <title type="text">Spring Campaign</title>
    <updated>2009-10-19T18:34:53.105Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.
      com/ws/customers/joesflowers/campaigns/1100546096289">
        <Name>Spring Campaign</Name>
        <Status>Sent</Status>
        <Date>2009-10-19T18:34:53.105Z</Date>
      </Campaign>
    </content>
  </entry>
  <entry>
    <link href="/ws/customers/joesflowers/campaigns/1100546028219" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100546028219</id>
    <title type="text">Fall Campaign</title>
    <updated>2009-10-16T13:55:48.369Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.
      com/ws/customers/joesflowers/campaigns/1100546028219">
        <Name>Fall Campaign</Name>
        <Status>Draft</Status>
        <Date>2009-10-16T13:55:48.369Z</Date>
      </Campaign>
    </content>
  </entry>
</feed>

Each <entry> elements represent a campagin.  A campaign's unique ID is given by <id> and the link that you should use to retrieve the details of a campaign is given in <link> with rel attribute value of "edit".  You should use the value of this <link> element concatenated after our server name.  From the above example, the constructed URI for the campaign is https://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100546028219.

For more detailed descriptions of the XML elements, refer to the Campaign Elements Data section.

 

Request Format

POST https://api.constantcontact.com/ws/customers/{user-name}/campaigns

For more detailed information about the URI, refer to the URI Format description.

To learn more about how to create a campaign, please refer to the Managing Email Campaigns.

The XML body must be passed as part of the request to describe the campaign that you would like to create.  The following shows an example of what the XML should look like.

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/campaigns" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
  <title type="text">API Test Email</title>
  <updated>2009-10-19T18:34:53.105Z</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/"
id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100546096289">
      <Name>API Test Email</Name>
      <Status>Draft</Status>
      <Date>2009-10-19T18:34:53.105Z</Date>
      <Subject>Enter email subject here</Subject>
      <FromName>joesflowers@example.com</FromName>
      <ViewAsWebpage>NO</ViewAsWebpage>
      <ViewAsWebpageLinkText></ViewAsWebpageLinkText>
      <ViewAsWebpageText></ViewAsWebpageText>
      <PermissionReminder>YES</PermissionReminder>
      <PermissionReminderText>You're receiving this email because of your relationship with ctct. 
Please &lt;ConfirmOptin>&lt;a style="color:#0000ff;">confirm&lt;/a>&lt;/ConfirmOptin> 
your continued interest in receiving email from us.</PermissionReminderText>
      <GreetingSalutation>Dear</GreetingSalutation>
      <GreetingName>FirstName</GreetingName>
      <GreetingString>Greetings!</GreetingString>
      <OrganizationName>ctct</OrganizationName>
      <OrganizationAddress1>123 wsw st</OrganizationAddress1>
      <OrganizationAddress2></OrganizationAddress2>
      <OrganizationAddress3></OrganizationAddress3>
      <OrganizationCity>Ashland</OrganizationCity>
      <OrganizationState>MA</OrganizationState>
      <OrganizationInternationalState></OrganizationInternationalState>
      <OrganizationCountry>us</OrganizationCountry>
      <OrganizationPostalCode>32423</OrganizationPostalCode>
      <IncludeForwardEmail>NO</IncludeForwardEmail>
      <ForwardEmailLinkText></ForwardEmailLinkText>
      <IncludeSubscribeLink>NO</IncludeSubscribeLink>
      <SubscribeLinkText></SubscribeLinkText>
      <EmailContentFormat>HTML</EmailContentFormat>
      <EmailContent>&lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" 
xmlns:cctd="http://www.constantcontact.com/cctd">
&lt;body>&lt;CopyRight>Copyright (c) 1996-2009 Constant Contact. All rights reserved.  Except as permitted under a
separate
written agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on any
Constant Contact site,
including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, or
distributed without the
prior written permission of Constant Contact.  For inquiries regarding reproduction or distribution of any Constant
Contact material, please
contact joesflowers@example.com.&lt;/CopyRight>
&lt;OpenTracking/>
&lt;!--  Do NOT delete previous line if you want to get statistics on the number of opened emails -->
&lt;CustomBlock name="letter.intro" title="Personalization">
    &lt;Greeting/>
&lt;/CustomBlock>
&lt;/body>
&lt;/html></EmailContent>
      <EmailTextContent>&lt;Text>This is the text version.&lt;/Text></EmailTextContent>
      <StyleSheet></StyleSheet>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/lists/1" rel="self" />
        </ContactList>
      </ContactLists>
      <FromEmail>
        <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/settings/emailaddresses/1"
          rel="self" />
        </Email>
        <EmailAddress>joesflowers@example.com</EmailAddress>
      </FromEmail>
      <ReplyToEmail>
        <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/settings/emailaddresses/1"
          rel="self" />
        </Email>
        <EmailAddress>joesflowers@example.com</EmailAddress>
      </ReplyToEmail>
    </Campaign>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
    <title type="text">Campaigns for customer: joesflowers</title>
    <link href="campaigns" />
    <link href="campaigns" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2009-10-19T19:36:12.622Z</updated>
  </source>
</entry>

For more detailed descriptions of the XML elements, refer to the Campaign Elements Data section.

 

Campaign Resource

The campaign resource refers to individual campaigns under the campaigns collection.  Each campaign is represented with an ID and resides under the campaigns collection in the URI.  By performing GET on a specific campaign resource, you retrieve details of a particular campaign.  By performing PUT on a specific campaign resource, you make updates to a particular campaign.   

Request Format

GET https://api.constantcontact.com/ws/customers/{user-name}/campaigns/{campaign-id}

For more detailed information about the URI, refer to the URI Format description.

To learn more about how to obtain a campaign's details, please refer to the Managing Email Campaigns.

 

Response Format

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/campaigns/1100545398420" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100545398420</id>
  <title type="text">joesflowers custom campaign HTML</title>
  <updated>2009-10-01T18:42:56.939Z</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.
    com/ws/customers/joesflowers/campaigns/1100545398420">
      <Name>joesflowers custom campaign HTML</Name>
      <Status>Draft</Status>
      <Date>2009-10-01T18:42:56.939Z</Date>
      <LastEditDate>2009-10-01T18:43:40.656Z</LastEditDate>
      <Sent>0</Sent>
      <Opens>0</Opens>
      <Clicks>0</Clicks>
      <Bounces>0</Bounces>
      <Forwards>0</Forwards>
      <OptOuts>0</OptOuts>
      <SpamReports>0</SpamReports>
      <Subject>Enter email subject here</Subject>
      <FromName>joesflowers</FromName>
      <CampaignType>CUSTOM</CampaignType>
      <ViewAsWebpage>YES</ViewAsWebpage>
      <ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText>
      <ViewAsWebpageText>Having trouble viewing this email?</ViewAsWebpageText>
      <PermissionReminder>YES</PermissionReminder>
      <PermissionReminderText>You're receiving this email because of your relationship with Constant Contact. Please &lt;
      ConfirmOptin>&lt;a style="color:#0000ff;">confirm&lt;/a>&lt;/ConfirmOptin> your continued interest in receiving
      email from us.</PermissionReminderText>
      <GreetingSalutation>Dear</GreetingSalutation>
      <GreetingName>First_Name</GreetingName>
      <GreetingString>Greetings!</GreetingString>
      <OrganizationName>Constant Contact</OrganizationName>
      <OrganizationAddress1>1601 Trapelo Rd.</OrganizationAddress1>
      <OrganizationAddress2></OrganizationAddress2>
      <OrganizationAddress3></OrganizationAddress3>
      <OrganizationCity>Waltham</OrganizationCity>
      <OrganizationState>MA</OrganizationState>
      <OrganizationInternationalState></OrganizationInternationalState>
      <OrganizationCountry>us</OrganizationCountry>
      <IncludeForwardEmail>YES</IncludeForwardEmail>
      <ForwardEmailLinkText>Forward email</ForwardEmailLinkText>
      <IncludeSubscribeLink>YES</IncludeSubscribeLink>
      <SubscribeLinkText>Subscribe me!</SubscribeLinkText>
      <EmailContentFormat>HTML</EmailContentFormat>
      <EmailContent>&lt;!-- If your HTML code DOES include the html, head, and body tags,
replace the entire code below with your custom HTML code.

Please note, if you want to use the Constant Contact personalized greeting,
make sure to add the &lt;Greeting/> tag to your code. -->

&lt;html>
&lt;body>
&lt;Greeting />
&lt;!-- If your HTML code DOES NOT include the html, head, and body tags,
paste your custom HTML code between the START and END comments  -->
&lt;!--    START    -->


&lt;!--     END     -->
&lt;/body>
&lt;/html></EmailContent>
      <EmailTextContent>&lt;Text>
&lt;Greeting />
&lt;/Text></EmailTextContent>
      <StyleSheet></StyleSheet>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/2">
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.
          com/ws/customers/joesflowers/lists/2" rel="self" />
        </ContactList>
      </ContactLists>
      <FromEmail>
        <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.
          com/ws/customers/joesflowers/settings/emailaddresses/1" rel="self" />
        </Email>
        <EmailAddress>joesflowers@constantcontact.com</EmailAddress>
      </FromEmail>
      <ReplyToEmail>
        <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.
          com/ws/customers/joesflowers/settings/emailaddresses/1" rel="self" />
        </Email>
        <EmailAddress>joesflowers@constantcontact.com</EmailAddress>
      </ReplyToEmail>
    </Campaign>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
    <title type="text">Campaigns for customer: joesflowers</title>
    <link href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns" />
    <link href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2009-10-01T18:43:40.731Z</updated>
  </source>
</entry>

 For more detailed descriptions of the XML elements, refer to the Campaign Elements Data section.

 

Request Format

PUT https://api.constantcontact.com/ws/customers/{user-name}/campaigns/{campaign-id}

For more detailed information about the URI, refer to the URI Format description.

To learn more about how to modify a campaign, please refer to the Managing Email Campaigns.

The XML body used for PUT should look the same as the response you get from a GET operation.  The easiest way to make changes to a campaign is to retrieve its details through a GET operation, and modify only the elements you want and posting the changes using the PUT operation.

 

Request Format

DELETE https://api.constantcontact.com/ws/customers/{user-name}/campaigns/{campaign-id}

For more detailed information about the URI, refer to the URI Format description.

To learn more about how to delete a campaign, please refer to the Managing Email Campaigns.

 

URI Format

URI Component Description
user-name

The account owner's Constant Contact user name.
Value must be in lower case.

campaigns

To find particular campaigns, query the collection by adding one or more query parameters to the collection's URI:

campaigns?status=SENT

Below are the choices of status for query:

Status Description
SENT All campaigns that have been sent and not currently scheduled for resend
SCHEDULED All campaigns that are currently scheduled to be sent some time in the future
DRAFT All campaigns that have not yet been scheduled for delivery
RUNNING All campaigns that are currently being processed and delivered

 

campaign-id

Represents an individual Campaign entry. 

It can be obtained from the Location header after creating a new <entry> or from <link> element that has in the rel="edit" attribute in an existing <entry> of Campaigns collection.

 

 

Campaign Data Elements

Property Name Allowed Values

Editable?

Description

Name

 

Yes

Name for the Campaign

Date

 

No

 

LastEditDate

 

No

Last date/time the Campaign was edited

LastRunDate

 

No

Last date/time the Campaign ran

NextRunDate

 

No

The next date/time the Campaign will run

Status

Draft, Running, Scheduled,  Archive Pending, Archived, Close Pending, Closed, Sent

No

Status of the Campaign

Sent

 

No

Number of emails sent for the campaign

Opens

 

No

Number of unique opens

Clicks

 

No

Number of unique clicks

Bounces

 

No

Number of bounced emails

Forwards

 

No

Number of times the campaign was forwarded (using the Forward link if included)

OptOuts

 

No

Number of opt outs from the campaign

Subject

 

Yes

Subject line for the email

FromName

 

Yes

The name that is displayed in the from box in the recipients email client

FromEmail

 

Yes

Email address entry represents From address shows the address that the email originated from

ReplyToEmail

 

Yes

Email address entry represents the field used by an email client's reply function

CampaignType

STOCK/CUSTOM No Describes whether the email campaign is based on a template (STOCK) or on HTML/XHTML custom code (CUSTOM).

ViewAsWebpage

YES/NO

Yes

This allows contacts who cannot view images in their email program to open your email in a browser window.

ViewAsWebpageLinkText

 

Yes

The text for the actual link in the View As Webpage link in the email

ViewAsWebageText

 

Yes

The text displayed together with the LinkText at the top of your email

PermissionReminder

YES/NO

Yes

Whether to show a permission reminder at the top of the email allowing recipients to confirm their opt in. FAQ

GreetingSalutation

 

Yes

Describes the chosen salutation to be used at the opening of the email (e.g. Dear)

GreetingName

FirstName, LastName, FirstAndLastName, None

Yes

Indicates if the email greeting should include just the recipient's FirstName, just the LastName, Both, or neither and use GreetingString instead.

GreetingString

 

Yes

Allows you to specify the full greeting string instead of the components of the previous two properties. If GreetingName and GreetingString are populated, they will be used instead of GreetingString.

OrganizationName

 

Yes

Name of organization for use in the email footer

OrganizationAddress1

 

Yes

Line 1 of the organization address for use in the email footer

OrganizationAddress2

 

Yes

Line 2 of the organization address for use in the email footer

OrganizationAddress3

 

Yes

Line 3 of the organization address for use in the email footer

OrganizationCity

 

Yes

City of the organization for use in the email footer

OrganizationState

 

Yes

State of the organization for use in the email footer

OrganizationInternationalState

 

Yes

International "State" if outside the US for use in the email footer

OrganizationPostalCode

 

Yes

PostalCode/Zipcode of the organization for use in the email footer

OrganizationCountry

 

Yes

Country of the organization for use in the email footer

IncludeForwardEmail

YES/NO

Yes

Boolean type property that indicates if the email should include a Forward This Email link

ForwardEmailLinkText

 

Yes

If IncludeForwardEmail property is set to YES, then this property should be specified and will appear in the email as the text of the link

IncludeSubscribeLink

YES/NO

Yes

Boolean type property that indicates if the email should include a Subscribe link

SubscribeLinkText

 

Yes

If IncludeSubscribeLink property is set to YES, then this property should be specified and will appear in the email as the text of the link

EmailContentFormat

HTML/XHTML Yes Describes whether email content is based on HTML or XHTML.

EmailContent

 

Yes

The full HTML/XHTML content of the email

EmailTextContent

 

Yes

The text version of the email content. Will be used for email clients that do not have HTML email capability or have it disabled.

StyleSheet

  Yes The stylesheet elements that are used for the email content.

URLS

 

No

Collection of URL entries that were included in this email for click tracking purposes

ContactLists

 

No

Collection of ContactList entries that are associated with this email Campaign

 

 

Retrieving Account Email Addresses

Each user has email addresses that have been registered in the user account.  These email addresses can be retrieved by using the Account Email Address resource.

Please select what you would like to do:

 

Retrieving a List of Account Email Addresses

You can retrieve a list of account email addresses by using the GET method on the email address collection:

https://api.constantcontact.com/ws/customers/{user-name}/settings/emailaddresses

The GET method will return a list of email addresses that are registered in the account as described in the Account Email Address resource.  Each <entry> represents an email address, and its unique ID is presented in <id>.  The link that retrieves the details of an email address is presented in <link> with rel attribute of "edit".

 

Retrieving Email Address Details

You can get details of a particular email address by using the GET method on an email address resource:

https://api.constantcontact.com/ws/customers/{user-name}/settings/emailaddresses/{email-id}

The details of an email address include its status and verified time.

Account Email Addresses Collection and Resource

The account settings email address collection and resource allows you to retrieve a list of registered email addresses on your account as specified in the Settings in the UI. These email addresses are used in conjunction with campaign resource to specify From Email and Reply To email addresses.

To learn more about how to use email address collectino and resource, refer to Retrieving Account Email Addresses.

Account Email Addresses Collection

The email addresses collection gives you a list of email addresses you registered with your account in the Settings.  Each <entry> represents an email address and gives you a summary of each email address.

Request Format

GET https://api.constantcontact.com/ws/customers/{user-name}/settings/emailaddresses

For more detailed description about the above URI, please refer to the URI Format description.

To learn more about how to retrieve a list of email addresses registered in your account, please refer to Retrieving Account Email Addresses.

Response Format

<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses</id>
  <title type="text" />
  <link href="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses" />
  <link href="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses" rel="self" />
  <author>
    <name>joesflowers</name>
  </author>
  <updated>2009-10-01T20:18:22.775Z</updated>
  <entry>
    <link href="/ws/customers/joesflowers/settings/emailaddresses/1" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1</id>
    <title type="text">joesflowers@example.com</title>
    <updated>2009-05-21T17:44:04.609Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.
      com/ws/customers/joesflowers/settings/emailaddresses/1">
        <EmailAddress>joesflowers@example.com</EmailAddress>
        <Status>Verified</Status>
        <VerifiedTime>2009-05-21T17:44:04.609Z</VerifiedTime>
      </Email>
    </content>
  </entry>
  <entry>
    <link href="/ws/customers/joesflowers/settings/emailaddresses/2" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/2</id>
    <title type="text">joesflowers2@example.com</title>
    <updated>2009-09-02T13:27:36.552Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.
      com/ws/customers/joesflowers/settings/emailaddresses/2">
        <EmailAddress>joesflowers2@example.com</EmailAddress>
        <Status>Pending</Status>
      </Email>
    </content>
  </entry>
</feed>

Each <entry> represents an email address registered with the account.  Its unique ID is givein in <id> element while the link to get more of its detail is given in <link> element with rel attribute of "edit".

For more detailed descriptions of the XML elements, refer to the Email Address Elements Data section.

 

Account Email Address Resource

The account email address represents an email address that has been registered in your account.

Request Format

GET https://api.constantcontact.com/ws/customers/{user-name}/settings/emailaddresses/{email-id}

 For more detailed description about the above URI, please refer to the URI Format description.

To learn more about how to retrieve a list of email addresses registered in your account, please refer to Retrieving Account Email Addresses.

Response Format

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/settings/emailaddresses/1" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1</id>
  <title type="text">joesflowers@example.com</title>
  <updated>2009-05-21T17:44:04.609Z</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.
    com/ws/customers/joesflowers/settings/emailaddresses/1">
      <EmailAddress>joesflowers@example.com</EmailAddress>
      <Status>Verified</Status>
      <VerifiedTime>2009-05-21T17:44:04.609Z</VerifiedTime>
    </Email>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses</id>
    <title type="text" />
    <link href="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses" />
    <link href="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2009-10-01T21:06:25.486Z</updated>
  </source>
</entry>

For more detailed descriptions of the XML elements, refer to the Email Address Elements Data section.

 

URI Format

URI Component Description
user-name

The account owner's Constant Contact user name.
Value must be in lower case.

settings Represents the settings of your account.
emailaddresses Represents email addresses registered under the account.
email-id

Retrieves an individual email address entry. 

Obtained the specific contact's URI with its ID from the Location header after creating a new <entry> or from an existing <entry> in the <link> element that has in the rel="edit" attribute. 

 

Email Address Elements Data

Name Allowed values Editable? Description
EmailAddress   No A valid email address
Status Verified
Pending
No The verification status of the email address.
VerifiedTime   No The time the email address was verified. Not returned if the address is in a Pending state

 

Contact Events Service

Overview

The Contact Events service provides access to the events (email sends, opens, clicks...) associated with a Contact (within the past 90 days). It helps answer these kinds of question: What Campaigns (emails) did this Contact receive? Which emails did they open? What links did that Contact Click on? When did they perform that action?
The Contacts Events Services does this through several read-only collections that track the interactions between Campaigns and Contacts. The events include sends, opens, opt-outs (unsubscribes), clicks, bounces, and forwards. The contact events collections available can be determined by retrieving the service document from the URI http://api.constantcontact.com/ws/customers/{UserName}/contacts/{ContactId}/events/. (Note that the final '/' in the preceding URL is required.)

Example

Retrieving the service document for a contact in our sample, gets:

<?xml version='1.0' encoding='UTF-8'?>
<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
  <workspace>
    <atom:title type="text">Constant Contact Web Services Event Workspace</atom:title>
    <collection href="/ws/customers/joesflowers/contacts/2084/events/bounces">
      <atom:title type="text">Bounce Events for Customer: joesflowers, Contact id: 2084</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/contacts/2084/events/clicks">
      <atom:title type="text">Click Events for Customer: joesflowers, Contact id: 2084</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/contacts/2084/events/forwards">
      <atom:title type="text">Forward Events for Customer: joesflowers, Contact id: 2084</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/contacts/2084/events/opens">
      <atom:title type="text">Open Events for Customer: joesflowers, Contact id: 2084</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/contacts/2084/events/optouts">
      <atom:title type="text">Opt-out Events for Customer: joesflowers, Contact id: 2084</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/contacts/2084/events/sends">
      <atom:title type="text">Send Events for Customer: joesflowers, Contact id: 2084</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
  </workspace>
</service>

 

The href attribute of each collection provides a link where that collection can be retrieved. Each collection will return a paged list of all the events of the type involving that contact for any campaign sent in the last 90 days. Events are immutable - once an event occurs, it never changes. Events are returned in reverse chronological order.

Here is an example of an event feed:

 

<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts/281/events/sends</id>
  <title type="text">Send Events for Customer: joesflowers, Contact id: 1</title>
  <link href="" />
  <link href="" rel="self" />
  <author>
    <name>joesflowers</name>
  </author>
  <updated>2008-08-07T20:27:04.627Z</updated>
  <link href="/ws/customers/joesflowers/contacts/281/events/sends" rel="first" />
  <link href="/ws/customers/joesflowers/contacts/281/events/sends" rel="current" />
  <entry>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts/281/events/sends/1122907878323,1,1217955004534</id>
    <title type="text">Email Send Event for Customer: joesflowers, Campaign: http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1122907878323</title>
    <updated>2008-08-05T16:50:04.534Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <SentEvent xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/281/events/sends/1122907878323,1,1217955004534">
        <Contact id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/1">
          <EmailAddress>ianjones@example.net</EmailAddress>
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.com/ws/customers/joesflowers/contacts/1" rel="self" />
        </Contact>
        <Campaign id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1122907878323">
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1122907878323" rel="self" />
        </Campaign>
        <EventTime>2008-08-05T16:50:04.534Z</EventTime>
      </SentEvent>
    </content>
  </entry>
</feed>

All events have the same basic form: a reference to a Contact, a reference to a Campaign, and the time when the event occurred. Some event types include additional information, see the data format description below.

Contact Tracking Event Data Format

All contact events have the following elements:

Name Allowed values Description
Contact   A reference to the Contact involved in the event. Contents of this element include an EmailAddress element and an atom:link element with its href attribute linking to the Contact.
Campaign   A reference to the Campaign which triggered the event. Contents of this element include an atom:link element with its href attribute linking to the Campaign.
EventTime Date/Time The time the event occurred, in Atom Date format.

Bounce Event Data Format

In addition to the Contact Tracking Event elements described above, Bounce events have the following additional elements:

Name Allowed values Description
Code B, D, F, V, X or Z One-letter bounce code.
Description   Description of the Code value:
B: Non-existent address
D: Undeliverable
F: Mailbox Full
V: Vacation/Auto Reply
X: Other
Z: Blocked
BounceMessage   Any message associated with the bounce.

Click Event Data Format

In addition to the Contact Tracking Event elements described above, Click events have the following additional elements:

Name Allowed values Description
LinkUrl URL The link that was clicked.

Forward Event Data Format

Forward events have no additional elements beyond the Contact Tracking Event elements described above.

Open Event Data Format

Open events have no additional elements beyond the Contact Tracking Event elements described above.

Optout Event Data Format

In addition to the Contact Tracking Event elements described above, Optout events have the following additional elements:

Name Allowed values Description
OptOutSource ACTION_BY_CUSTOMER, ACTION_BY_CONTACT Source of the opt-out
OptOutReason Text If provided, reason for the opt-out

Send Event Data Format

Send events have no additional elements beyond the Contact Tracking Event elements described above.

Sample Usage

See this page for a code example.

Campaign Events resource

Overview

The Campaign Events service provides access to the detailed results (Open, Click, Bounce and other Events) associated with any Campaign (email) sent in the last 90 days. It helps answer these kinds of question: What Contacts Opened my last email? What links in the Campaign did they Click On? When did the Contact perform the action?

The Campaign Events service does this through several read-only collections that track the interactions between Campaigns and Contacts. The events include sends, opens, opt-outs (unsubscribes), clicks, bounces, and forwards. The campaign events collections available can be determined by retrieving the service document from the URI http://api.constantcontact.com/ws/customers/{UserName}/campaigns/{CampaignID}/events/. (Note that the final '/' in the preceding URL is required).
 

Example

Retrieving the service document for a campaign in our sample, http://api.constantcontact.com/ws/customers/{UserName}/campaigns/{CampaignID}/events/, returns this XML:

<?xml version='1.0' encoding='UTF-8'?>
<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
  <workspace>
    <atom:title type="text">Constant Contact Web Services Event Workspace</atom:title>
    <collection href="/ws/customers/joesflowers/campaigns/1100544815515/events/bounces">
      <atom:title type="text">Bounce Events for Customer: joesflowers, Campaign id: : 1100544815515</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/campaigns/1100544815515/events/forwards">
      <atom:title type="text">Forward Events for Customer: joesflowers, Campaign id: : 1100544815515</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/campaigns/1100544815515/events/opens">
      <atom:title type="text">Open Events for Customer: joesflowers, Campaign id: : 1100544815515</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/campaigns/1100544815515/events/optouts">
      <atom:title type="text">Opt-out Events for Customer: joesflowers, Campaign id: : 1100544815515</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
    <collection href="/ws/customers/joesflowers/campaigns/1100544815515/events/sends">
      <atom:title type="text">Send Events for Customer: joesflowers, Campaign id: : 1100544815515</atom:title>
      <accept>application/atom+xml; type=entry</accept>
    </collection>
  </workspace>
</service>

 

The href attribute of each collection provides a link where a collection of the events of that type (Opens, Clicks...) can be retrieved. Each collection will return a paged list of all the Events of the type for that Campaign. Detailed Campaign Events are maintained for a period of 90 days following the first send of that Campaign. Events are immutable. Once an Event occurs, it never changes. Events are returned in reverse chronological order.

The Campaign resource has also been modified slightly. A URLs collection has been added that includes any URLs from email campaigns that have registered click events. See below for an example:

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/joesflowers/campaigns/1102414826616" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1102414826616</id>
  <title type="text">Copy of Jen R5 Deployment</title>
  <updated>2009-01-18T14:00:04.681Z</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1102414826616">
      <Name>Copy of Jen R5 Deployment</Name>
      <Status>Sent</Status>
      <Date>2009-01-18T14:00:04.681Z</Date>
      <LastEditDate>2009-01-17T13:53:12.932Z</LastEditDate>
      <LastRunDate>2009-01-18T14:00:04.676Z</LastRunDate>
      <Sent>1</Sent>
      <Opens>1</Opens>
      <Clicks>1</Clicks>
      <Bounces>0</Bounces>
      <Forwards>0</Forwards>
      <OptOuts>0</OptOuts>
      <SpamReports>0</SpamReports>
      <Urls>
        <Url id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1102414826616/events/urls/1011301655704/clicks">
          <value>http://www.bestbuy.com</value>
          <Clicks>1</Clicks>
        </Url>
      </Urls>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/41">
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.com/ws/customers/joesflowers/lists/41" rel="self" />
        </ContactList>
      </ContactLists>
    </Campaign>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns</id>
    <title type="text">Campaigns for customer: joesflowers</title>
    <link href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns" />
    <link href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns" rel="self" />
    <author>
      <name>joesflowers</name>
    </author>
    <updated>2009-01-19T13:47:03.700Z</updated>
  </source>
</entry>

 

Here is an example of an Event feed:

 

<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100544815515/events/sends</id>
  <title type="text">Send Events for Customer: joesflowers, Campaign id: 1100544815515</title>
  <link href="" />
  <link href="" rel="self" />
  <author>
    <name>joesflowers</name>
  </author>
  <updated>2008-08-07T20:27:04.627Z</updated>
  <link href="/ws/customers/joesflowers/campaigns/1100544815515/events/sends" rel="first" />
  <link href="/ws/customers/joesflowers/campaigns/1100544815515/events/sends" rel="current" />
  <entry>
    <id>http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100544653344/events/sends/1122907878323,1,1217955004534</id>
    <title type="text">Email Send Event for Customer: joesflowers, Campaign: http://api.constantcontact.com/ws/customers/joesflowers/campaigns/110054...
    <updated>2008-08-05T16:50:04.534Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <SentEvent xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100544815515/events/sends/1100544815515,1,1217692805901">
        <Contact id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/1">
          <EmailAddress>ianjones@example.net</EmailAddress>
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.com/ws/customers/joesflowers/contacts/1" rel="self" />
        </Contact>
        <Campaign id="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1122907878323">
          <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.com/ws/customers/joesflowers/campaigns/1100544815515" rel="self" />
        </Campaign>
        <EventTime>2008-08-05T16:50:04.534Z</EventTime>
      </SentEvent>
    </content>
  </entry>
</feed>

All events have the same basic form: a reference to a Contact, a reference to a Campaign, and the time when the event occurred. NOTE: Event detail information is only available for campaigns that were first sent in the past 90 days. Detail data for campaigns older than 90 days is not available, but high level aggregate statistics (number of sent, opens, etc) are available.

Some event types include additional information, see the data format description below.

Contact Tracking Event Data Format

All contact events have the following elements:

Name Allowed values Description
Contact   A reference to the Contact involved in the event. Contents of this element include an EmailAddress element and an atom:link element with its href attribute linking to the Contact.
Campaign   A reference to the Campaign which triggered the event. Contents of this element include an atom:link element with its href attribute linking to the Campaign.
EventTime Date/Time The time the event occurred, in Atom Date format.

Bounce Event Data Format

In addition to the Contact Tracking Event elements described above, Bounce events have the following additional elements:

Name Allowed values Description
Code B, D, F, V, X or Z One-letter bounce code.
Description   Description of the Code value:

B: Non-existent address
D: Undeliverable
F: Mailbox Full
V: Vacation/Auto Reply
X: Other
Z: Blocked
BounceMessage   Any message associated with the bounce.

Forward Event Data Format

Forward events have no additional elements beyond the Contact Tracking Event elements described above.

Open Event Data Format

Open events have no additional elements beyond the Contact Tracking Event elements described above.

Optout Event Data Format

In addition to the Contact Tracking Event elements described above, Optout events have the following additional elements:

Name Allowed values Description
OptOutSource ACTION_BY_CUSTOMER, ACTION_BY_CONTACT Source of the opt-out
OptOutReason Text If provided, reason for the opt-out

Send Event Data Format

Send events have no additional elements beyond the Contact Tracking Event elements described above.

REST API Authentication - Overview

API Authentication Overview

While the Constant Contact REST APIs technically supports several authentication models, at this point developers should leverage our Basic Authentication model.
 

Basic Authentication Over HTTPs

The Basic Authentication model should be used for all new development projects.

OAuth Authentication (Support Retracted)

Constant Contact developed and deployed support for an OAuth based Authentication model. However, due to a recently announced and acknowledged security vulnerability with the protocol, we are retracting support for our OAuth model. We are investigating the issue and considering appropriate API adjustments. Developers can and should leverage Basic Authentication. (For more information on the OAuth based vulnerability, please see this reference on the OAuth site).

Digest Authentication (Support Withdrawn July 31st 2009)

Constant Contact has deprecated support for the use of Digest Authentication with the REST APIs. Applications which are already using Digest Authentication will need to migrate their applications to another Authentication model by August 2009. Existing applications are encouraged to migrate to the OAuth based authentication model.

Digest Authentication **Deprecated and withdrawn in July 2009**

NOTE:

Constant Contact is withdrawing the Digest authentication mechanism in July 2009. Your application should not use Digest Authentication. This documentation is provided to aid existing API adopters in migrating their applications.
 

Overview

All API requests must be authenticated. The API supports several Authentication protocols, as described on the Authentication Overview section. This page discusses Digest Authentication. The API responds to unauthenticated requests with a 401 Unauthorized HTTP status. The response will include a WWW-Authenticate header with a Digest Authentication challenge string. Typically, API developers will not need to implement Digest Authentication because most standard HTTP client libraries include Digest implementations. All the API developer needs to do is provide the proper Username and Password values which are constructed as described below.

API Application Key

The API application key is used to identify the application making an API request. Developers should use a different key for each application they write. Developers should never disclose their API keys to anyone or place them in a web page where they can be seen with "View Source". If your key is compromised notify Constant Contact immediately. Anyone with access to your key can impersonate your application, which could lead to that key being disabled.

The key itself is a UUID, an identifier provided to developers by Constant Contact on request, subject to Constant Contact terms and conditions.

Getting an API Application Key

To get an API key, provide your Constant Contact (*not your developer web site*) login credentials and follow the simple flow here.

Making an Authenticated Request

The API key identifies the application making the request. API authentication is also used to verify that an application is allowed to perform the requested operation. The customer grants permission by providing his or her Username and Password to the application. Digest Authentication allows the application to prove that it has access to the customer's password without actually including it in the request.

The Constant Contact API Authentication uses standard HTTP Digest User Authentication as defined by RFC 2617. Digest authentication is implemented by most HTTP client libraries including those in Java (java.net package or Apache HttpClient), Javascript (XmlHttpRequest), .NET (System.Net HttpWebRequest and CredentialsCache) and PHP (HTTP extension).

To send an authenticated request, you must build the credentials in the following way:

Username: {API Key}%{Username}
The API Application Key, followed by a '%' (percent sign character), followed by a the customer's (not the developer's) Username
Password: {Password}
The customer's (not the developer's) Password

For example, if the developers API key is 7xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, the customer's Username is ctct_customer and the customer's Password is mypassword, then the request credentials would be:

Username: 7xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%ctct_customer
Password: mypassword

API Authentication Using Basic Over HTTPs

API Authentication Using Basic Authentication Over HTTPS

The Constant Contact REST APIs support several authentication models. This page documents the preferred Authentication model - Basic Authentication.

The Constant Contact Basic Authentication model:

  • Is supported only over https.
  • Provides a relatively direct mitigation path for pre-existing API adopters who leveraged Digest Authentication.

API Access Using Basic Authentication

The Basic Authentication model used in the REST APIs is designed to authenticate both the application developer (via an API Key) and a Constant Contact customer (via that customer's Constant Contact UserName and Password). Authentication credentials are required on each API request.

Each application is identified by an API Application Key. The key is a private credential which is directly associated with a single 'developer'. Constant Contact distributes API Keys to developers. To get your first API key, or to get an additional key to cover a subsequent application, simply Request API Access Using This Online Form.

In addition to the API key, each request must include the authentication information for the account which is being accessed. Specifically, the request must include the Constant Contact UserName and Password for the customer account being accessed.

API authentication is based on HTTP Basic Authentication. In order to secure access credentials are they are sent across the network, the Constant Contact API only accepts HTTPS Basic Authentication requests. Authentication requests via HTTP will be rejected.

Constructing the HTTP Credentials

Most modern browsers and http libraries inherently manage the details of the Basic Authentication. Your application will need to construct a HTTP Username from a concatenation of your API User Key, the "%" character and the Constant Contact customer's UserName. This information is passed with Constant Contact Customer's Password in the HTTP Header and the HTTP library should manage the details. 

Converting your Digest Authentication Implementation to a Basic Authentication Implementation

Basic Authentication is one of the simplest forms of HTTP Authentication. If your application is using a library to handle Digest Authentication, migrating that application to support Basic Authentication is comprised of two steps.

  1. Use HTTPS instead of HTTP - For URI's you use to call any API, use HTTPS instead of HTTP.  However, in the XML body you send in, DO NOT change HTTP to HTTPS (see example below).

    Example
    To update a contact, you use the following URI (note the use of HTTPS instad of HTTP):

    https://api.constantcontact.com/ws/customers/joesflowers/contacts/101

    For the contact information, you would normally get the contact information using GET, update the data you want, and re-use the XML body as below (Note we did not change "http" used in the XML body to "https"):

    <entry xmlns="http://www.w3.org/2005/Atom">
      <id>http://api.constantcontact.com/ws/customers/joesflowers/contacts/101</id>
      <title type="text">Contact: u86597@example.com</title>
      <updated>2008-04-25T19:29:06.096Z</updated>
      <author> </author>
      <content type="application/vnd.ctct+xml">
        <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/joesflowers/contacts/101">
          <EmailAddress>u86597@example.com</EmailAddress>
          <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
          <ContactLists>
            <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1"></ContactList>
            <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/11"></ContactList>
            <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/12"></ContactList>
            <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/14"></ContactList>
          </ContactLists>
        </Contact>
      </content>
    </entry>
  2. Convert your application to use SSL communications (Handling SSL communication is beyond the scope of this documentation).  Unlike HTTP, which uses port 80, HTTPS uses port 443.  Please ensure that you are communicating over port 443 instead of port 80.

  3. Ensure you are using Basic Authentication instead of Digest Authentication - This commonly consists of simply identifying the appropriate authentication model for your HTTP client. For example, in Java, the most prevalent library is HttpClient. Using this library, switching from Digest authentication to Basic authentication is as simple as changing the following code:

    List authPrefs = new ArrayList(1);
    authPrefs.add(AuthPolicy.DIGEST);
    httpclient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);

    to

    List authPrefs = new ArrayList(1);
    authPrefs.add(AuthPolicy.BASIC);
    httpclient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
    

    Or in PHP, using the Curl module you'd need to change the following code:

    curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);

    to

    curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    

      The username and password that you pass stays exactly the same as with Digest Authentication. Specifically, you construct the HTTP username from the concatenation of your API User Key, the "%" character and the Constant Contact customer's UserName.

 

API Authentication with OAuth (SUPPORT RETRACTED!)

Support for OAuth Retracted

The developers of the OAuth specification recently acknowledged a security vulnerability in the OAuth standard. It appears that addressing the concern could require API changes on the part of Constant Contact and on the part of our API adopters. In the interest of preserving the integrity of our customer data and in the interest of minimizing developer rework on the part of our adopters, we have elected to retract support for OAuth in our API. We are investigating and appropriate course of action. In the meantime, all developers are encouraged to adopt our Basic Authentication model, which is documented here.



For more information on the OAuth vulnerability, please see the OAuth Security Advisory posting on the OAuth site, here.


Constant Contact OAuth for Desktop Applications

For each user that wants to authorize your desktop application, the following diagram illustrates the authorization flow:



Step 1: Obtaining an unauthorized request token



Request Token URL:


https://api.constantcontact.com/ws/oauth_get_request_token

Required Parameters

  • oauth_consumer_key: this is your application specific API Key
  • oauth_nonce, oauth_timestamp, oauth_signature_method, oauth_version, oauth_signature: (these parameters are normally handled by an OAuth library, if you are using one, which we highly recommend)


Your users are not involved in this step. First, your application makes request to the Constant Contact Request Token URL for a request token. Note that the oauth_signature you generate for this call will use only your oauth_consumer_key as a key and will be signed with your Consumer Secret, acquired when you obtained your consumer key (API Key). Constant Contact will respond with a unique request token and request token secret.



Constant Contact's response will look something like:


oauth_token=jwxxxxxxjif4&oauth_token_secret=fcyyyyyyyyyy4b5j0qq


Step 2: Obtaining user authorizations



User Authorization URL


https://api.constantcontact.com/ws/oauth_authorize_token

Required Parameters

  • oauth_token: the request token that you obtained in the previous step


After obtaining the request token, your application constructs the authorization URL to call Constant Contact with the request token. The oauth_token parameter is the request token from the response in step 1. The oauth_token_secret from step 1 is used to sign the request prior to sending.

You get the user's browser pointed at the authorization URL where he or she can choose whether to authorize your application or not. If the user authorizes your application, the user will be prompted to close the browser and return to your desktop application.


Step 3: Obtaining user-specific access token



Access Token URL


https://api.constantcontact.com/ws/oauth_get_access_token


Required Parameters

  • oauth_consumer_key : application consumer key
  • oauth_token : the request token passed to your application callback URL by Constant Contact. This should be the same as the request_token you obtained in step one
  • oauth_nonce, oauth_timestamp, oauth_signature_method, oauth_version, oauth_signature (these parameters are normally handled by an OAuth library, if you are using one, which we highly recommend)




After the user authorizes your application, your application needs to exchange the request token for a permanent user-specific access token, or access token for short. Regardless of the application type, the access token uniquely identifies the user to your application and allows your application to update or query Constant Contact for that particular user on their behalf.


To get the access token, the callback URL registered with your application will be called by Constant Contact with the request token after the user authorizes your application. At this point, your application needs to make request to the Constant Contact Access Token URL with the request token. Similar to step 2, the oauth token parameter is the request token token, while the request token's oauth_token_secret from step 1 is used to sign the request prior to sending.


If the user has properly authorized your application, Constant Contact will respond with a unique access token and token secret for the user. Constant Contact will respond with something like:


oauth_token=1qxxxxxxei74&oauth_token_secret=68yyyyyyyyyyv5agufgea3v1z80p16s3



Step 4: Managing and storing the access token


You will receive an access token and token secret for the user which you need to store together securely. The access token ties the user to your application and is your pass to update and query for the the user's information within Constant Contact. You need to figure out how your application associates the access token with your application's representation of the user. The access secret is used to sign your application's query and update requests for the user.


For server-based applications, access tokens and access secrets should be treated as private data on your web server. Protect this data from the public as the corresponding user's Constant Contact information may be inadvertently exposed if the user's access token and access secret are compromised. User-specific access tokens should be considered as the property of your users.

Constant Contact OAuth for Web Application (Two Legged Scenario)

For a Two Legged Authentication Scenario, the application flow is greatly simplified, since, as the application developer, you don't need to approve or deny access to your own data. For a Two Legged Authentication Scenario, the application flow is greatly simplified, since, as the application developer, you don't need to approve or deny access to your own data. There is no need to obtain a Request Token or an Access Token at all, since your Consumer Key and Consumer Secret identify you to our API. To make a request to our API to access your own Constant Contact account, make a request directly to the API and use your Consumer Key and your Consumer Secret as if they were an Access Token and a Token Secret. Pass the Consumer Key in the URL and use the Consumer Secret to sign the request.

Constant Contact OAuth for Web Applications (Three Legged Scenario)

This page describes the typical flow for a web based application requesting access to Constant Contact data held in a specific user's account. For a more detailed code walk through, see this PHP example.




For each user that wants to authorize your app, the following illustrates the authorization flow**.




Step 1: Obtaining an unauthorized request token



Request Token URL:


https://api.constantcontact.com/ws/oauth_get_request_token

Required Parameters

  • oauth_consumer_key: this is your application specific API Key
  • oauth_nonce, oauth_timestamp, oauth_signature_method, oauth_version, oauth_signature: (these parameters are normally handled by an OAuth library, if you are using one, which we highly recommend)


Your users are not involved in this step. First, your application makes a request to Constant Contact Request Token URL for a request token. Note that the oauth_signature you generate for this call will use only your oauth_consumer_key as a key and will be signed with your Consumer Secret, acquired when you obtained your consumer key (API Key). Constant Contact will respond with a unique request token and request token secret.



Constant Contact's response will look something like:



oauth_token=jwxxxxxxxxf4&oauth_token_secret=fcxxxxxxxxxx4b5j0qq


Step 2: Obtaining user authorizations



User Authorization URL


https://api.constantcontact.com/ws/oauth_authorize_token

Required Parameters

  • oauth_token: the request token that you obtained in the previous step

Optional Parameters

  • oauth_callback: a URL to redirect to after a user completes the authorization step


After obtaining the request token, your application constructs the authorization URL to call Constant Contact with the request token. The oauth_token parameter is the request token from the response in step 1. The oauth_token_secret from step 1 is used to sign the request prior to sending.

You get the user's browser pointed at the authorization URL where he or she can choose whether to authorize your application or not. If the user authorizes your application, Constant Contact will invoke your application callback URL, if one was provided, with the request token appended as parameters. If one was not provided, the user will be prompted to close the browser and return to your application.


Step 3: Obtaining user-specific access token



Access Token URL


https://api.constantcontact.com/ws/oauth_get_access_token


Required Parameters

  • oauth_consumer_key : application consumer key
  • oauth_token : the request token passed to your application callback URL by Constant Contact. This should be the same as the request_token you obtained in step one
  • oauth_nonce, oauth_timestamp, oauth_signature_method, oauth_version, oauth_signature (these parameters are normally handled by an OAuth library, if you are using one, which we highly recommend)




After the user authorizes your application, your application needs to exchange the request token for a permanent user-specific access token, or access token for short. Regardless of the application type, the access token uniquely identifies the user to your application and allows your application to update or query Constant Contact for that particular user on their behalf.


To get the access token, the callback URL registered with your application will be called by Constant Contact with the request token after the user authorizes your application. At this point, your application needs to make request to the Constant Contact Access Token URL with the request token. Similar to step 2, the oauth token parameter is the request token token, while the request token's oauth_token_secret from step 1 is used to sign the request prior to sending.


If the user has properly authorized your application, Constant Contact will respond with a unique access token and token secret for the user. Constant Contact will respond with something like:


oauth_token=1qxxxxxxxx74&oauth_token_secret=68xxxxxxxxxxv5agufgea3v1z80p16s3



Step 4: Managing and storing the access token


You will receive an access token and token secret for the user which you need to store together securely. The access token ties the user to your application and is your pass to update and query for the the user's information within Constant Contact. You need to figure out how your application associates the access token with your application's representation of the user. The access secret is used to sign your application's query and update requests for the user.


For server-based applications, access tokens and access secrets should be treated as private data on your web server. Protect this data from the public as the corresponding user's Constant Contact information may be inadvertently exposed if the user's access token and access secret are compromised. User-specific access tokens should be considered as the property of your users.




For a more detailed code walk through, see this PHP example.



Using OAuth From PHP (Sample - 3 Legged)

Overview

This document provides a detailed PHP code walkthrough for accessing Constant Contact’s REST API in PHP using OAuth authentication. It shows how a typical web application obtains an account access token using OAuth and how that token is used in Constant Contact APIs.

For a general overview of OAuth usage in the Constant Contact REST APIs, see this page.

Sample Application

The source for the PHP code discussed in this document is available here. The instructions to use the sample are available in the readme file. To execute the sample application, perform the following steps:

  1. Create a Constant Contact email account if you do not already have one. You can create a free trial account from www.constantcontact.com
  2. Get a consumer key and consumer secret by logging into the developer website at developer.constantcontact.com/apikey/login and providing the required information
  3. Download the Constant Contact PHP sample code. Download the OAuth PHP framework (OAuth.php) from http://oauth.googlecode.com/svn/code/php. Place all the .php files in a folder which is accessible from your web server. We’ll call this the “source folder.”
  4. Point your browser to index.php in the source folder.
  5. Enter the consumer key, user name and secret you got from Steps 1 and 2 into the respective text fields and proceed through the authentication process.

 

Using OAuth with PHP

The remainder of this document describes the detailed steps required to create an application which accesses Constant Contact data through the Constant Contact REST APIs which use OAuth authentication. The following steps are described in detail in the sections that follow.. Step 1 – Setup Environment Step 2 – Get your Consumer Key and Secret Step 3 – Get Request Token Step 4 – Redirect user to Constant Contact to Login/Grant Access Step 5 – Exchange Request Token for an Access Token Step 6 – Step 6 – Access the APIs

Step 1 – Setup Environment

This document assumes that your web server is setup with a PHP environment which is ready to use. If you need to set up PHP and you are running Linux, you can launch the setup with: sudo apt-get install libapache2-mod-php5 If you are running Windows, information on setting up PHP is available at XAMPP. The sample code discussed in this document uses the PHP OAuth framework from http://oauth.googlecode.com/svn/code/php. Download OAuth.php to your source folder and import into your source .php files.

Step 2 – Get your Consumer Key and Secret

Log into the developer website (http://developer.constantcontact.com), API Keys section to either view your existing Consumer Key (aka API Key) and Consumer Secret or request a new key and secret. If you are building more than one application, you should request a Consumer Key and Consumer secret for each application.

Step 3 – Get Request Token

Your program will use the consumer key and consumer secret to get a request token and request secret. These will be stored in the sessions and used in subsequent steps to get an access token and access token secret. Following is typical PHP code to get a request token and request secret.
Step 3. 1 Setup the parameters and URL

       define("URI", "http://api.constantcontact.com");
       $request_token_url  = URI.'/ws/oauth_get_request_token';
       $parsed = parse_url($request_token_url );
       $params = array();

Step 3.2 Sign the request with consumer key and consumer secret

       $req_req = OAuthRequest::from_consumer_and_token($oauth _consumer, NULL, "GET", $request_token_url, $params);
       $oauth_consumer = new OAuthConsumer($consumer_key, $consumer_secret, NULL);
       $sig_method = new OAuthSignatureMethod_HMAC_SHA1();
       $req_req->sign_request($sig_method, $oauth_consumer, NULL);

Step 3.3 Execute request

 
       $request  = $req_req->to_url();
       $session = curl_init($request);
       curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
       // Make the request
       $response = curl_exec($session);

       //Error Handling:
       // there is an error while executing the request, 
       if (!$response) {  
            $response = curl_error($curl);  
        }  
       curl_close($session);

Step 3.4 Store request token and secret

       parse_str($response, $params);
       $oauth_token = $params['oauth_token'];
       $oauth_token_secret = $params['oauth_token_secret'];
       $_SESSION[CONSUMER_KEY] = $consumer_key;
       $_SESSION[CONSUMER_SECRET] = $consumer_secret;
       $_SESSION[REQUEST_TOKEN] = $oauth_token;
       $_SESSION[REQUEST_TOKEN_SECRET] = $oauth_token_secret;

 

Step 4 – Redirect user to Constant Contact to Login/Grant Access

Before the Constant Contact API will provide an access token, the Constant Contact user has to authenticate the request token. This is done by sending the user to a predefined Constant Contact authentication page, which asks the user if they wish to grant access to the application that is making the request (ie. Your application). The following code demonstrates this.

       //initialize $context_root variable with application’s root.
       $callback_url = $context_root . "access_token.php";
       $auth_url = URI.'/ws/oauth_authorize_token?oauth_token='.$oauth_token.'&oauth_callback='.urlencode($callback_url);
       Header("Location: $auth_url");

When a user clicks on the confirm button on the final page of the Constant Contact authentication wizard, the page will be redirected to the callback URL ($context_root . "access_token.php").

Step 5 – Exchange Request Token for an Access Token

Now that we have an authenticated request token and its request token secret, we’ll use these to get an access token using the authorize token URL. This code is very similar to the code above which retrieved the request token. The only significant difference is the URL. After getting the access token and access token secret, these can be stored in the session, as they are used in subsequent steps to get access to the API. This example shows storing tokens and secrets in session variables. In a real application these values would typically be stored in a database to be reused later.
Step 5.1 Setup parameters and URL

       $request_token = $_SESSION[REQUEST_TOKEN];
       $request_token_secret = $_SESSION[REQUEST_TOKEN_SECRET];
       $consumer_key = $_SESSION[CONSUMER_KEY];
       $consumer_secret = $_SESSION[CONSUMER_SECRET];
       $access_url = URI.'/ws/oauth_get_access_token';

Step 5.2 Sign access token

       $sig_method = new OAuthSignatureMethod_HMAC_SHA1();
       $access_consumer = new OAuthConsumer($consumer_key, $consumer_secret, NULL);
       $access _token = new OAuthConsumer($request_token, $request_token_secret);
       $parsed = parse_url($access_url);
       $params = array();
       $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, "GET", $endpoint, $params);
       $acc_req->sign_request($sig_method, $test_consumer, $test_token);

Step 5.3 Execute request

       $request  = $acc_req->to_url();
       $session = curl_init($request);
       curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
       // Make the request
       $response = curl_exec($session);
       //Error Handling:
       // there is an error while executing the request, 
       if (!$response) {  
            $response = curl_error($curl);  
        }  
       curl_close($session);

Step 5.4 Store access token and access token secret

       parse_str($response, $params);
       $access_token = $params['oauth_token'];
       $access_token_secret = $params['oauth_token_secret'];
       $_SESSION[ACCESS_TOKEN] = $access_token;
       $_SESSION[ACCESS_TOKEN_SECRET] = $access_token_secret;

 

Step 6 – Access the APIs

Once the access token and access token secret are available, the APIs can be accessed using the following code.

Step 6.1 Sign API request This code shows how to sign the API request using access token and access token secret, obtained in the steps above.

       $consumer = new OAuthConsumer($_SESSION[CONSUMER_KEY], $_SESSION[CONSUMER_SECRET], NULL);
       $token = new OAuthToken($_SESSION[ACCESS_TOKEN], $_SESSION[ACCESS_TOKEN_SECRET]);
       $parsed = parse_url($webServiceUrl);
       $params = array();
       parse_str($postVars, $params);
       $request = OAuthRequest::from_consumer_and_token($consumer, $token, $method, $webServiceUrl, $params);
       $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, $token);
	

Step 6.2 Execute request This code shows executing the request that is being signed in above step.

       $response = send_request($request->get_normalized_http_method(), 
       	$webServiceUrl, $request, null);
       // Get the XML from the response, bypassing the header
       //Error Handling:
       //if there is an error, response will have error code and 
       //corresponding error message
       if (!($xml = strstr($response, '<?xml'))) {
       	 echo $response;
       	 $xml = null;
       }	

Step 6.3 Render the list from the XML in the response The following code renders a row for each contact list name in the name.

      
       <?php
       if (isset($xml)){
       	$data = simplexml_load_string($xml);
       	foreach ($data->entry AS $item){
       		$shortId = substr($item->id, 
       			strrpos($item->id, "/") + 1)
       ?>
       <input type='checkbox' name='lists[]' 
       	value='<?php echo $item->id ?>'>
       
       <a href='showList.php?listId='>
       <?php echo $item->content->ContactList->Name ?>
       
       <?php
       } ?>

Tips, Tricks and Known Issues Using the WebServices APIs

Getting Started

--1. Get your Developer API key. The Developer API key identifies the person or organization who built the application. It is confidential information and should not be shared with your application end users.
--2. Find out which APIs exist. See this reference.
--3. Construct your access credentials. Your access credentials are constructed from the Developer API Key, the Constant Contact login name for the data you want to access and the Constant Contact password for that Constant Contact user. The API Username is a concatenation of your API User Key, the "%" character and the Constant Contact login name like so: {API Key}%{UserName}
--4. Reference the top level document for your domain. In many cases this may be the service description, which is held here: https://api.constantcontact.com/ws/customers/{UserName}/
where {UserName}/ is the user name of the Constant Contact account holder.
--5. Navigate the response document to get a reference to the next level of details.

Using RESTClient

RESTClient is a great tool to test your XML and the way you are using Constant Contact APIs. It gives you a simple way to test individual calls outside of your program to check if you are calling APIs correctly, and if not, it provides detailed error messages that the server returns. We created a user guide to help you use this helpful tool.

Combining Several Constant Contact APIs

Constant Contact supports several APIs. While the APIs can be combined as needed, the capabilities, usage model and limitations of the APIs vary. For an overview of the available Constant Contact APIs, see this page.

FAQs and API Known Issues

There are a number of things you might want to know about the API, including:

 

Developer Support Forums

The Web Services Forums provide a community where Constant Contact API users can seek, contribute and refine advise and expertise for applying and extending the Constant Contact solution.


You are encouraged to contribute to existing topics - or launch a new topic (thread) of your own.




For a complete list of forums, go here.



Support Forum

The Support forum is where to go when you have a specific issue or concern with the API. Think you've found a defect? Having trouble getting your application running? Submit an issue to the Support forum. (Don't forget to check out our Frequently asked Questions first!)


"Getting Started" Forum

Just Getting Started? Have general questions on the use of any of the Constant Contact APIs? Have an interesting reference, resource or source sample you think other community members might benefit from? Submit your topic to the Getting Started and Samples forum.


"Authentication Issues" Forum

Encountering Access isses (typically, http 401 errors)? Confused about OAuth, Basic and Digest Authentication? Submit your topic to the Authentication Issues forum.


API Enhancement Request Forum

Looking for an API enhancement or a new API capability? Want to see, or comment on, what others are requesting? Check out the API Enhancement Requests forum.


Heritage APIs (SiteVisitor and Others)

As the newest members of our API family, the Constant Contact REST APIs cover only a subset of the Constant Contact capabilities. Adopters can apply the newer REST APIs with any of the existing API functionality.



In addition to the new RestAPIs covered in the API reference section, Constant Contact has four other API families. One of those APIs, the broadly adopted SiteVisitorAPI, is appropriate for any Constant Contact Account Holder. The other three APIs are designed for, and restricted to, Constant Contact Partner organizations.


APIs:

For more information on the existing APIs, and on using the APIs in conjunction with the REST APIs, see the following sections:


API

Description

Audience

Site Visitor API
Add a single contact to an existing Contact List. Modify the attributes of a single contact. Unsubscribe a contact from all all lists.(Note: To upload a group of contacts or modify the attributes of a group of contacts, see the 'Activities' resource described here). All Constant Contact Account Holders.

List Manager API
Enable a partner to manage contact list uploads for the Constant Contact Account Holders which they manage. The API includes the capability to Create a contact list, Upload contacts to an existing list, View contact lists, Get the status of contact upload batch jobs

Constant Contact Partners (for the accounts they manage)

Site Owner API
Enable a partner to provision or update a new Constant Contact Account Holder's ("Site Owner"), manage the Constant Contact Account Holder's account information, and login for the Account Holder via an API.

Constant Contact Partners (for the Constant Contact Account Holders they manage)
Partner API Enable a partner to provision and manage sub-partners. Access to the Partner API is restricted to specific Constant Contact Business Partners who have been provided the privileges to establish and manage sub-partners. To request access to the Partner API, please contact the webservices team.

Constant Contact Partners (for the sub-Partner accounts they manage)

Other Resources:

Please check out the Constant Contact ConnectUp! Community for customer related discussions around Constant Contact usage and in particular, take a look at the ConnectUP! API thread.

Site Visitor API

Overview


THE SITE VISITOR APIs, while still functional, ARE BEING DEPRECATED. Support for the Site Visitor APIs will be withdrawn by the end of 2009. The functionality of the SITE VISITOR APIs has been subsumed by the REST APIs available on this site. The REST APIs provide more functionality than the Site Visitor API, and are the preferred platform for future development.

The Site Visitor API was designed to help Constant Contact Customers create a tailored contact list registration process for their contact. The API consists of two verbs. The first verb (API_AddSiteVisitor) adds or updates a single contact to an existing Constant Contact Account. The second verb (API_UnsubscribeSiteVisitor) permanently removes a contact from an existing Constant Contact customer account.

This API is expressly limited in two ways:
- The API is not to be used for bulk operations (See the 'Activities' resource described here for bulk operations of any size).
- The API is designed to be used with the direct permission of the contact. A call to API_AddSiteVisitor should be based on an explicit opt-in from the contact. Contacts who are added via the API_AddSiteVisitor API do not receive a "Welcome email".

Support and Questions on the SiteVisitor API

Documentation for the SiteVisitor API is no longer distributed.

See the SiteVisitor API Frequently Asked Questions for a handy set of FAQs which capture the experiences of hundreds of our customers' API implementations.

If you have questions, comments or improvements on these examples, please use the discussion forums as that is the sole support mechanism for these code snippets.



Site Visitor API Frequently Asked Questions (FAQs)

Q: I already have a form on my website where I collect contact information. Can I use the Site Visitor API to send contact information from that form directly to my Constant Contact account?

A: Yes. This is the primary purpose of the Site Visitor API.



Q: I want two different signup forms on my website, one that will add contacts directly to list A and one that will add contacts directly to list B. Can I do this?

A: Yes. The Site Visitor API will enable you to have as many forms on your website as you would like and have each of them submit the contact to a specific list or lists. You will control which list(s) the contact gets added to through the server-side script that handles the form data and makes the call to the API.



Q: What skills are needed to implement the Site Visitor API?

A: Thorough understanding of web programming and server-side script development is necessary in order to successfully implement the Site Visitor API.



Q: I do not have access to web programming resources. Can Constant Contact help?

A: Constant Contact has identified business partners that have web programming expertise and who can complete the integration for an additional fee. We can provide you the contact information of these business partners if you are interested.



Q: Can I implement the Site Visitor API through an HTML web page?

A: While it is possible to implement the API within your client-side HTML page, we do not recommend you do this because the login name and password information you pass through the API will be visible. Furthermore, the “success” page is merely a blank screen with a zero in the upper left corner, so the customer experience will be poor.



Q: What programming languages can be used to integrate the Site Visitor API?

A: The API can be called using either a GET or POST method. Therefore, you can use the programming language that you are most familiar with.



Q: Within my server-side script I have constructed the URL call to the API correctly but my contact is not being properly subscribed, unsubscribed or updated. What’s going on?

A: There are a few common reasons why this could be happening:
--- One or more of the required parameters (login name, login password, email address, list name) are missing or incorrect.
--- The parameter names or values are not defined in the correct case. For example if the list you are adding the contact to is named “Customers” defining this name as “customers” in the API call will not work. You need to match uppercase and lowercase characters exactly.
--- You have made too many calls to the API with an incorrect password and now the account has been locked for too many failed logins. Contact Customer Support to have the account reset.
--- The list does not exist. The list that you are adding the contact to must already exist within the Constant Contact account.



Q: Can I use the Site Visitor APIs to find out what list(s) a contact is on?

A: No. At this time the Site Visitors APIs enable you to subscribe and unsubscribe a contact to / from your Constant Contact account. It is a one way communication channel from your web site to your Constant Contact account and the functionality does not support querying your account for information. HOWEVER...you can now use the REST APIs, documented on this web site, to determine what list a contact is on. You can also update the list association of that contact. Please see the Contacts Collection Resource for more information.



Q: Can I use the Site Visitor APIs for synchronizing my database with Constant Contact or adding / removing hundreds or thousands of email addresses at a time.

A: No. The Site Visitor APIs are meant to be used for subscribing or unsubscribing one contact at a time based on signup activity on your website. WHILE the SiteVisitor APIs are meant for managing individual contacts and *MAY NOT* be used for managing large sets of contacts - there is another solution. You can now use the REST APIs, documented on this web site, for bulk uploads and downloads of contacts. Please see the Activities Resource for more information.



Q: Will a welcome email be sent from Constant Contact when I add a contact with the SiteVisitor APIs?

A: Not with the SiteVisitor APIs. HOWEVER...you can now use the REST APIs, documented on this web site, to add individual contacts. With the REST APIs, the developer can indicate if the contact was 'added by the contact themself' (with, for example, a form on a public website) or 'added by the Constant Contact Customer' (with, for example, a desktop form used by the Constant Contact customer). Contacts who are 'added by the contact themself' receive a welcome email. Please see the Contacts Collection Resource for more information.



Q: Will a thank you page be shown when I add a contact?

A: No. If you would like the contact to see a thank you page after you have added them to your Constant Contact account, you will need to program this on your end and host that page on your own web servers. A developer has posted a simple sample script, in PHP, in this thread in the Constant Contact ConnectUp! community.



Q: I am receiving a 400 error when I make a call to the API, what does that mean?

A: The 400 code is not specific to the Constant Contact Subscriber API, rather it is an indication that the API call could not be understood by the server due most likely due to incorrect syntax. Make sure you are including the requirement parameters and that the values you are passing are the correct case. Refer to the API documentation here.



Q: Does the daily or weekly Site Visitor Signup Report include contacts that are added through the API?

A: Yes.



Q: If I use the Site Visitor API to handle unsubscribes from my website, can the Unsubscribe link in the footer of my emails be directed back to my website?

A: No. The unsubscribe link in the footer of your emails must point back directly to your Constant Contact account. This ensures that unsubscribe requests are being handled properly.



Q: I am having problems getting my Flash application to run and I think it is related to cross-site scripting limitations. Will Constant Contact add my cross domain file on their server to allow my application access?

A: While we can't manage individual cross domain files, we can suggest another approach that should work. Create a small proxy script on your server which acts as a proxy for the Flash file and invoke the Constant Contact APIs from that proxy. Here is PHP example (put this PHP file where the Flash file is served on your webserver):



Notes:
This proxy can be written in php, asp or jsp here. See more information here: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16520&sliceId=2.

In this example, we named the PHP file proxy.php.

Now you can write the flex code to access the php or some other proxy that you have written and placed in your webserver.
Following is the flex code you can use to read the php file above (which inturn invokes the CTCT api url):

                var httpService:HTTPService = new HTTPService();
                var url:String = "proxy.php?ea="+emailText.text;
                httpService.url = url;
                httpService.showBusyCursor=true;
                httpService.send();




You will find more on creating a signup form with Flash here.



Q: I am receiving a 400 error when I make a call to the API, what does that mean?

A: The 400 code is not specific to the Constant Contact Subscriber API, rather it is an indication that the API call could not be understood by the server due most likely due to incorrect syntax. One common reason for a 400 error (in the SiteVisitorAPI) is invalid login credentials. As a first step, make sure you can login to http://www.constantcontact.com with the login credentials which you are using in the API. If this does not solve the problem, make sure you are including the requirement parameters and that the values you are passing are the correct case. Refer to the API documentation here.



Q:
I am trying to use the API from a client side HTML form. The API works up to a point. I can add an email address to the list with no problem. But the page then displays a zero return code. This is not want I need. The user will see the 0 and wonder what
happened. I need the API to return to my site (or to another URL I specify) or it has not value to me.

A:
What you are seeing is the return code from the HTTP call you are making. This is of course not intended to be displayed to the user, but rather, to be captured by your program and treated appropriately (ie. If there is an error, you will receive a non-zero return code and you present a message to the user).

To do this, your program will need to trap the error and continue.

Once you have invoked the http: and managed the error, your program can redirect the user accordingly. There are simple examples of this (in PHP and ColdFusion) posted on our developer web site, here:

http://developer.constantcontact.com/doc/siteVisitorAPI


It addition, Constant Contact Community members have posted examples in the ConnectUp! community here:

http://community.constantcontact.com/forum/default.aspx?g=posts&t=2509





ListManager API

The ListManager API is a limited availability API which was designed to support bulk upload of contacts.

The ListManager API has been fully subsumed by the REST API effort. If you are already using this API, you may continue to do so for the time being.

We encourage all ListManager API users to consider the expanded functionality and improved access control provided in the newer Constant Contact REST APIs covered here .



Partner / Site Owner Management APIs

Site Owner API


Overview

The SiteOwner API is designed to help partners automate the process of creating and managing Constant Contact Accounts.
The SiteOwner API allows a partner to:

  • Provision a site owner
  • Update a site owner
  • Retrieve a site owner’s Constant Contact site owner ID.
  • Deactivate a site owner
  • Reactivate a site owner
  • Autologin the site owner - Allow a site owner to log on to Constant Contact from the hosting provider’s application or Web site
  • Obtain all of a site owner’s tags (Constant Contact sign-up prompts) for automatic inclusion on the site owner’s Web site
  • Obtain a single site owner’s tag for automatic inclusion on the site owner’s Web site
  • Retrieve specific information about a Site Owner



Access to the SiteOwner API is a restricted access API provided to some Constant Contact Business Partners depending on the specific needs of the partner and the appropriateness of the API for those needs. The SiteOwner API operations can be applied only to accounts which are within the Business Partner's privilege hierarchy (generally, this means accounts which signed up through the Business Partner).


Accessing the SiteOwner API

If your integration needs include provisioning and managing Constant Contact accounts for your customers, please send a request, including your contact information, to the web services team.


Partner API


Overview

The SiteOwner API is designed to Enable a partner to provision and manage sub-partners. Access to the Partner API is applicable only to specific Constant Contact Business Partners who have been provided the privileges to establish and manage sub-partners. To request access to the Partner API, please contact the webservices team. Please include your business partner name and contact details.