I need to load files into Salesforce via an API as part of some integration work. I want to be loading files as Salesforce Files (not attachments) so we can version files if need be and I also need to make sure that the resulting uploaded file is available to Community licensed users who have access to the record. There seem to be two API options:

  1. Using the Chatter API where you upload a file to Files home for a user through a request to /connect/files/users/userid (example on this page) and then relate it to a record by doing a request to /chatter/feed-elements as described here.
  2. Uploading as a ContentDocument via the REST API, although the example shown in API describe that in the context of Salesforce Content, which is not something we are interested in using.

Is the best option one of the above or something else altogether? Are there any limits that I should be aware of? I think that either option would be fine for files 50MB or potentially a bit more, which would be enough for us. In terms upload numbers, we're probably going to be around a few thousand at most per day.

  • Salesforce Content is older name for Salesforce Files
    – cropredy
    Feb 1, 2021 at 20:05

1 Answer 1


If you're using Files, you are using Salesforce Content. In fact, when you add a Chatter File, the platform is generating a ContentDocument/ContentVersion/ContentDocumentLink just as if you were using those objects directly - in addition to the Chatter post(s).

The model sounds complicated, but it can be relatively simple to use the REST API to insert a File.

When you insert a ContentVersion record with a null ContentDocumentId field, it will create the ContentDocument for you.

If you populate the FirstPublishLocationId field with the Id of the record you want to relate the File to when you insert the ContentVersion, the platform will also create the ContentDocumentLink record for you. One call to insert and relate a File!


If the file is larger than 37.5 MB, you'll need to send the file data in a multi-part message. In this manner, you can upload a file up to the 2GB max for Files.

Some more detail on this can be found here:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .