Newer Version Available

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

News Feed Resources

A feed containing feed elements of interest to the context user. You can post feed items to the news feed.

To match the feed displayed in the Chatter Web UI, the composition of this feed may change between releases.

Note

Available resources are:

Resource Description
/chatter/feeds/news/me Returns a URL to the feed elements for all feeds for the context user.
/chatter/feeds/news/me/feed-elements All feed elements from all groups the context user either owns or is a member of, as well as all files, records, and users the context user follows. Use this resource to get information about feed elements and to post feed elements.

News Feed URL

Returns a URL to the feed elements for all feeds for the context user.

Resource
1/chatter/feeds/news/userId
1/connect/communities/communityId/chatter/feeds/news/userId

userId must be the ID of the context user or the alias me.

Note

Available since version
23.0
Requires Chatter
Yes
HTTP methods
GET or HEAD
Request parameter
Parameter Name Type Description
sort String Specifies the order returned by the sort, such as by date created or last modified:
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
The default value is CreatedDescDate.
Response body
Feed
Example response body
1{ 
2   "feedElementPostUrl": "/services/data/v34.0/chatter/feed-elements",
3   "feedElementsUrl": "/services/data/v34.0/chatter/feeds/news/005xx000001Sv1mAAB/feed-elements"
4}

News Feed Elements

All feed elements from all groups the context user either owns or is a member of, as well as all files, records, and users the context user follows. Use this resource to get information about feed elements and to post feed elements.

For information about posting a feed element, see Feed Elements, Post and Search.

For information about uploading and attaching a binary file to a feed element, see Uploading Binary Files.

Resource
1/chatter/feeds/news/userId/feed-elements
1/connect/communities/communityId/chatter/feeds/news/userId/feed-elements

userId must be the ID of the context user or the alias me.

Note

Available since version
31.0
Requires Chatter
Yes
HTTP methods
GET, HEAD
Request parameters for GET
Parameter Name Type Description Required or Optional Available Version
density String The density of the feed. One of these values:
  • AllUpdates—Displays all updates from people and records the user follows and groups the user is a member of.
  • FewerUpdates—Displays all updates from people and records the user follows and groups the user is a member of, but hides some system-generated updates from records.

The default value is AllUpdates.

Optional 31.0
elementsPerBundle Integer Maximum number of feed elements to include in a bundle. The value must be an integer from 0 through 10. The default value is 3.

Bundled posts contain feed-tracked changes. In Salesforce1 downloadable apps, bundled posts are in record feeds only.

Note

Optional 31.0
filter String Specifies the filter values that can be applied to a feed.
  • AllQuestions—Only feed elements that are questions.
  • CommunityScoped—Reserved for future use.
  • SolvedQuestions—Only feed elements that are questions and that have a best answer.
  • UnansweredQuestions—Only feed elements that are questions and that don’t have any answers.
  • UnsolvedQuestions—Only feed elements that are questions and that don’t have a best answer.
Optional 32.0
page String A generated token that indicates the view of feed elements in the feed.
Page tokens are returned as part of the response body, in one of the URL parameters, such as nextPageURL:
1"nextPageUrl": 
2"/services/data/v34.0/
3chatter/feeds/news/
4005D0000001GLowIAN
5/feed-elements
6?page=2011-03-30T17:34:50Z,
70D5D0000000DSv4KAG"
Optional 31.0
pageSize Integer Specifies the number of elements per page. Valid values are from 1 through 100. If you don't specify a size, the default is 25. Optional 31.0
q String One or more keywords to search for in the body and comments of feed elements in this feed.

The search string can contain wildcards and must contain at least two characters that aren’t wildcards. See Wildcards.

Optional 31.0
recentComment​Count Integer Maximum number of comments to include per feed element. The default value is 3. The maximum value is 25. Optional 31.0
sort String Specifies the order returned by the sort, such as by date created or last modified:
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
The default value is CreatedDescDate.
Optional 31.0
updatedSince String An opaque token defining the modification time stamp of the feed and the sort order.

Do not construct this token. Retrieve this token from the updatesToken property of the Feed Element Page response body.

Optional 31.0
Response body for GET
Feed Element Page

News Feed Items

All feed items from all groups the context user either owns or is a member of, as well as all files, records, and users the context user follows. Use this resource to get information about the feed items and to post feed items, including attaching files, posting links, polls, and questions, and sharing posts.

For information about posting a feed item, see Using POST, PATCH, or PUT for Input.

