I am trying to upload file to my Salesforce Instance using REST API documented here: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm

Following the instructions when inserting a document with Blob Data, I can successfully upload file under 5MB. However, when I tried to insert a document that is greater than 5MB using the same mechanism, I am getting an error as below:

{“message”:“document cannot exceed 5MB”,“errorCode”:“MAXIMUM_SIZE_OF_DOCUMENT”,“fields”:[]}]] TransferResult(transferResultCode=400, transferResultMsg=‘Bad Request’
--> [{“message”:“document cannot exceed 5MB”,“errorCode”:“MAXIMUM_SIZE_OF_DOCUMENT”,“fields”:[]}], transferDuration=2052, transferSize=7024463, resultFile=null, pdfOriginalSize=7089156, pdfOptimizedSize=7024036, pdfOptimizationDuration=2498)

I did not anticipate there would be a 5MB limit on file size when creating a document via REST API in the salesforce. And did not find any documentation stating this limitation.

Does any one running into similar issue with create document using multipart REST API? Here is a json object I send as the first part of the REST API

"Description" : "Marketing brochure for Q1 2011",
"Keywords" : "marketing,sales,update",
"FolderId" : "005D0000001GiU7", // I used a userId here
"Name" : "Marketing Brochure Q1",
"Type" : "pdf"}

1 Answer 1


The classic Document object has a 5MB limit (up to 25MB if you contact Technical Support). Use a ContentVersion instead to support files up to 2GB in size.

  • Thank you for the prompt reply, we tried inserting a contentVersion without "ContentDocumentId" and we can pass the 5MB limit. { "ContentDocumentId" : empty, "ReasonForChange" : "Marketing materials updated", "PathOnClient" : "Q1 Sales Brochure.pdf" } Commented Jun 13 at 17:28
  • @JessicaSun What is the URL you are using, though? It should be /services/data/v60.0/sobjects/ContentVersion.
    – sfdcfox
    Commented Jun 13 at 17:30
  • yes we used the content version endpoint Commented Jun 13 at 17:31
  • One more question: what is the difference between using Doc object to create vs using ContentVersion to create and upload files. other than the size limit?? if there is not difference why would salesforce provide the Document upload endpoint. Commented Jun 13 at 17:32
  • @JessicaSun Document is an older technology, not part of Salesforce Files. The ContentDocument acts as a "header" for the file, while the ContentVersion stores versions of that ContentDocument. You should use ContentVersion to store new files. Documents to not appear in Lightning Experience, only Classic.
    – sfdcfox
    Commented Jun 13 at 17:35

You must log in to answer this question.

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