In Salesforce, files are managed through the ContentDocument and ContentVersion objects. A ContentDocument represents the file entity, while each revision of that file is stored as a separate ContentVersion record. When you need to upload a new version of an existing file using the Salesforce REST API, SOAP API, or Bulk API, you insert a new ContentVersion record linked to the existing ContentDocument. This is different from uploading a file for the first time, which requires a FirstPublishLocationId.
When inserting a new version of an existing document via the API, include the following four required fields:
ContentDocumentId — The Salesforce record ID of the existing ContentDocument that this version belongs to.ReasonForChange — A text description explaining why this new version is being uploaded (for example: "Updated contract pricing terms for Q2").PathOnClient — The filename or full file path on the client machine (for example: /documents/contract_v2.pdf). This value is used to determine the file extension and display name.VersionData — The base64-encoded binary content of the file being uploaded.The FirstPublishLocationId field can only be set when inserting the very first version of a new document. Do not include this field when inserting a subsequent version of an existing ContentDocument — doing so will cause an error.
000385651

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.