For information about uploading and attaching a binary file to a feed item, see Uploading Binary Files.

As of API version 29.0, feed items can contain 5000 characters. This change is backwards compatible; all earlier API versions support the 5000 character limit.

Resource
1/chatter/feeds/news/userId/feed-items

userId must be the ID of the context user or the alias me.

Note

Available versions
23.0–31.0

In version 32.0 and later, use News Feed Elements.

Important

Requires Chatter
Yes
HTTP methods
GET, POST, HEAD
Request parameters for GET
Parameter Name Type Description Required or Optional Available Version
density String The density of the feed. One of these values:
  • AllUpdates—Displays all updates from people and records the user follows and groups the user is a member of.
  • FewerUpdates—Displays all updates from people and records the user follows and groups the user is a member of, but hides some system-generated updates from records.

The default value is AllUpdates.

Optional 29.0–31.0
page String A generated token that indicates the view of feed items in the feed. Page tokens are returned as part of the response body, in one of the URL parameters, such as nextPageURL:
1"nextPageUrl": 
2"/services/data/v34.0/
3chatter/feeds/news/
4005D0000001GLowIAN
5/feed-items
6?page=2011-03-30T17:34:50Z,
70D5D0000000DSv4KAG"
Optional 23.0–31.0
pageSize Integer Specifies the number of items per page. Valid values are from 1 through 100. If you don't specify a size, the default is 25. Optional 23.0–31.0
q String One or more keywords to search for in the body and comments of feed items in this feed.

The search string can contain wildcards and must contain at least two characters that aren’t wildcards. See Wildcards.

Optional 28.0–31.0
recentComment​Count Integer Maximum number of comments to include per feed item. The default value is 3. The maximum value is 25. Optional 29.0–31.0
sort String Specifies the order returned by the sort, such as by date created or last modified:
  • CreatedDateDesc—Sorts by most recent creation date.
  • LastModifiedDateDesc—Sorts by most recent activity.
The default value is CreatedDescDate.
Optional 23.0–31.0
updatedSince String An opaque token defining the modification time stamp of the feed and the sort order.

Do not construct this token. Retrieve this token from the updatesToken property of the Feed Item Page response body.

Optional 30.0–31.0
Request body for POST
Root XML tag
<feedItem>
JSON
The following example attaches a poll to a feed item:
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}
Feed items support more than 1 capability. The following example attaches a file to a feed item and bookmarks it.
1{
2   "body":{
3      "messageSegments":[
4         {
5            "type":"Text",
6            "text":"Check out the latest marketing collateral."
7         }
8      ]
9   },
10   "capabilities":{
11      "bookmarks":{
12         "isBookmarkedByCurrentUser": true
13      },
14      "content":{
15         "contentDocumentId": "069D00000001uQO"
16      }
17   },
18   "feedElementType":"FeedItem",
19   "subjectId":"me"
20}
Properties
Name Type Description Required or Optional Available Version
attachment Depends on type. You can specify only one of these values in the attachment parameter. Values are:

As of API version 32.0, use the capabilities property.

Important

Optional
body Message Body Input Description of message body. The body can contain up to 25 mentions.

If you specify originalFeedElementId to share a feed item, use the body property to add the first comment to the feed item.

To edit this property in a feed item, make a PATCH request to /chatter/feed-elements​/feedElementId. Editing feed posts is supported in version 34.0 and later.

Required unless the feed item has a content capability or a link capability 23.0
capabilities Feed Element Capabilities Input The capabilities that define the behavior of this feed element. Optional 31.0
isBookmarked​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false.

As of API version 32.0, use the capabilities.bookmarks.​isBookmarkedByCurrentUser property.

Important

Optional 24.0–31.0
feedElementType String The type of feed element this input represents.

The only valid value is FeedItem.

Required 31.0
originalFeedElementId String To share a feed element, specify its 18-character ID.

You can’t share a post and upload a file in the same request body.

Note

Optional 31.0
originalFeedItemId String To share a feed item, specify its 18-character ID.

As of API version 32.0, use the originalFeedElementId property.

Important

Optional 24.0–31.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
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 26.0
Request parameters for POST
Use one of the following sets of parameters. For example, you can’t post a link and attach a file in the same request.

Parameters for attaching an existing file

