Get Started
Configure your Org
Manage Content Workspaces
Search for Content
Create and Manage Emails
Create and Manage Email Templates
Publish Content Items
Integrate Form Submissions
Security
Use the CMS Contents endpoints in Connect API to create and manage email content in your marketing content workspace.
Retrieve the ID of the workspace to create the email in. See Manage Content Workspaces.
To create an email using raw HTML content, issue a POST request to the /services/data/{apiVersion}/connect/cms/contents endpoint.
After you create a raw HTML email, you can’t change it to use a component-based structure.
Note
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 in. |
contentType | string | Required. The type of content. To create an email, specify sfdc_cms__email. |
contentBody.sfdc_cms:title | string | Required. An identifying name for the email. |
contentBody.subjectLine | string | Required. The email subject line. |
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. |
This sample request shows how to create a basic HTML email.
1POST /services/data/{apiVersion}/connect/cms/contents HTTP/1.1
2Host: {subdomain}.my.salesforce.com
3Content-Type: application/json
4Authorization: Bearer YOUR_BEARER_TOKEN
5
6{
7 "contentSpaceOrFolderId": "0ZuQZ0000004YSv0AM",
8 "contentType": "sfdc_cms__email",
9 "contentBody": {
10 "messagePurpose": "promotional",
11 "preheader": "Updates, resources, and more — take a look at what's ready.",
12 "rawHtml": "<h1>Welcome Back</h1><p>We have updates, resources, and new content ready for you. Explore what's new and make the most of everything available to you.</p><a href='https://example.com/welcome'>Get Started</a>",
13 "sfdc_cms:title": "Sample HTML Email",
14 "subjectLine": "What’s New for You"
15 }
16}If the request is successful, the response includes metadata about the email.
1{
2 "contentKey": "MCNUSLTYAES5CLRKYWXFUXDXW2BM",
3 "contentSpace": {
4 "id": "0ZuQZ0000004YSv0AM",
5 "resourceUrl": "/services/data/v67.0/connect/cms/spaces/0ZuQZ0000004YSv0AM"
6 },
7 "contentType": {
8 "fullyQualifiedName": "sfdc_cms__email"
9 },
10 "isPublished": false,
11 "managedContentId": "20YQZ0000007G3F2AU",
12 "managedContentVariantId": "9PsQZ00000072oH0AQ",
13 "status": {
14 "label": "Draft",
15 "status": "Draft"
16 },
17 "title": "Sample HTML Email",
18 "versionNumber": "1.0"
19}The email 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.
To create an email 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 in. |
contentType | string | Required. The type of content. To create an email, specify sfdc_cms__email. |
contentBody.sfdc_cms:title | string | Required. An identifying name for the email. |
contentBody.subjectLine | string | Required. The email subject line. |
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. |
1POST /services/data/{apiVersion}/connect/cms/contents HTTP/1.1
2Host: {subdomain}.my.salesforce.com
3Content-Type: application/json
4Authorization: Bearer YOUR_BEARER_TOKEN
5
6{
7 "contentSpaceOrFolderId": "0ZuQZ0000004YSv0AM",
8 "contentType": "sfdc_cms__email",
9 "contentBody": {
10 "sfdc_cms:title": "Sample Component Email",
11 "subjectLine": "Welcome to Our Newsletter",
12 "preheader": "Check out what’s new",
13 "messagePurpose": "promotional",
14 "sfdc_cms:block": {
15 "id": "GENERATE_UUID",
16 "type": "sfdc_cms:documentBlock",
17 "contentNodes": [
18 {
19 "id": "GENERATE_UUID",
20 "type": "sfdc_cms:documentBlock",
21 "contentNodes": [
22 {
23 "id": "GENERATE_UUID",
24 "type": "sfdc_cms:paragraphBlock",
25 "contentNodes": [
26 {
27 "id": "GENERATE_UUID",
28 "type": "sfdc_cms:textBlock",
29 "text": "Welcome to our newsletter!"
30 }
31 ]
32 }
33 ]
34 }
35 ]
36 }
37 }
38}To retrieve details of an email, 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.
1GET /services/data/{apiVersion}/connect/cms/contents/MCNUSLTYAES5CLRKYWXFUXDXW2BM HTTP/1.1
2Host: {subdomain}.my.salesforce.com
3Authorization: Bearer YOUR_BEARER_TOKENIf the request is successful, the response includes the email details.
1{
2 "contentKey": "MCNUSLTYAES5CLRKYWXFUXDXW2BM",
3 "managedContentId": "20YQZ0000007G3F2AU",
4 "managedContentVariantId": "9PsQZ00000072oH0AQ",
5 "title": "Sample HTML Email",
6 "status": {
7 "status": "Draft"
8 },
9 "contentType": {
10 "fullyQualifiedName": "sfdc_cms__email"
11 },
12 "contentBody": {
13 "sfdc_cms:title": "Sample HTML Email",
14 "subjectLine": "What’s New for You",
15 "preheader": "Updates, resources, and more — take a look at what’s ready.",
16 "rawHtml": "<h1>Welcome Back</h1><p>We have updates, resources, and new content ready for you. Explore what’s new and make the most of everything available to you.</p><a href='https://ex.com/welcome'>Get Started</a>",
17 },
18 "contentSpace": {
19 "id": "0ZuQZ0000004YSv0AM"
20 }
21}To update an email, use the retrieve endpoint to find the managedContentVariantId of the email. Next, issue a PUT request to the /services/data/{apiVersion}/connect/cms/contents/variants/{variantId} endpoint.
1PUT /services/data/{apiVersion}/connect/cms/contents/variants/9PsQZ00000072oH0AQ HTTP/1.1
2Host: {subdomain}.my.salesforce.com
3Content-Type: application/json
4Authorization: Bearer YOUR_BEARER_TOKEN
5
6{
7 "contentBody": {
8 "messagePurpose": "promotional",
9 "preheader": "Updated preview text",
10 "rawHtml": "<h1>Updated Content</h1><p>New content here</p>",
11 "sfdc_cms:title": "Updated Email Title",
12 "subjectLine": "Updated Subject"
13 }
14}Provide the full contentBody. Fields that aren’t included in the request are cleared. You can’t switch between HTML and component structures during an update.
Important
The email remains in its current status (Draft or Published). To change the status, use the publish or unpublish endpoints.
To create a copy of an email, use the retrieve endpoint to find the contentKey of the email. Next, issue a POST request to the /services/data/{apiVersion}/connect/cms/contents/{contentKey}/clone endpoint.
1POST /services/data/{apiVersion}/connect/cms/contents/MCNUSLTYAES5CLRKYWXFUXDXW2BM/clone HTTP/1.1
2Host: {subdomain}.my.salesforce.com
3Authorization: Bearer YOUR_BEARER_TOKENThe cloned email is created in Draft status and includes the same content body fields and structure as the original version.
To delete an email permanently, use the retrieve endpoint to find the managedContentVariantId of the email. Next, issue a DELETE request to the /services/data/{apiVersion}/connect/cms/contents/variants/{variantId} endpoint.
Deleting an email is permanent and can’t be undone.
Important
This sample request shows how to delete an email by providing its variant ID.
1DELETE /services/data/{apiVersion}/connect/cms/contents/variants/9PsQZ00000072oH0AQ HTTP/1.1
2Host: {subdomain}.my.salesforce.com
3Authorization: Bearer YOUR_BEARER_TOKENA successful deletion returns a 204 No Content response with no response body.
Before you can use an email in messages, you must publish it.