Create (Post) a new email campaign in your email collection.

To create a new email campaign in your email collection, make a POST call to the /emails endpoint. Use the request body parameter to specify a unique name for the email campaign and all required email_campaign_activities properties. If you enter a name that already exists for a email campaign in your account, a 409 Response Code is returned.

When you create an email campaign, you can choose to specify optional email_campaign_activities properties, and physical_address_in_footer and document_properties subresource properties.

The system automatically generates the following metadata for the new email campaign:

  • campaign_id

    The ID (in UUID format) that uniquely identifies the email campaign.

  • current_status

    The current status of the email campaign (set to DRAFT when first created).

  • created_at

    The date and time that the email campaign is created.

  • updated_at

    The date and time that the email campaign either created or was last updated.

  • campaign_activities

    Identifies the role (purpose) of each campaign activity within the email campaign, and the campaign_activity_id that is used to uniquely identify each campaign activity.

    • primary_email: The primary marketing campaign email to use and send to contacts.
    • permalink: The system-generated permanent link to a web accessible version of the email campaign content. The content does not include any personalized email information, such as contact email addresses.

Example:

 {
     "type": "CUSTOM_CODE_EMAIL",
     "name": "Newsletter for Dog Lovers",
     "campaign_id": "71a9c14e-2b9a-4e1d-9097-1390326e0fb2",
     "current_status": "DRAFT",
     "updated_at": "2019-03-05T21:22:14.000Z",
     "created_at": "2019-03-05T21:22:14.000Z",
     "campaign_activities": [
         {
             "role": "primary_email",
             "campaign_activity_id": "70b83958-6418-42a2-ac33-80b4134a06d7"
         },
         {
             "role": "permalink",
             "campaign_activity_id": "4ead62fc-a0fe-4a34-af69-81d667e1ca2a"
         }
     ]
 }

After you create an email campaign, make a PUT call to the /emails/activities/{campaign_activity_id} endpoint to update the email campaign activity with the contacts that you want Constant Contact to send the campaign activity to. You currently cannot add contacts when you use the POST /emails endpoint to create the campaign. For more information on updating an email campaign activity, see Update an Email Campaign Activity.

After creating the new email campaign, you can always use the GET /emails/{campaign_id} to go back to view information about the email campaign and to get a list of associated campaign activities, including the unique campaign_activity_id and role for each activity. To view details about a specific campaign activity, use GET /emails/activities/{campaign_activity_id}.

Authorization Requirements

User privileges: campaign:write

Authorization scopes: campaign_data

Parameters and Properties

In the body parameter, specify the EmailCampaignActivityInput properties to include in your email campaign.

Required properties

name

A unique and descriptive name to identify the email campaign. The maximum length for this string is 80.

Example: name: December Newsletter for Dog Lovers

email_campaign_activities

Used to create and format the email content and information to include in the email campaign.

  • format_type

    Identifies the email format type that this email campaign activity uses. When creating a new email campaign, you must enter 1 (Custom Code Email).

  • from_name

    The sender’s name to display for the email campaign activity. The maximum length of this string is 100.

    Example: Jake Dodge

  • from_email

    The sender’s email address to use for the email campaign activity. You must use a confirmed account email address. Make a GET call to /account/emails to return a collection of account emails and their status. For more information, see the Get a Collection of Account Emails topic. The maximum length of this string is 80.

    Example: jdodge@constantcontact.com

  • reply_to_email

    The sender’s email address to use if the contact replies to the email campaign activity. You must use a confirmed account email address. Make a GET call to /account/emails to return a collection of account emails and their status. For more information, see the Get a Collection of Account Emails topic. The maximum length of this string is 80. Example: jdodge@constantcontact.com

  • subject

    The text to display in the subject line that describes the email campaign activity. The maximum length of this string is 200.

    Example: Informed Daily Digest

  • html_content

    Used to display the HTML or XHTML content for the email campaign activity. Only format_type 1 (custom code emails) can contain html_content. For XHTML formatted emails, you can add special Constant Contact tags to change the default layout of email elements and to include Constant Contact specific information in the email. For details, see the Advanced Editor User Guide. The maximum length of this string is 150,000.

    Example: <html><body><a href="http://www.constantcontact.com">Visit ConstantContact.com!</a> </body></html>