Parameter Name Type Description Required or Optional Available Version
attachmentType String The attachment type. Must contain the value ExistingContent. Required 27.0–31.0
contentDocumentId String 18-character ID of an existing file. Required 23.0–31.0
isBookmarked​​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false. Optional 26.0–31.0
text String Text of the feed item. Optional 23.0–31.0
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 26.0–31.0

Parameters for attaching a new file

Parameter Name Type Description Required or Optional Available Version
attachmentType String The attachment type. Must contain the value NewFile. Required 27.0–31.0
desc String Description of file being posted.

Don’t use this parameter as of version 27.0. Use description instead.

Attention

Optional 23.0–26.0
description String Description of file being posted. Optional 27.0–31.0
fileName String File name of the file being posted.

Don’t use this parameter as of version 24.0. Use title instead.

Attention

Required 23.0–24.0
isBookmarked​​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false. Optional 26.0–31.0
text String Text of the feed item. Optional 23.0–31.0
title String File name of a file to be uploaded and posted. Required 24.0–31.0
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 26.0–31.0
Parameters for posting a link
Parameter Name Type Description Required or Optional Available Version
attachmentType String The attachment type. Must contain the value Link. Required 27.0–31.0
isBookmarked​​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false. Optional 26.0–31.0
text String Text of the feed item. Optional 23.0–31.0
url String URL of the link. Required 23.0–31.0
urlName String Name of the URL. Optional 23.0–31.0
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 26.0–31.0
Parameters for posting a poll
Parameter Name Type Description Required or Optional Available Version
attachmentType String The attachment type. Must contain the value Poll. Required 27.0–31.0
isBookmarked​​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false. Optional 26.0–31.0
pollChoice1 through pollChoice10 String The choices used to create a feed item with a poll. Specify 2–10 poll choices for each poll. Required 26.0–31.0
text String Text of the feed item. Required 23.0–31.0
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 26.0–31.0
Parameters for sharing a post
Parameter Name Type Description Required or Optional Available Version
isBookmarked​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false. Optional 26.0–31.0
originalFeedItemId String The 18-character ID of the feed item you want to share.

Sharing a post takes precedence over uploading a file. Do not share a post and upload a file in the same post.

Note

Required 24.0–31.0
text String A comment on the shared feed item. Optional 28.0–31.0
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 26.0–31.0
Parameters for posting text only
Parameter Name Type Description Required or Optional Available Version
isBookmarked​​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false. Optional 26.0–31.0
text String Text of the feed item. The maximum number of characters is 1000. Required 23.0–31.0
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 26.0–31.0
Parameters for posting a canvas app
Parameter Name Type Description Required or Optional Available Version
attachmentType String The attachment type. Must contain the value Canvas. Required 29.0–31.0
description String Description of the canvas app Optional 29.0–31.0
developerName String The developer name (API name) of the canvas app Required 29.0–31.0
height String The height of the canvas app in pixels. Default height is 200 pixels. Optional 29.0–31.0
isBookmarked​​ByCurrentUser Boolean Specifies whether to bookmark the new feed item for the user (true) or not (false). The default value is false. Optional 29.0–31.0
namespacePrefix String The namespace prefix of the Developer Edition organization in which the canvas app was created. Optional 29.0–31.0
parameters String Parameters passed to the canvas app in JSON format. The JSON must be URL-encoded:
1parameters={'isUpdated'='true';}"
Optional 29.0–31.0
text String Text of the feed item Optional 29.0–31.0
thumbnailUrl String The URL to a thumbnail image for the canvas app. Maximum dimensions are 120x120 pixels. Optional 29.0–31.0
title String The title of the link to the canvas app Optional 29.0–31.0
visibility String Who can see the post. Valid values are:
  • InternalUsers—If Communities is enabled, only members of the default, internal community can see the feed item.
  • AllUsers—If Communities is enabled, all members of the community can see the feed item.
Default values:
  • For external users, the default value is AllUsers. External users must use this value to see their posts.
  • For internal users, the default value is InternalUsers. Internal users can accept this value or use the value AllUsers to allow external users to see their posts.
