After creating a public link of a File using ContentDistribution, you get the below URL


How to query the Content Id of a File? I can see the URL already contains the Version Id this means the Content Id is something diffrent.

  • By the way, just in case, this feels like it might be a X-Y Problem. You may want to ask your "X" question directly.
    – sfdcfox
    Jul 28, 2021 at 5:01
  • Sure will correct it Jul 28, 2021 at 5:29

2 Answers 2


The Content Id in the URL is a ContentBody, which states:

Cannot be queried, inserted, updated, or deleted directly.


ContentBody is intended for internal Salesforce use. If you need to access the file content body, please use ContentVersion.

In other words, you're not meant to use this Id. If you need to generate a public link, create a ContentDistribution record. Note that even if you could query ContentBody, it wouldn't be valid without a valid ContentDistribution.

  • Thanks for the response, it lead me in to the correct direction. Jul 28, 2021 at 5:31

If someone else lands here the Content Id in the URL is ContentBodyId which is present inside the ContentVersion.

ContentBodyId Description: Allows inserting a file version independently of the file blob being uploaded. This field is available for query and insert only. It can only point to a ContentBody record. This field is available in API version 40.0 and later. This is a relationship field.

Ref: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentversion.htm?search_text=Content%20Body

You must log in to answer this question.

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