Optional Subresources and Properties

When creating the new campaign, you have the option to include physical_address_in_footer anddocument_properties subresource properties.

The sending organization’s physical address that Constant Contact displays to contacts in the email footer. By default, the physical address that already exists for your account is used (as defined in My Settings). If no physical address exists for your account, you must specify the address using this property. To return this property, you must include physical_address_in_footer in the include query parameter.

  • address_line1

    Line one of the organization’s street address (required).

    Example: 123 Maple Street

  • address_line2

    Line two of the organization’s street address.

    Example: Unit 1

  • address_line3

    Line three of the organization’s street address.

    Example: string

  • address_optional

    Optional address field.

    Example:Near Boston Fire Station

  • city

    The city where the organization is physically located (required).

    Example: Boston

  • country_code

    The two letter country code (upper case) that represents the country where the organization is located (read-only). For details, see ISO 3166-1 code.

    Example: US

  • country_name

    The full name of the country where the organization is located that is automatically populated based on the country_code that you enter in the request body (read-only).

    Example: United States.

  • organization_name

    The full name of the organization.

    Example: My Organization

  • postal_code

    The address Postal Code (ZIP) representing the location of the organization.

    Example: 02451

  • state_code

    The two letter State Code (upper case) representing the State where the organization is located. For details, see ISO 3166-1 code.

    Example: MA

  • state_name

    The State name where the organization is located and it is automatically populated based on the state_code that you enter in the request body (read-only). `

  • state_non_us_name

    The state name to use for a non-US country code.

    Example: Victoria

document_properties

Use the document_properties object properties to include email campaign content, such as messages, links, forwarding information, and to define how the content displays or is used.

  • style_content

    Contains style sheet elements for XHTML formatted emails. The maximum length for this string is 150,000.

    Example: .white{color: #ffffff;}

  • text_content

    Contains the text to display to contacts if their email client cannot display an HTML email. If you do not specify a value for text_content, Constant Contact displays a default greetings message, such as Greetings. The maximum length for this string is 150,000.

    Example: <Text><Greetings/></Text>

  • permission_reminder_enable

    If true, the contacts permission_reminder message displays at the top of the email. If false, the message does not display. The default value is false.

  • permission_reminder

    The message text that displays at the top of the email message to remind users that they are subscribed to an email list. The maximum length for this string is 1,500.

    Example: Hi, just a reminder that you are receiving this email because you have expressed an interest in our company

  • view_as_webpage_enabled

    If true, the view_as_webpage_text email message displays. If false, the message does not display. The default value is false.

    Example: false

  • view_as_webpage_text

    If view_as_webpage_enabled is true, used to display the web page text at the top of the email and above the view_as_webpage_link_name. The maximum length is 50.

    Example: Having trouble viewing this email?

  • view_as_webpage_link_name

    The link text to display that users can click to view the email as a web page. Required if view_as_webpage_enabled is true. The maximum length is 50.

    Example, Click here to view this email as a web page

  • greeting_salutation

    The greeting used in the email message. The maximum length is 50.

    Example: Hi,

  • greeting_name_type

    The email campaign naming convention used to greet contacts. Valid values are F (First Name), L (Last Name), B (First and Last Name), or N (No greeting name). The default value is N.

    Example: F

  • greeting_secondary

    The text string used to greet the contact when the greeting_name_type is not available or is set to N. The maximum length is 1500.

    Example: Greetings!

  • forward_email_link_enabled

    If true, when the user forwards an email message the footer includes a link for subscribing to the list. If false and forwarded, the footer does not include the link. By default, the value is false.

  • forward_email_link_name

    The text to display as the link name in the footer when forward_email_link_enabled is true. The maximum length is 80.

    For example: Forward email

  • subscribe_link_enabled

    If set to true, the email footer includes a link to allow users to subscribe to the list. If set to false, the message footer does not display the link. The default value is false.

  • subscribe_link_name

    The text to display in the email footer for the subscribe link, if the subscribe_link_enabled is true. The maximum length is 80.

    Example: Subscribe to my email list!

  • letter_format

    The HTML or XHTML format used for the email message. Valid values are HTML and XHTML. For XHTML format, you can add special Constant Contact tags to change the default layout of the email content and to include Constant Contact specific information in the email. For details, see the Advanced Editor User Guide. By default, the value is HTML.

Example POST Request

The example POST requests include optional document_properties and physical_address_in_footer object properties.

POST https://api.cc.email/v3/emails

<?php

$request = new HttpRequest();
$request->setUrl('https://api.cc.email/v3/emails');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Postman-Token' => 'b992f2da-7eb8-4194-8ede-97032b6092bb',
  'cache-control' => 'no-cache',
  'Authorization' => 'Bearer {access_token}',
  'Content-Type' => 'application/json',
  'Accept' => '*/*'
));

$request->setBody('{
  "name": "April Newsletter for Dog Lovers",
  "email_campaign_activities": [
    {
      "format_type": "1",
      "from_name": "Your best doggie friend",
      "from_email": "webservices_summer@mailinator.com",
      "reply_to_email": "webservices_summer@mailinator.com",
      "subject": "Doggie Lovers!!!",
      "html_content": "<html><body> <a href=\\"http://www.constantcontact.com\\">Visit ConstantContact.com!</a> </body></html>",
      "physical_address_in_footer": {
        "address_line1": "123 Maple Street",
        "address_line2": "Unit 1",
        "address_line3": "string",
        "address_optional": "Near Boston Fire Station",
        "city": "Boston",
        "country_code": "US",
        "country_name": "United States",
        "organization_name": "My Organization",
        "postal_code": "02451",
        "state_code": "MA",
        "state_name": "string",
        "state_non_us_name": "Victoria"
      },
      "document_properties": {
        "style_content": ".white{color: #ffffff;}",
        "text_content": "<Text><Greetings/></Text>",
        "permission_reminder_enabled": "true",
        "permission_reminder": "Hi, just a reminder that you're receiving this email because you have expressed an interest in our company.",
        "view_as_webpage_enabled": "false",
        "view_as_webpage_text": "Having trouble viewing this email?",
        "view_as_webpage_link_name": "Click here to view this email as a web page",
        "greeting_salutation": "Hi,",
        "greeting_name_type": "F",
        "greeting_secondary": "Greetings!",
        "forward_email_link_enabled": "true",
        "forward_email_link_name": "Forward email",
        "subscribe_link_enabled": "false",
        "subscribe_link_name": "Subscribe to my email list!",
        "letter_format": "XHTML"
      }
    }
  ]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
curl -X POST \
  https://api.cc.email/v3/emails \
  -H 'Accept: */*' \
  -H 'Authorization: Bearer {access_token}' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 0763edff-4c73-4422-b55b-e3e56cd384a4' \
  -H 'cache-control: no-cache' \
  -d '{
  "name": "April Newsletter for Dog Lovers",
  "email_campaign_activities": [
    {
      "format_type": "1",
      "from_name": "Your best doggie friend",
      "from_email": "webservices_summer@mailinator.com",
      "reply_to_email": "webservices_summer@mailinator.com",
      "subject": "Doggie Lovers!!!",
      "html_content": "<html><body> <a href=\"http://www.constantcontact.com\">Visit ConstantContact.com!</a> </body></html>",
      "physical_address_in_footer": {
        "address_line1": "123 Maple Street",
        "address_line2": "Unit 1",
        "address_line3": "string",
        "address_optional": "Near Boston Fire Station",
        "city": "Boston",
        "country_code": "US",
        "country_name": "United States",
        "organization_name": "My Organization",
        "postal_code": "02451",
        "state_code": "MA",
        "state_name": "string",
        "state_non_us_name": "Victoria"
      },
      "document_properties": {
        "style_content": ".white{color: #ffffff;}",
        "text_content": "<Text><Greetings/></Text>",
        "permission_reminder_enabled": "true",
        "permission_reminder": "Hi, just a reminder that you'\''re receiving this email because you have expressed an interest in our company.",
        "view_as_webpage_enabled": "false",
        "view_as_webpage_text": "Having trouble viewing this email?",
        "view_as_webpage_link_name": "Click here to view this email as a web page",
        "greeting_salutation": "Hi,",
        "greeting_name_type": "F",
        "greeting_secondary": "Greetings!",
        "forward_email_link_enabled": "true",
        "forward_email_link_name": "Forward email",
        "subscribe_link_enabled": "false",
        "subscribe_link_name": "Subscribe to my email list!",
        "letter_format": "XHTML"
      }
    }
  ]
}'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"name\": \"April Newsletter for Dog Lovers\",\n  \"email_campaign_activities\": [\n    {\n      \"format_type\": \"1\",\n      \"from_name\": \"Your best doggie friend\",\n      \"from_email\": \"webservices_summer@mailinator.com\",\n      \"reply_to_email\": \"webservices_summer@mailinator.com\",\n      \"subject\": \"Doggie Lovers!!!\",\n      \"html_content\": \"<html><body> <a href=\\\"http://www.constantcontact.com\\\">Visit ConstantContact.com!</a> </body></html>\",\n         \"physical_address_in_footer\": {\n        \"address_line1\": \"123 Maple Street\",\n        \"address_line2\": \"Unit 1\",\n        \"address_line3\": \"string\",\n        \"address_optional\": \"Near Boston Fire Station\",\n        \"city\": \"Boston\",\n        \"country_code\": \"US\",\n        \"country_name\": \"United States\",\n        \"organization_name\": \"My Organization\",\n        \"postal_code\": \"02451\",\n        \"state_code\": \"MA\",\n        \"state_name\": \"string\",\n        \"state_non_us_name\": \"Victoria\"\n      },\n      \"document_properties\": {\n        \"style_content\": \".white{color: #ffffff;}\",\n        \"text_content\": \"<Text><Greetings/></Text>\",\n        \"permission_reminder_enabled\": \"true\",\n        \"permission_reminder\": \"Hi, just a reminder that you're receiving this email because you have expressed an interest in our company.\",\n        \"view_as_webpage_enabled\": \"false\",\n        \"view_as_webpage_text\": \"Having trouble viewing this email?\",\n        \"view_as_webpage_link_name\": \"Click here to view this email as a web page\",\n        \"greeting_salutation\": \"Hi,\",\n        \"greeting_name_type\": \"F\",\n        \"greeting_secondary\": \"Greetings!\",\n        \"forward_email_link_enabled\": \"true\",\n        \"forward_email_link_name\": \"Forward email\",\n        \"subscribe_link_enabled\": \"false\",\n        \"subscribe_link_name\": \"Subscribe to my email list!\",\n        \"letter_format\": \"XHTML\"\n      }\n    }\n  ]\n}");
Request request = new Request.Builder()
  .url("https://api.cc.email/v3/emails")
  .post(body)
  .addHeader("Accept", "*/*")
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer {access_token}")
  .addHeader("cache-control", "no-cache")
  .addHeader("Postman-Token", "4f765fa2-049a-453a-9279-9d86f5d1df2f")
  .build();

Response response = client.newCall(request).execute();

Example Response

{
    "campaign_activities": [
        {
            "campaign_activity_id": "62805103-5d7f-4dee-abce-4d45236c11a9",
            "role": "permalink"
        },
        {
            "campaign_activity_id": "8747e3a2-28ed-43e1-9617-0dd52c677cde",
            "role": "primary_email"
        }
    ],
    "campaign_id": "d8e2a306-e489-4288-8558-349ebf36642b",
    "created_at": "2019-01-23T15:03:54.000Z",
    "current_status": "DRAFT",
    "name": "April Newsletter for Dogs",
    "type": "CUSTOM_CODE_EMAIL",
    "updated_at": "2019-01-23T15:05:47.000Z"    
}

Try it!