If the parent of the feed item is a User or a Group, the visibility of the feed item must be AllUsers.
Optional 29.0–31.0
Response body for GET
Feed Item Page
Response body for POST
Feed Item
Example of file post
This example updates a news feed with a post that has a new file attachment.
1curl https://instance_name/services/data/v31.0/chatter/feeds/news/me/feed-items 
2     --form "feedItemFileUpload=@Desktop/textFile.txt" 
3     --form "title=Sample" 
4     --form "description=Just a Text File" 
5     --form "text=Please review" 
6     --form "attachmentType=NewFile" 
7     --header 'Authorization: Bearer 00DD0000000Jhd2!AQIAQBgn42jbvCW2SX8JaRO2_JjX1fNKXWBrjYQPXODtDyaT6gT4DJVs4Ki7s6GoxvO8a.Z7gTHKkfqjW6S1.ujlD413PYpF'
This Java example updates a news feed with a file post.
1swfobject.registerObject("clippy.codeblock-12", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17import java.io.File;
18
19import org.apache.commons.httpclient.*;
20import org.apache.commons.httpclient.methods.PostMethod;
21import org.apache.commons.httpclient.methods.multipart.*;
22
23...
24
25String oauthToken = "00Dx0000000X42V!AQgAQClp6UqGWNJUf4d3LQkVCysBIS6a";
26String url = "https://instance_name/services/data/v31.0/chatter/" +
27              "feeds/user-profile/me/feed-items";
28String text = "I love posting files to Chatter!";
29File contentFile = getFile();
30String description = "This is a test file that I'm posting.";
31String title = "contentFile";
32Part[] parts = {
33        new StringPart("description", description),
34        new StringPart("title", fileName),
35        new StringPart("text", text),
36        new FilePart("feedItemFileUpload", contentFile),
37};
38
39final PostMethod postMethod = new PostMethod(url);
40                
41try {
42    postMethod.setRequestEntity(new MultipartRequestEntity(parts, 
43                                postMethod.getParams()));
44    postMethod.setRequestHeader("Authorization", "Bearer " + oauthToken);
45    postMethod.setRequestHeader("Content-type", "multipart/form-data")
46    postMethod.addRequestHeader("X-PrettyPrint", "1");
47    
48    HttpClient httpClient = new HttpClient();
49    httpClient.getParams().setSoTimeout(60000);
50    
51    int returnCode = httpClient.executeMethod(postMethod);
52    
53    System.out.println(postMethod.getResponseBodyAsString());
54    
55    assertTrue("Expected return code of: " + HttpStatus.SC_CREATED, 
56                returnCode == HttpStatus.SC_CREATED);
57} finally {
58    postMethod.releaseConnection();
59}
60
Example of a link post
This request creates a link post using the request parameters:
1/chatter/feeds/news/me/feed-items?text=Did+you+see+this?&url=http://www.chatter.com
This request body creates a link in a feed item post:
1{ "body" : { 
2     "messageSegments" : [ 
3        { 
4           "type": "Link", 
5           "url" : "http://www.chatter.com" 
6        },
7        { 
8           "type": "Text", 
9           "text" : "Is everyone following this?" 
10        }
11      ]
12  }
13}
This request body includes a link as an attachment to a feed item post:
1{ "body" : { 
2      "messageSegments" : [ 
3         { 
4            "type": "Text", 
5            "text" : "Is everyone following this?" 
6         }
7      ]
8   },
9  "attachment" :{ 
10     "url" : "http://www.chatter.com",
11     "urlName" : "The Future of Social Enterprise"
12  }
13}

News Feed Items Flat

This resource is deprecated as of version 26.0.

Returns a flat feed, that is, a feed where there is no hierarchy between feed items and comments: Feed items and comments are at the same level. All items are returned in chronological order.

Resource
1/chatter/feeds/news/me/feed-items/flat
or
1/chatter/feeds/news/userId/feed-items/flat

userId must be the ID of the context user or the alias me.

Note

Available since version
25.0–26.0

As of API version 32.0, use /chatter/feeds/news/userId/feed-elements.

Important

Requires Chatter
Yes
HTTP methods
GET or HEAD
Request parameters
Parameter Name Type Description
numFeedItems Integer Specifies the number of feed items returned. Valid values are from 0 through 100. Default value is 25. Because feed items can include comments, specifying 25 flat feed items may actually return more. For example, if each feed item has one comment, and recentCommentCount is greater than 1, 50 flat feed items are returned.
page String A generated token that indicates the view of feed items in the feed. Page tokens are returned as part of the response body, in one of the URL parameters, such as nextPageURL.
recentComment​Count Integer Specifies the number of recent comments returned. Valid values are from 0 through 25. Default value is 3.
sort String. One of the following:
  • CreatedDateDesc
  • LastModifiedDateDesc
Sorts the returned feed either by created date in ascending order, or by last modified date, also in ascending order. The default is LastModifiedDateDesc
Response body
Flat Feed