Make a PUT call to the /emails/activities/{campaign_activity_id}
endpoint to update an email campaign activity. This includes updating the contact_list_ids
array to specify which contacts Constant Contact should send the email campaign activity to. You must add contacts to an email campaign activity in order to schedule it.
Email Campaign Activity Object Structure
The email campaign activity object contains the email header content, the email body content, the contacts lists or segments associated with the email, and the email metadata. The email headers are in the from_name
, from_email
, reply_to_email
, and subject
properties. The contacts that Constant Contact sends the email campaign activity to are in the contact_list_ids
array or the segment_ids
array. The html_content
property contains the email body content for format_type
5 emails (custom code emails). The other format_type
emails do not contain html_content
.
The email campaign activity object also contains a physical_address_in_footer
object and a document_properties
object. The physical_address_in_footer
object contains the address information for the organization sending the email campaign. Constant Contact displays this address information to contacts in the email footer. The document_properties
object contains optional properties that are specific to each email format_type
and control the behavior of the email. For more information on document_properties
, see the reference documentation for GET a Single Email Campaign Activity.
Update an Email Campaign Activity
Update an email campaign activity by making a PUT call to the /emails/activities/{campaign_activity_id}
endpoint. Include the complete email campaign activity with your updates in the request body.
You can only update email campaign activities that have the primary_email
role. You can update email campaign activities when they are in DRAFT
status for each email campaign activity format_type
. You can also update email campaign activities when they are in DONE
status if the email campaign activity uses format_type
3, 4, or 5.
Specify which contacts Constant Contact should send the email campaign activity to using either the segment_ids
or contact_list_ids
array.
Use the segment_ids
array to specify a single segment_id
to use to dynamically get contacts that meet that segment’s criteria. Use the contact_list_ids
array to specify the unique contact list_id
string values used to get contacts. You can use the GET /contact_lists collection endpoint to return a paginated list of all available contact lists.
You can only use segments with email campaign activities that use format_type
that is 3
, 4
, or 5
.
You must add contacts to an email campaign activity using either the contact_list_ids
array or the segment_ids
array in order to schedule it.
Authorization Requirements
User privileges: campaign:write
Authorization scopes: campaign_data
Request Parameters
This method requires the campaign_activity_id
URL parameter. Use the campaign_activity_id
parameter to specify which email campaign activity you want to update.
This method requires a request body that contains the from_name
, from_email
, reply_to_email
and subject
properties.
When you use a PUT method to update a resource, the V3 API overwrites any properties that are missing in the request body. However, this method does not overwrite subresources that you omit in the request body or missing properties in subresources. This method considers physical_address_in_footer
, document_properties
, html_content
, and permalink_url
subresources.
Example PUT Email Campaign Activity Call
This example PUT call updates an email campaign activity that uses format_type
5. This example PUT call also adds two contact lists to the email campaign activity.
PUT https://api.cc.email/v3/emails/activities/{campaign_activity_id}
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cc.email/v3/emails/activities/a4a22b4d-0e81-452a-a835-fea9339384dd');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders(array(
'Postman-Token' => 'a65b757e-6a1b-441d-b8ab-992c12d85e19',
'cache-control' => 'no-cache',
'Authorization' => 'Bearer {access token}',
'Content-Type' => 'application/json'
));
$request->setBody('{
"campaign_activity_id": "a4a22b4d-0e81-452a-a835-fea9339384dd",
"campaign_id": "4705ddd9-6af8-4fea-a32f-3834fd239364",
"role": "primary_email",
"contact_list_ids": [ "fa32f620-6d82-11e8-8b59-fa163e56c9b0", "f4ab800a-5adf-11e9-ba6a-fa163e6b01c1" ],
"segment_ids": [],
"current_status": "DRAFT",
"format_type": 5,
"from_email": "jdodge@example.com",
"from_name": "Jake Dodge",
"reply_to_email": "jdodge@example.com",
"subject": "Our Holiday Specials",
"html_content": "<html><body>[[trackingImage]] <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": "Jake Dodge's Pet Supplies",
"postal_code": "02451",
"state_code": "MA",
"state_name": "Massachusetts"
}
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"campaign_activity_id\": \"a4a22b4d-0e81-452a-a835-fea9339384dd\",\n \"campaign_id\": \"4705ddd9-6af8-4fea-a32f-3834fd239364\",\n \"role\": \"primary_email\",\n \"contact_list_ids\": [\"da10f460-3072-11e9-b282-fa163e6b01c1\",\"04fe9a-a579-43c5-bb1a-58ed29bf0a6a\"],\n \"segment_ids\": [],\n \"current_status\": \"DRAFT\",\n \"format_type\": 5,\n \"from_email\": \"jdodge@example.com\",\n \"from_name\": \"Jake Dodge\",\n \"reply_to_email\": \"jdodge@example.com\",\n \"subject\": \"Our Holiday Specials\",\n \"html_content\": \"<html><body>[[trackingImage]] <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\": \"Jake Dodge's Pet Supplies\",\n \"postal_code\": \"02451\",\n \"state_code\": \"MA\",\n \"state_name\": \"Massachusetts\"\n }\n}");
Request request = new Request.Builder()
.url("https://api.cc.email/v3/emails/activities/a4a22b4d-0e81-452a-a835-fea9339384dd")
.put(body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {access token}")
.build();
Response response = client.newCall(request).execute();
curl -X PUT \
https://api.cc.email/v3/emails/activities/a4a22b4d-0e81-452a-a835-fea9339384dd \
-H 'Authorization: Bearer {access token}' \
-H 'Content-Type: application/json' \
-d '{
"campaign_activity_id": "a4a22b4d-0e81-452a-a835-fea9339384dd",
"campaign_id": "4705ddd9-6af8-4fea-a32f-3834fd239364",
"role": "primary_email",
"contact_list_ids": ["da10f460-3072-11e9-b282-fa163e6b01c1","04fe9a-a579-43c5-bb1a-58ed29bf0a6a"],
"segment_ids": [],
"current_status": "DRAFT",
"format_type": 5,
"from_email": "jdodge@example.com",
"from_name": "Jake Dodge",
"reply_to_email": "jdodge@example.com",
"subject": "Our Holiday Specials",
"html_content": "<html><body>[[trackingImage]] <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": "Jake Dodge'\''s Pet Supplies",
"postal_code": "02451",
"state_code": "MA",
"state_name": "Massachusetts"
}
}'
Response
{
"campaign_activity_id": "a4a22b4d-0e81-452a-a835-fea9339384dd",
"campaign_id": "4705ddd9-6af8-4fea-a32f-3834fd239364",
"role": "primary_email",
"contact_list_ids": [
"f4ab800a-5adf-11e9-ba6a-fa163e6b01c1",
"fa32f620-6d82-11e8-8b59-fa163e56c9b0"
],
"segment_ids": [],
"current_status": "DRAFT",
"format_type": 5,
"from_email": "jdodge@example.com",
"from_name": "Jake Dodge",
"reply_to_email": "jdodge@example.com",
"subject": "Our Holiday Specials",
"html_content": "<html><body>[[trackingImage]] <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": "Jake Dodge's Pet Supplies",
"postal_code": "02451",
"state_code": "MA",
"state_name": "Massachusetts"
}
}