Newer Version Available

This content describes an older version of this product. View Latest

Feed Elements, Post and Search

Post feed elements and search all feed elements in an organization.
Resource
1/chatter/feed-elements
1/connect/communities/communityId/chatter/feed-elements
Available version
31.0
Requires Chatter
Yes
HTTP methods
GET, POST
Request parameters for GET
Parameter Name Type Description Required or Optional Available Version
page String Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned. Optional 31.0
pageSize Integer Specifies the number of feed elements per page. Valid values are from 1 through 100. If you pass in null, the default size is 25. Optional 31.0
q String One or more keywords to search for in the feed elements visible to the context user. The search string can contain wildcards and must contain at least two characters that aren’t wildcards. See Wildcards. Required 31.0
recentCommentCount Integer Maximum number of comments to return with each feed element. The default value is 3. Optional 31.0
sort String Order of feed items in the feed.
  • CreatedDateAscSorts by oldest creation date. This sort order is available only for DirectMessageModeration, Draft, Isolated, Moderation, and PendingReview feeds.
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
  • MostViewed—Sorts by most viewed content. This sort order is available only for Home feeds when the ConnectApi.FeedFilter is UnansweredQuestions.
  • Relevance—Sorts by most relevant content. This sort order is available only for Company, Home, and Topics feeds.
Optional 31.0
threadedComments​Collapsed Boolean Specifies whether to return threaded comments in a collapsed style (true) or not (false). If you don’t specify, the default is false. Optional 44.0
Response body for GET
Feed Element Page
Request body for POST
Feed item and comment bodies have a 10,000 character limit. Because this limit can change, we recommend that clients make a describeSObjects() call on the FeedItem or FeedComment object. To determine the maximum number of allowed characters, look at the length of the Body or CommentBody field.
Feed Item Input
Request parameters for POST
Parameter Name Type Description Required or Optional Available Version
feedElementType String Feed elements are the top-level items that a feed contains. Feeds are feed element containers.

The only possible value is FeedItem.

Required 31.0
originalFeed​ElementId String If this feed element is shared, the original feed element 18-character ID.

In version 39.0 and later, use the Feed Item Input with the nested Feed Entity Share Capability Input.

Important

Optional 31.0–38.0
subjectId String The ID of the parent this feed element is being posted to. This value can be the ID of a user, group, or record, or the string me to indicate the context user. Required 31.0
text String Text of the feed element. Required 31.0
visibility String Specifies the type of users who can see a feed element.
  • AllUsers—Visibility is not limited to internal users.
  • InternalUsers—Visibility is limited to internal users.
