The Messaging APIs let you send, manage, and search messages across every kind of room. This section covers the Chat endpoints (messages in channels, groups, and threads), Direct Messages, and Auto-Translate.
The message object
Message endpoints accept and return a message object. A trimmed example from Get Message:
{
"message": {
"_id": "CeXwh5eBbdrtvnqG6",
"rid": "agh2Sucgb54RQ8dDo",
"msg": "s",
"ts": "2018-10-05T13:48:21.616Z",
"u": {
"_id": "KPkEYwKKBKZnEEPpt",
"username": "marc.pow",
"name": "Marc Pow"
},
"reactions": {
":frowning2:": { "usernames": ["marcos.defendi"] }
},
"mentions": [],
"channels": []
},
"success": true
}Fields you use most often:
_id: The message ID. Pass it asmsgIdormessageIdwhen updating, reacting, pinning, or deleting.rid: The ID of the room the message belongs to. Most message endpoints require it.msg: The message text.u: The user who sent the message.tmid: Set when the message belongs to a thread — it holds the thread's parent message ID.
Common workflows
Post and manage a message
Post a message to a room using its
roomIdor channel name.Delete the message when it is no longer needed.
Start a direct message
Create the direct message session with one or more users.
Post messages using the returned room ID.
Close the session to hide it from your room list.
Work with threads
Send a message with
tmidset to the parent message ID to reply in a thread.Mark the thread as read when you finish processing it.
Translate messages
Translate the message to the target language.
Conventions
Post Message accepts a channel name or ID and can send to multiple channels; Send Message targets one room and lets you set a custom message
_idand thread fields.Message endpoints identify rooms by
roomId(rid). Message-level actions take the message ID from the message object.List endpoints such as Search Message support
countandoffsetquery parameters.