To add an image to your Marketing Cloud Next content workspace, upload a file from your computer, reuse a file from your content workspace, or specify an image URL. You can include images in emails, landing pages, forms, and content blocks.
Add an image to your content workspace by using one of these methods.
Upload an image file from your computer.
Create an image from a file in your content workspace.
Reference an image hosted at an external URL.
For all three methods, issue a POST request to the /services/data/{apiVersion}/connect/cms/contents endpoint. In the request body, include the properties in this table.
Property
Data Type
Description
contentBody.altText
string
Alternative text that describes the image.
contentBody.sfdc_cms:media.source.ref
string
Required only when you use a file that exists in your content workspace. The CMS file ID of the file. Omit this property when you upload a file.
contentBody.sfdc_cms:media.source.type
string
Required. The source of the image. Use file for an uploaded file or a file in your content workspace. Use url for an externally hosted image.
contentBody.sfdc_cms:media.source.url
string
Required only when you reference an external URL. The public URL of the image.
contentBody.thumbnail
object
The thumbnail image.
contentSpaceOrFolderId
string
Required. The ID of the workspace or folder to add the image to.
contentType
string
Required. The type of the content item. For images, use sfdc_cms__image.
title
string
Required. A name that identifies the image in your content workspace. Specify the title at the top level of the request body, not inside contentBody.
The contentBody object accepts only altText, thumbnail, and sfdc_cms:media. If you include any other property, such as sfdc_cms:title or sfdc_cms:description, the API returns an HTTP 400 response.
Important
The API determines the correct size and mimeType properties for the image, so don’t include them in your request.
You can add an GIF, JPG, JPEG, PNG, SVG, or WEBP file up to 25 MB.
Add an Image by Uploading a File
To upload an image file, issue a multipart/form-data POST request. The request includes two parts:
A JSON part named ManagedContentInputParam with the content type application/json. This part contains the image metadata.
A binary part named contentData. Set its content type to match the type of image, such as image/jpeg. This part contains the image file data.
In the ManagedContentInputParam part, set contentBody.sfdc_cms:media.source.type to file. Don’t include ref, size, or mimeType.
Name the file part contentData. If you use a different name, the API returns an HTTP 400 response with the error POST_BODY_PARSE_ERROR.
Note
The API returns 201 Created, and the response body includes metadata about the image. The response contains the uploaded file’s CMS file ID in contentBody.sfdc_cms:media.source.ref and a CMS delivery path in contentBody.sfdc_cms:media.url.
To create an image from a file in your content workspace, issue a POST request with the content type application/json. Set contentBody.sfdc_cms:media.source.type to file, and set contentBody.sfdc_cms:media.source.ref to the ref value from the response of an earlier upload.
The ref property accepts only a CMS file ID. If you specify a content document or content version ID, the API returns an HTTP 400 response with the error INVALID_FIELD and the message “This image reference isn’t available.”
Note
Add an Image by Specifying an External URL
To reference an image hosted at an external URL, issue a POST request with the content type application/json. Set contentBody.sfdc_cms:media.source.type to url, and set contentBody.sfdc_cms:media.source.url to the public URL of the image.
New images start as drafts. To make an image available to use in messages, publish it by using the managedContentId value from the response. For more information, see Publish Content Items.