Optional 31.0
Response body for POST
Feed Item
Example for posting a feed item using the request body
1{ 
2   "body" : {
3      "messageSegments" : [
4         {
5            "type" : "Text",
6            "text" : "When should we meet for release planning? "
7         }]
8       },
9   "feedElementType" : "FeedItem",
10   "subjectId" : "005D00000016Qxp"
11}
Example for posting a feed item with a mention using the request body
1{ 
2   "body" : {
3      "messageSegments" : [
4         {
5            "type" : "Text",
6            "text" : "When should we meet for release planning? "
7         },
8         {   
9            "type" : "Mention",
10            "id" : "005T0000000mzCy"
11         }
12      ]
13   },
14   "feedElementType" : "FeedItem",
15   "subjectId" : "005D00000016Qxp"
16}
Example for posting a feed item with multiple mentions using the request body
1{ 
2   "body" : {
3      "messageSegments" : [
4         {
5            "type" : "Text",
6            "text" : "When should we meet for release planning? "
7         },
8         {   
9            "type" : "Mention",
10            "id" : "005T0000000mzCy"
11         },
12         {
13            "type" : "Text",
14            "text" : " "
15         },
16         {   
17            "type" : "Mention",
18            "id" : "005B0000000Ek1S"
19         } 
20      ]
21   },
22   "feedElementType" : "FeedItem",
23   "subjectId" : "005D00000016Qxp"
24}
Example for posting a feed item with files using the request body
1{
2   "body":{
3      "messageSegments":[
4         {
5            "type":"Text",
6            "text":"Please take a look at these files."
7         }
8      ]
9   },
10   "capabilities":{
11      "files":{
12         "items": [
13            {"id": "069D00000001IOh"},
14            {"id": "069D00000002IOg"}
15         ]
16      }
17   },
18   "subjectId":"me",
19   "feedElementType":"FeedItem"
20}
Example for posting a poll using the request body
1{
2   "body":{
3      "messageSegments":[
4         {
5            "type":"Text",
6            "text":"When should we meet for release planning?"
7         }
8      ]
9   },
10   "capabilities":{
11      "poll":{
12         "choices":[
13            "Monday",
14            "Tuesday"
15         ]
16      }
17   },
18   "feedElementType":"FeedItem",
19   "subjectId":"me"
20}
Example for posting a rich-text feed item using the request body
1{
2   "body":{
3      "messageSegments":[
4         {
5            "markupType" : "Paragraph",
6            "type" : "MarkupBegin"
7         },
8         {
9            "markupType" : "Bold",
10            "type" : "MarkupBegin"
11         },
12         {
13             "text" : "First line of text.",
14             "type" : "Text"
15         },
16         {
17            "markupType" : "Bold",
18            "type" : "MarkupEnd"
19         },
20         {
21            "markupType" : "Paragraph",
22            "type" : "MarkupEnd"
23         },
24         {
25            "markupType" : "Paragraph",
26            "type" : "MarkupBegin"
27         },
28         {
29            "text" : " ",
30            "type" : "Text"
31         },
32         {
33            "markupType" : "Paragraph",
34            "type" : "MarkupEnd"
35         },
36         {
37            "markupType" : "Paragraph",
38            "type" : "MarkupBegin"
39         },
40         {
41            "text" : "Second line of text.",
42            "type" : "Text"
43         },
44         {
45            "markupType" : "Paragraph",
46            "type" : "MarkupEnd"
47         }
48      ]
49   },
50   "subjectId":"me",
51   "feedElementType":"FeedItem"
52}
Example for posting a feed item with a code block using the request body
1{
2   "body":{
3      "messageSegments":[
4         {
5            "markupType" : "Code",
6            "type" : "MarkupBegin"
7         },
8         {
9             "text" : "<script>var i, t = 0;\nfor (i = 0; i < 5; i++) {\n   t +=
10                       i;\n}\n</script>",
11             "type" : "Text"
12         },
13         {
14            "markupType" : "Code",
15            "type" : "MarkupEnd"
16         }
17      ]
18   },
19   "subjectId":"me",
20   "feedElementType":"FeedItem"
21}
Example for posting a feed item with an inline image using the request body
1{
2   "body":{
3      "messageSegments":[
4         {
5            "type":"Text",
6            "text":"Please take a look at this file."
7         },
8         {
9            "type":"InlineImage",
10            "fileId":"069xx00000000QO",
11            "altText":"API Spec"
12         },
13         {
14            "type":"Text",
15            "text":"And this one."
16         },
17         {
18            "type":"InlineImage",
19            "fileId":"069xx00000000QT",
20            "altText":"REST API Spec"
21         }
22      ]
23   },
24   "subjectId":"me",
25   "feedElementType":"FeedItem"
26}
Example for sharing a feed item using the request body
1{ 
2   "body" : {
3      "messageSegments" : [
4         {
5            "type" : "Text",
6            "text" : "When should we meet for release planning? "
7         },
8         {   
9            "type" : "Mention",
10            "id" : "005D00000016Qxp"
11         }]
12       },
13   "capabilities" : {
14      "feedEntityShare" : {
15         "feedEntityId" : "0D5B000000Py41t"
16         }
17      },
18   "feedElementType" : "FeedItem",
19   "subjectId" : "0F9B000000000W2"
20}
Example for sending a direct message
1{
2   "body":{
3      "messageSegments":[
4         {
5            "type":"Text",
6            "text":"Thanks for attending my presentation test run this morning. Send me any feedback."
7         }
8      ]
9   },
10   "capabilities":{
11      "directMessage":{
12         "membersToAdd": ["005R0000000I2X4","005R0000000I23Y"],
13         "subject": "Thank you!"
14      }
15   },
16   "subjectId":"me",
17   "feedElementType":"FeedItem"
18}