Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Upload Files

Upload documents and images or update the file with a new version.

Salesforce stores files uploaded to a record or group as a ContentDocument. Each file has a ContentVersion record that corresponds to a specific version of the file. Additionally, ContentDocumentLink holds the polymorphic relationships between a file and where it's shared, such as a users, groups, and records. For information about working with files, see ContentDocument in Object Reference for Salesforce and Lightning Platform.

User Interface API provides two ways to upload a file in a request.

To prevent duplication of file uploads, such as in situations where the network connection is unstable, use Idempotency Record Writes.

Note

Upload a New File

This request uploads an image with the .csv file extension. It creates a new ContentDocument, ContentVersion, and ContentDocumentLink in one request. After the file is uploaded, you can view it in Files home.

Example POST Request
1POST /ui-api/records/content-documents/content-versions
1{
2  "description": "My test file",
3  "title": "CSV File"
4}
Example CURL Request
1curl -H "X-PrettyPrint: 1"
2-F 'json={"title":"CSV File", "description":"My test file"};type=application/json'
3-F 'fileData=@aa.csv;type=application/octet-stream'
4-X POST https://{instance-name}.salesforce.com/services/data/v57.0/ui-api/records/content-documents/content-versions
5-H 'Authorization: Bearer your_access_token_here'
Example Response
1{
2  "contentDocument" : {
3    "apiName" : "ContentDocument",
4    "childRelationships" : { },
5    "eTag" : "32e236323d9e6feea5412bb694a9b33d",
6    "fields" : {
7      "CreatedDate" : {
8        "displayValue" : "11/2/2022, 11:13 AM",
9        "value" : "2022-11-02T18:13:53.000Z"
10      },
11      "Description" : {
12        "displayValue" : null,
13        "value" : "My test file"
14      },
15      "Id" : {
16        "displayValue" : null,
17        "value" : "069RM0000008MbJYAU"
18      },
19      "LastModifiedById" : {
20        "displayValue" : null,
21        "value" : "005RM000002dpIzYAI"
22      },
23      "LastModifiedDate" : {
24        "displayValue" : "11/2/2022, 11:13 AM",
25        "value" : "2022-11-02T18:13:53.000Z"
26      },
27      "SystemModstamp" : {
28        "displayValue" : null,
29        "value" : "2022-11-02T18:13:54.000Z"
30      },
31      "Title" : {
32        "displayValue" : null,
33        "value" : "CSV File"
34      }
35    },
36    "id" : "069RM0000008MbJYAU",
37    "lastModifiedById" : "005RM000002dpIzYAI",
38    "lastModifiedDate" : "2022-11-02T18:13:53.000Z",
39    "recordTypeId" : null,
40    "recordTypeInfo" : null,
41    "systemModstamp" : "2022-11-02T18:13:54.000Z",
42    "weakEtag" : 1667412834000
43  },
44  "contentDocumentLinks" : [ {
45    "apiName" : "ContentDocumentLink",
46    "childRelationships" : { },
47    "eTag" : "a9e9ca5f7e2eb85af2aef5ed122350c2",
48    "fields" : {
49      "ContentDocumentId" : {
50        "displayValue" : null,
51        "value" : "069RM0000008MbJYAU"
52      },
53      "Id" : {
54        "displayValue" : null,
55        "value" : "06ARM00000095a72AA"
56      },
57      "LinkedEntityId" : {
58        "displayValue" : null,
59        "value" : "005RM000002dpIzYAI"
60      },
61      "ShareType" : {
62        "displayValue" : "Inferred",
63        "value" : "I"
64      },
65      "SystemModstamp" : {
66        "displayValue" : null,
67        "value" : "2022-11-02T18:13:54.000Z"
68      }
69    },
70    "id" : "06ARM00000095a72AA",
71    "lastModifiedById" : null,
72    "lastModifiedDate" : null,
73    "recordTypeId" : null,
74    "recordTypeInfo" : null,
75    "systemModstamp" : "2022-11-02T18:13:54.000Z",
76    "weakEtag" : 1667412834000
77  } ],
78  "contentVersion" : {
79    "apiName" : "ContentVersion",
80    "childRelationships" : { },
81    "eTag" : "0cbf5c6af463dbda0d0741eeda132d7a",
82    "fields" : {
83      "ContentSize" : {
84        "displayValue" : null,
85        "value" : "26224"
86      },
87      "CreatedDate" : {
88        "displayValue" : "11/2/2022, 11:13 AM",
89        "value" : "2022-11-02T18:13:53.000Z"
90      },
91      "Description" : {
92        "displayValue" : null,
93        "value" : "My test file"
94      },
95      "Id" : {
96        "displayValue" : null,
97        "value" : "068RM0000008SBhYAM"
98      },
99      "LastModifiedById" : {
100        "displayValue" : null,
101        "value" : "005RM000002dpIzYAI"
102      },
103      "LastModifiedDate" : {
104        "displayValue" : "11/2/2022, 11:13 AM",
105        "value" : "2022-11-02T18:13:53.000Z"
106      },
107      "SystemModstamp" : {
108        "displayValue" : null,
109        "value" : "2022-11-02T18:13:54.000Z"
110      },
111      "Title" : {
112        "displayValue" : null,
113        "value" : "CSV File"
114      },
115      "VersionDataUrl" : {
116        "displayValue" : null,
117        "value" : "https://{instance-name}.documentforce.com/sfc/servlet.shepherd/version/download/068RM0000008SBh"
118      }
119    },
120    "id" : "068RM0000008SBhYAM",
121    "lastModifiedById" : "005RM000002dpIzYAI",
122    "lastModifiedDate" : "2022-11-02T18:13:53.000Z",
123    "recordTypeId" : "012000000000000AAA",
124    "recordTypeInfo" : null,
125    "systemModstamp" : "2022-11-02T18:13:54.000Z",
126    "weakEtag" : 1667412834000
127  }

Upload a File Version

This request uploads a new version of an image file with a new file name. It creates a new ContentVersion, and updates the existing objects to reference the new ContentVersion.

Example POST Request
1POST /ui-api/records/content-documents/069RM0000008MbEYAU/content-versions
1{
2  "title": "Updated product image"
3}
Example CURL Request
1curl -H "X-PrettyPrint: 1" 
2-F 'json={"title":"Updated product image"};type=application/json' 
3-F 'fileData=@Test.PNG;type=application/octet-stream' 
4-X POST 'https://{instance-name}.salesforce.com/services/data/v57.0/ui-api/records/content-documents/069RM0000008MbEYAU/content-versions' 
5-H 'Authorization: Bearer your_access_token_here'
Example Response
1{
2  "contentDocument" : {
3    "apiName" : "ContentDocument",
4    "childRelationships" : { },
5    "eTag" : "8a5ed89e115ff7f99e4d00e6ec07c0f3",
6    "fields" : {
7      "CreatedDate" : {
8        "displayValue" : "11/2/2022, 10:19 AM",
9        "value" : "2022-11-02T17:19:28.000Z"
10      },
11      "Description" : {
12        "displayValue" : null,
13        "value" : null
14      },
15      "Id" : {
16        "displayValue" : null,
17        "value" : "069RM0000008MbEYAU"
18      },
19      "LastModifiedById" : {
20        "displayValue" : null,
21        "value" : "005RM000002dpIzYAI"
22      },
23      "LastModifiedDate" : {
24        "displayValue" : "11/2/2022, 10:53 AM",
25        "value" : "2022-11-02T17:53:59.000Z"
26      },
27      "SystemModstamp" : {
28        "displayValue" : null,
29        "value" : "2022-11-02T17:54:00.000Z"
30      },
31      "Title" : {
32        "displayValue" : null,
33        "value" : "Updated product image"
34      }
35    },
36    "id" : "069RM0000008MbEYAU",
37    "lastModifiedById" : "005RM000002dpIzYAI",
38    "lastModifiedDate" : "2022-11-02T17:53:59.000Z",
39    "recordTypeId" : null,
40    "recordTypeInfo" : null,
41    "systemModstamp" : "2022-11-02T17:54:00.000Z",
42    "weakEtag" : 1667411640000
43  },
44  "contentDocumentLinks" : [ {
45    "apiName" : "ContentDocumentLink",
46    "childRelationships" : { },
47    "eTag" : "0e32a473e9bd0bb69eb23fb1c0d8115c",
48    "fields" : {
49      "ContentDocumentId" : {
50        "displayValue" : null,
51        "value" : "069RM0000008MbEYAU"
52      },
53      "Id" : {
54        "displayValue" : null,
55        "value" : "06ARM00000095a32AA"
56      },
57      "LinkedEntityId" : {
58        "displayValue" : null,
59        "value" : "001RM000005XNLIYA4"
60      },
61      "ShareType" : {
62        "displayValue" : "Inferred",
63        "value" : "I"
64      },
65      "SystemModstamp" : {
66        "displayValue" : null,
67        "value" : "2022-11-02T17:19:31.000Z"
68      }
69    },
70    "id" : "06ARM00000095a32AA",
71    "lastModifiedById" : null,
72    "lastModifiedDate" : null,
73    "recordTypeId" : null,
74    "recordTypeInfo" : null,
75    "systemModstamp" : "2022-11-02T17:19:31.000Z",
76    "weakEtag" : 1667409571000
77  }, {
78    "apiName" : "ContentDocumentLink",
79    "childRelationships" : { },
80    "eTag" : "ccfa6db5bfad0c23d0aa613b69fbaec5",
81    "fields" : {
82      "ContentDocumentId" : {
83        "displayValue" : null,
84        "value" : "069RM0000008MbEYAU"
85      },
86      "Id" : {
87        "displayValue" : null,
88        "value" : "06ARM00000095a22AA"
89      },
90      "LinkedEntityId" : {
91        "displayValue" : null,
92        "value" : "005RM000002dpIzYAI"
93      },
94      "ShareType" : {
95        "displayValue" : "Inferred",
96        "value" : "I"
97      },
98      "SystemModstamp" : {
99        "displayValue" : null,
100        "value" : "2022-11-02T17:19:32.000Z"
101      }
102    },
103    "id" : "06ARM00000095a22AA",
104    "lastModifiedById" : null,
105    "lastModifiedDate" : null,
106    "recordTypeId" : null,
107    "recordTypeInfo" : null,
108    "systemModstamp" : "2022-11-02T17:19:32.000Z",
109    "weakEtag" : 1667409572000
110  } ],
111  "contentVersion" : {
112    "apiName" : "ContentVersion",
113    "childRelationships" : { },
114    "eTag" : "7b64a64ff99e3141f6fdbf7a5278d424",
115    "fields" : {
116      "ContentSize" : {
117        "displayValue" : null,
118        "value" : "324337"
119      },
120      "CreatedDate" : {
121        "displayValue" : "11/2/2022, 10:53 AM",
122        "value" : "2022-11-02T17:53:59.000Z"
123      },
124      "Description" : {
125        "displayValue" : null,
126        "value" : null
127      },
128      "Id" : {
129        "displayValue" : null,
130        "value" : "068RM000000228mYAA"
131      },
132      "LastModifiedById" : {
133        "displayValue" : null,
134        "value" : "005RM000002dpIzYAI"
135      },
136      "LastModifiedDate" : {
137        "displayValue" : "11/2/2022, 10:53 AM",
138        "value" : "2022-11-02T17:53:59.000Z"
139      },
140      "SystemModstamp" : {
141        "displayValue" : null,
142        "value" : "2022-11-02T17:54:01.000Z"
143      },
144      "Title" : {
145        "displayValue" : null,
146        "value" : "Updated product image"
147      },
148      "VersionDataUrl" : {
149        "displayValue" : null,
150        "value" : "https://{instance-name}.documentforce.com/sfc/servlet.shepherd/version/download/068RM000000228m"
151      }
152    },
153    "id" : "068RM000000228mYAA",
154    "lastModifiedById" : "005RM000002dpIzYAI",
155    "lastModifiedDate" : "2022-11-02T17:53:59.000Z",
156    "recordTypeId" : "012000000000000AAA",
157    "recordTypeInfo" : null,
158    "systemModstamp" : "2022-11-02T17:54:01.000Z",
159    "weakEtag" : 1667411641000
160  }
161}