I'm doing sync with Salesforce. In my case I should sync both Case and CaseFeed items. When my CaseFeed items changed I get the notification from Salesforce and create/update the CaseFeed item in external system(if exist). I also want to link the attachments of that CaseFeed item. So I need to get the related attachments of updated item using REST API for example.

I know that attachments will be linked to Case even if added in Case Feed item directly. And all attachments saved in Attachments table. So to get the related Attachments of the Case Feed I just need to know the Attachments ids, right? But I have no idea how to get it from Case Feed item. I am investigating the CaseFeed and FeedAttachments objects but no luck.

Can somebody help me with it?

Also is it possible to get a external links to attachments? Is it supported in Salesforce? For example can I get the links to the attachments in my CaseFeed/Case to use it in external system for download?

UPD Here is the Connect API endpoint that allows me to get the whole Case Feed Item. And looks like the file Ids there is what I'm looking for. But the response object is quite big. What if I need only the Attachments ids? Can I get it somehow using Rest API?

Also looks like the links to the attachments in response can be used for uploading.

1 Answer 1


It is easy once you understand the Data Model.

  1. You have the CaseFeedItem already in your system. Use this to Query for the Feedattachment. This can be done through the REST API

    /services/data/v51.0/query/?q=SELECT Id, RecordId, Type FROM FeedAttachment WHERE FeedEntityId = 'some_feedItem_id'

  2. Once you have the FeedAttachment use the RecordId and Type to figure which objects to query for.

Example if your Type is For inline images, RecordId is a ContentDocument ID. For content attachments, RecordId is a ContentVersion ID

  1. Once you have contentversionId make sure to use below REST API


The Data might be in base64encoded format and you will need a custom script to change to the required format.

  • Thanks a lot!. Does it mean that the RecordId of the FeedAttachment table is the "Attachment Id". So can I store just these Recordids and then when the Attachments of the Case will be synced I can link them? I see that to get the Atachments of the Case I should query the ContendDocumetLink table, right? Commented Feb 4, 2021 at 8:54
  • You should query contentDocument and ContentVersion tables finally! Commented Feb 4, 2021 at 12:38
  • Ok, I got it. is it the same way if I want to upload them in Case using API? I believe the Attachment endpoint is for obsolete Attahcments not for the new Files Commented Feb 4, 2021 at 12:48
  • Oh ok! Ya for case, use the ContentVersionID and CaseID and create a ContentDocumentLink record Commented Feb 4, 2021 at 12:50
  • ok will do :) Also what I tried is to get the ContentDocumentLink by Case Id(I know it in CaseFeed) and here I see the ContentDocument Id. Is if enough to get the document? Probably again I just need to consider the Type. And get the document either from ContentDocument or ContentVersion by ContentDocument Id. However the Type is not presented in ContentDocumentLink Commented Feb 4, 2021 at 12:53

You must log in to answer this question.

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