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