uploadContent

Upload a file to your Marketing Cloud Next content workspace.

POST https://{subdomain}.my.salesforce.com/services/data/v63.0/connect/cms/contents

Request 

HTTP Request Example
1POST /services/data/v63.0/connect/cms/contents HTTP/1.1
2Host: {subdomain}.my.salesforce.com
3Authorization: Bearer YOUR_BEARER_TOKEN
4Content-Type: multipart/form-data; boundary=----Boundary7MA4YWxkTrZu0gW
5
6------Boundary7MA4YWxkTrZu0gW
7Content-Disposition: form-data; name="ManagedContentInputParam"
8Content-Type: application/json; charset=UTF-8
9
10{
11  "contentSpaceOrFolderId":"0Zu1Q0000000ZzZSAU",
12  "title":"HeaderImage",
13  "contentType":"sfdc_cms__image",
14  "contentBody": {
15    "sfdc_cms:media": {
16      "source": {
17        "type": "file"
18      }
19    }
20  }
21}
22
23------Boundary7MA4YWxkTrZu0gW
24Content-Disposition: form-data; name="fileData"; filename="1eeb7017-dcc1-40c0-8f12-979853600e79"
25Content-Type: application/octet-stream
26
27FILE_DATA
28
29------Boundary7MA4YWxkTrZu0gW--

URI Parameters 

subdomain (string)

Required. The unique API subdomain for your Salesforce org.

Headers 

Authorization (string)

Required. A unique, time-limited token that you can use to issue requests to Connect API. Replace YOUR_ACCESS_TOKEN with your authentication token.

1Bearer YOUR_ACCESS_TOKEN

Request Body 

These property descriptions apply to the JSON part of the request body. A complete multi-part upload request contains a JSON part and a file part. For a complete example, see Request.

contentSpaceOrFolderId (string)

Required. The ID of the folder to add the file to.

title (string)

Required. A display name for the file.

contentType (string)

Required. The type of content you're uploading. Possible values:

  • sfdc_cms__image—An image file.
  • sfdc_cms__email—A marketing email.
urlName (string)

The name to use in the URL of the file. If you don't specify a value, the URL name is the content title in lowercase letters, with spaces replaced with hyphens.

contentBody.sfdc_cms:media.source.type (string)

An object that contains metadata for the file. Set the value to file.

Responses 

201 Created

This response indicates that the API accepted your request to start a content ingestion job.

1{
2  "contentBody":{
3    "sfdc_cms:media":{
4      "source":{
5        "type":"file",
6        "ref":"0sN1Q000000gLyG",
7        "size":6859,
8        "mimeType":"image/png"
9      },
10      "url":"/cms/media/MCWLJRM7HKRFCKFEUFECYZZZJYAU?version=1.1"
11    }
12  },
13  "contentKey":"MCWLJRM7HKRFCKFEUFECYZZZJYAU",
14  "contentSpace":{
15    "id":"0Zu1Q0000000ZzZSAU",
16    "resourceUrl":"/services/data/v63.0/connect/cms/spaces/0Zu1Q0000000ZzZSAU"
17  },
18  "contentType":{
19    "fullyQualifiedName":"sfdc_cms__image"
20  },
21  "createdBy":{
22    "id":"0051Q00000bxxY5QAI",
23    "name":"D'Angelo Cunningham",
24    "resourceUrl":"/services/data/v63.0/chatter/users/0051Q00000bxxY5QAI"
25  },
26  "createdDate":"2024-01-19T20:43:18.000Z",
27  "externalId":null,
28  "folder":{
29    "id":"9Pu1Q0000000XYZSA2",
30    "resourceUrl":"/services/data/v63.0/connect/cms/folders/9Pu1Q0000000XYZSA2"
31  },
32  "isPublished":false,
33  "language":"en_US",
34  "lastModifiedBy":{
35    "id":"0051Q00000bxxY5QAI",
36    "name":"D'Angelo Cunningham",
37    "resourceUrl":"/services/data/v63.0/chatter/users/0051Q00000bxxY5QAI"
38  },
39  "lastModifiedDate":"2024-01-19T20:43:18.000Z",
40  "managedContentId":"20Y1Q0000009IXnUAM",
41  "managedContentVariantId":"9Ps1Q000000xyiBSAQ",
42  "managedContentVersionId":"5OU1Q000000y2zYWAS",
43  "status":{
44    "label":"Draft",
45    "status":"Draft"
46  },
47  "title":"HeroBanner",
48  "urlName":"herobanner",
49  "versionNumber":"1.1"
50}
400 Bad Request

This response indicates that your request contained errors that prevented the file from being uploaded. When you receive a 400 response, examine the request syntax for issues. For example, this response can be returned if you specify an invalid value for contentSpaceOrFolderId or contentType in the JSON part of the request body.

1[
2  {
3    "errorCode": "INVALID_API_INPUT",
4    "message": "The body of your request is invalid. Check your input and try again."
5  }
6]
401 Unauthorized

This response indicates that the API wasn’t able to authorize your request. When you receive a 401 response, verify that your authorization token is still valid.

1[
2  {
3    "message":"Session expired or invalid",
4    "errorCode":"INVALID_SESSION_ID"
5  }
6]