/messages.json - Post
Definition
https://www.yammer.com/api/v1/messages.json
Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
body | body | string | The text of the message body | |
replied_to_id | body | integer | The message ID this message is in reply to. If this is set then group_id and network_id are inferred from it. |
|
direct_to_user_ids | body | array of integers | Send a private message to one or more users, specified by ID. | |
group_id | body | integer | Post the message to this group, specified by ID. If this is set then the network_id is inferred from it. If your 'All Company' group does not have a numeric 'feed_id' then a post without direct_to_user_ids , replied_to_id or group_id will default to All Company group. |
|
network_id | body | integer | If your 'All Company' does not have a numeric 'feed_id' then you can post a message in the 'All Company' feed if replied_to_id, direct_to_user_ids and group_id are all omitted. | |
yammer-capbilities | header | string | Set this header to "external-messaging,external-groups" to be able post to external threads and groups. If you are doing this then your app should make it clear to users that their message can be seen by people outside their organisation when it includes external participants. See https://support.office.com/en-gb/article/External-messaging-FAQ-Yammer-35b59d6c-bb1c-4541-bf19-9f67d2f2b199| |
Documentation
Create a new message. The response body will include the new message formatted the same way as message polling above. This allows your app to immediately display the newly-posted message back to the user.
POST messages are form encoded. To post in an existing Yammer conversation, set the replied_to_id to the ID of the message that you're replying to.
To start a new Yammer conversation, specify where the message should be posted using one of direct_to_user_ids, group_id, or network_id.
- Specify direct_to_user_ids to send a private message to just those users. They will see the message in their Yammer Inbox, but not in a group on Yammer.
- To post in group, specify the group_id parameter.
- If only the 'network_id' is specified, then the message will be posted in the 'All Company' feed in Yammer for networks that have the 'All Company' group feed id as 'company'. For networks that have a numeric feed id for their 'All Company' group, use the 'feed_id' as a 'group_id' in the request body to post to the 'All Company' group.
- Someone might attach an OGO (and its metadata) directly to the message.
Announcements
To send an announcement, set the following parameters, and use HTML to format the message body.
is_rich_text:true
message_type:announcement
title: your text here
Applying Topics
To apply topics to the message provide the topic name(s) in parameters topic1
through topic20
.
Attaching Files
Yammer provides the uploadSmallFile API for attachments with a message. There is a file size upload limit of 4MB. On success each small file upload response body includes an id. Let's assume you have a file with the id=123456. In order to upload that file with the message, in the body parameters of the message.json API, you can add: attached_objects[]: uploaded_file:123456
. If you need to attach multiple files, then you can add one line per file in the body parameters of the API.
Attaching Open Graph Objects
A message may contain an Open Graph (OG) object as an attachment. The og_url
parameter is required, the other parameters are optional.
Field | Description |
---|---|
og_url | The canonical URL of the OG object used as its permanent ID in the graph. (required) If the og_url is a SharePoint URL, you will need to call this API using an AAD token. |
og_fetch | Unless set to false, this flag will ask the Yammer server will fetch the page at the given URL and attempt to populate the other OG parameters automatically. For this to work, the page must be publicly accessible over the Internet from Yammer’s servers or a SharePoint URL for which the user has permissions to access it. |
og_title | The title of your object as it must appear within the graph. |
og_image | A thumbnail image URL that represents your object in the graph. If the og_url is a SharePoint URL, do not add a thumbnail image URL in og_image. Even if you pass it, it will not be used. Yammer fetches from SharePoint the thumbnail associated with the SharePoint URL. |
og_description | A one to two-sentence description of your object. |
og-object_type | The type of your object, e.g., “employee”. |
og_site_name | An identifier to relate objects from a common domain, e.g., “Yammer Blog”. |
og_meta | Structured metadata about this object that can be used by clients for custom rendering. |
Frequently asked questions
Can the messages created using the POST messages API be backdated to an earlier date?
At this time, backdating messages is not possible because API doesn't support parameters like 'created_at' or 'published_at'. All messages posted via this API will be created at the current timestamp and cannot be assiged a custom creation date.