Send a message to one room. Unlike chat.postMessage, this endpoint accepts _id, blocks, and tshow, but it can't send to more than one room.
Note: You can only send the alias and avatar properties if your user has the message-impersonate (Impersonate other users) permission. By default, only the bot and app roles have this permission.
The server removes markdown trees (md and descriptionMd) from attachments before it saves the message. It does not generate a new md for the attachment.
Change Log
| Version | Description |
|---|---|
| 9.0.0 | Rejected message fields that are not part of the request body, such as fields that only the server sets, and blocks with an invalid structure. Stripped md and descriptionMd from attachments before saving the message. |
| 6.8.0 | Added custom fields to messages. |
| 6.4.0 | Added the previewUrls parameter. |
| 2.4.0 | Added validation on user's identity |
| 0.60.0 | Added |
The authToken of the authenticated user.
The userId of the authenticated user.
Some important things to note about the previewUrls parameter include:
- If you don't send
previewUrls, all external URLs in the message are previewed. - If you list URLs, only those URLs are previewed.
- If
previewUrlsis empty, no URL is previewed. - If the message contains attachments or quotes, no URL is previewed.
- Internal URLs are never previewed, even if you list them.
- A message can have at most five external URL previews. If it contains more than five external URLs, no URL is previewed.
URLs that include the same text as the Site URL are referred to as Internal URLs.
{
"message": {
"rid": "Xnb2kLD2Pnhdwe3RH",
"msg": "Sample message",
"emoji": ":smirk:",
"attachments": [
{
"color": "#ff0000",
"text": "Yay for gruggy!",
"ts": "2016-12-09T16:53:06.761Z",
"thumb_url": "http://res.guggy.com/logo_128.png",
"message_link": "https://google.com",
"collapsed": false,
"author_name": "Bradley Hilton",
"author_link": "https://rocket.chat/",
"author_icon": "https://avatars.githubusercontent.com/u/850391?v=3",
"title": "Attachment Example",
"title_link": "https://youtube.com",
"title_link_download": true,
"image_url": "http://res.guggy.com/logo_128.png",
"audio_url": "http://www.w3schools.com/tags/horse.mp3",
"video_url": "http://www.w3schools.com/tags/movie.mp4",
"fields": [
{
"short": true,
"title": "Test",
"value": "Testing out something or other"
},
{
"short": true,
"title": "Another Test",
"value": "[Link](https://google.com/) something and this and that."
}
]
}
]
}
}{
"message": {
"rid": "GENERAL",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Text example* Normal message `code` here"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Field 1*"
},
{
"type": "mrkdwn",
"text": "Field 2"
}
]
}
]
}
}{
"message": {
"rid": "64f0f82c2c26843a68c1f7ba",
"msg": "This is a list of links! https://google.com https://hola.org/ https://www.usepayday.com/ https://www.getbumpa.com/ https://www.atlassian.com/software/jira http://localhost:3000/"
},
"previewUrls": [
"https://google.com",
"http://localhost:3000/",
"https://hola.org/",
"https://www.usepayday.com/",
"https://www.getbumpa.com/",
"https://www.atlassian.com/software/jira"
]
}Accepts only the properties listed here. Any other property, such as an unknown property or one that only the server sets (for example u, ts, md, urls, or pinned), fails.
The message type, for example e2e. A system message type, such as uj, fails.
The room ID where the message is to be sent.
The message text to send.
The name to display on the message instead of your name. Your username is still displayed. Requires the message-impersonate permission.
An emoji to display as the message avatar.
The URL of an image to display as the message avatar. Requires the message-impersonate permission.
An array of attachment objects with the following properties.
Displays a tiny icon to the left of the author's name.
Providing this makes the author name clickable and points to this link.
Name of the author.
Causes the image, audio, and video sections to be displayed as collapsed when set to true.
Whether this field should be a short field.
The title of this field.
The value of this field, displayed underneath the title value.
The URL of the image to display in the attachment.
Only applicable if the ts parameter is provided, as it makes the time clickable to this link.
The text to display in the attachment.
The URL of a thumbnail image to display to the left of the attachment text.
Title to display for this attachment, displays under the author.
Providing this makes the title clickable, pointing to this link.
When this is true, a download icon appears and clicking this saves the link to file.
Displays the time next to the text portion.
The ID of the message to reply to in a thread.
Set to true to also show the thread reply in the room. Requires tmid.
An array of UI Kit blocks to display in the message. See the Message with Blocks example and the Apps-Engine UI Blocks documentation.
The request fails if:
blocksis not an array of objects.- The
elementsof anactionsorcontextblock is missing or is not an array of objects. - The
fieldsof asectionblock is not an array of objects. - An
inputblock has noelementobject. - A
linear_scaleelement has a non-numericminValueormaxValue, or more than 100 points. - An
appIdcontains characters other than letters, digits,-, and_. - A block is nested more than 10 levels deep.
Blocks with an unknown type or an unexpected text shape are saved as sent.
Custom fields for the message, such as a priority. Custom fields must be enabled, and the value must match the validation defined in the Message settings.
The ID to give the new message. It must not match the ID of an existing message. If you don't send it, the server generates one.
A GeoJSON geometry to attach to the message, such as a Point with coordinates as [longitude, latitude]. Invalid GeoJSON, or a longitude or latitude out of range, fails. The server doesn't check the coordinate order, so swapped coordinates that are still in range are saved without an error. The web client shows a Point as a Shared location link to a map.
Set to false to show the message with its own header instead of grouping it with the sender's previous message.
Set to false to stop the server from extracting URLs from the message text. The message is saved with no urls entries and no link preview. Links in the message markdown (md) are still parsed.
A separate text field that the server saves as sent. It is not an alias of msg: the server does not generate md from it, and the web client does not display it. Use msg for the message text.
The encryption state of an end-to-end encrypted message: pending or done.
Mentions in an end-to-end encrypted message, as e2eUserMentions and e2eChannelMentions arrays.
The encrypted content of an end-to-end encrypted message. Set algorithm to rc.v1.aes-sha2 or rc.v2.aes-sha2, and ciphertext to the encrypted text. With rc.v2.aes-sha2, also send iv and kid. The server saves the object as sent and does not validate its properties.
The URLs in msg to preview.
OK
{
"message": {
"rid": "GENERAL",
"msg": "Hello from the API",
"ts": "2026-11-03T13:57:54.003Z",
"u": {
"_id": "i5FdM4ssFgAcQP62k",
"username": "rocket.cat",
"name": "Rocket.Cat"
},
"_id": "dy8Qx3XXH9wKR9AMP",
"_updatedAt": "2026-11-03T13:57:54.056Z",
"md": [
{
"type": "PARAGRAPH",
"value": [
{
"type": "PLAIN_TEXT",
"value": "Hello from the API"
}
]
}
],
"mentions": [],
"channels": [],
"urls": []
},
"success": true
}Bad Request
{
"success": false,
"error": "must have required property 'message'",
"errorType": "error-invalid-params"
}{
"success": false,
"error": "tshow provided but missing tmid [invalid-params]",
"errorType": "invalid-params",
"details": {
"method": "sendMessage"
}
}{
"success": false,
"error": "The 'rid' property on the message object is missing."
}{
"success": false,
"error": "error-invalid-room"
}{
"success": false,
"error": "The message fields cannot be set through 'chat.sendMessage': ts, u"
}{
"success": false,
"error": "Cannot send system messages using 'chat.sendMessage'"
}{
"success": false,
"error": "must be array",
"errorType": "error-invalid-params"
}{
"success": false,
"error": "must be object",
"errorType": "error-invalid-params"
}{
"success": false,
"error": "must have required property 'element'",
"errorType": "error-invalid-params"
}{
"success": false,
"error": "Invalid blocks: blocks[0].elements[0] must have numeric minValue and maxValue"
}{
"success": false,
"error": "Invalid blocks: blocks[0].elements[0] cannot have more than 100 points"
}{
"success": false,
"error": "Invalid blocks: blocks[0].appId must contain only letters, digits, \"-\" and \"_\""
}{
"success": false,
"error": "Invalid blocks: blocks[0].d.a.a.a.a.a.a.a.a.a.a is nested too deeply"
}{
"success": false,
"error": "must be object",
"errorType": "error-invalid-params"
}{
"success": false,
"error": "Not enough permission"
}{
"success": false,
"error": "Invalid attachment field, title and value is required"
}{
"success": false,
"error": "Custom fields not enabled"
}{
"success": false,
"error": "Invalid custom fields"
}Unauthorized
{
"success": false,
"error": "You must be logged in to do this."
}