Create and Manage Email Templates in Marketing Cloud Next
Use the CMS Contents endpoints in Connect API to create and manage email templates in your marketing content workspace.
Retrieve the ID of the workspace to create the email template in. See Manage Content Workspaces.
To create an email template using raw HTML content, issue a POST request to the /services/data/{apiVersion}/connect/cms/contents endpoint.
This table lists the properties in the request body.
| Property | Data Type | Description |
|---|---|---|
contentSpaceOrFolderId | string | Required. The ID of the workspace to create the email template in. |
contentType | string | Required. The type of content. To create an email template, specify sfdc_cms__emailTemplate. |
contentBody.sfdc_cms:title | string | Required. An identifying name for the email template. |
contentBody.subjectLine | string | Required. The default subject line for the email template. |
contentBody.preheader | string | Preview text that’s shown after the subject line in some email clients. |
contentBody.messagePurpose | string | The purpose of the email. Possible values are promotional or transactional. |
contentBody.rawHtml | string | Required. The HTML content of the email template. |
This sample request shows how to create a basic HTML email template.
If the request is successful, the response includes metadata about the email template.
The email template is created in Draft status. To make it available for use in messages, copy the value of the managedContentId property, and then publish the email template.
To create an email template that uses components, issue a POST request to the /services/data/{apiVersion}/connect/cms/contents endpoint with an sfdc_cms:block structure.
This table lists the properties in the request body.
| Property | Data Type | Description |
|---|---|---|
contentSpaceOrFolderId | string | Required. The ID of the workspace to create the email template in. |
contentType | string | Required. The type of content. To create an email template, specify sfdc_cms__emailTemplate. |
contentBody.sfdc_cms:title | string | Required. An identifying name for the email template. |
contentBody.subjectLine | string | Required. The default subject line for the email template. |
contentBody.sfdc_cms:block | object | The structure of the component block. Each content node in the block requires a unique ID, such as a UUID. |
To retrieve details of an email template, issue a GET request to the /services/data/{apiVersion}/connect/cms/contents/{contentKey} endpoint. Replace {contentKey} with the unique ID or the API name of the email template.
If the request is successful, the response includes the email template details.
To update an email template, use the retrieve endpoint to find the managedContentVariantId of the email template. Next, issue a PUT request to the /services/data/{apiVersion}/connect/cms/contents/variants/{variantId} endpoint.
You can’t switch between raw HTML email templates and component-based email templates during an update.
This sample request shows how to update the content of an email template.
Include the full contentBody in PUT requests. If you omit properties from the request body, they’re deleted from the email template.
The email template remains in its current status (Draft or Published) after the update. To change the status, use the publish or unpublish endpoints.
To create a copy of an existing email template, issue a POST request to the /services/data/{apiVersion}/connect/cms/contents/{contentKey}/clone endpoint. Replace {contentKey} with the unique ID or API name of the email template to clone.
The cloned email template is created in Draft status and includes all content body fields and structure from the original. To differentiate the clone from the original, update the cloned email template’s title.
To delete an email template, issue a DELETE request to the /services/data/{apiVersion}/connect/cms/contents/variants/{variantId} endpoint. Replace {variantId} with the managedContentVariantId of the email template.
Deleting an email is permanent and can’t be undone.
This sample request shows how to delete an email by providing its variant ID.
A successful deletion returns a 204 No Content status with no response body.
To publish a draft email template and make it available for use in messages, see Publish Content Items.