Send Message

Prev Next
Post
/api/v1/chat.sendMessage

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
Header parameters
X-Auth-Token
stringRequired

The authToken of the authenticated user.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
X-User-Id
stringRequired

The userId of the authenticated user.

ExamplerbAXPnMktTFbNpwtJ
Body parameters

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 previewUrls is 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 with Attachments
{
  "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 with Blocks
{
  "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 with PreviewURLs
{
  "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"
  ]
}
Expand All
object
message
object Required

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.

t
string

The message type, for example e2e. A system message type, such as uj, fails.

rid
string Required

The room ID where the message is to be sent.

msg
string

The message text to send.

alias
string

The name to display on the message instead of your name. Your username is still displayed. Requires the message-impersonate permission.

emoji
string

An emoji to display as the message avatar.

avatar
string

The URL of an image to display as the message avatar. Requires the message-impersonate permission.

attachments
Array of object

An array of attachment objects with the following properties.

object
audio_url
string

Audio file to attach. See HTML audio element for information.

author_icon
string

Displays a tiny icon to the left of the author's name.

author_link
string

Providing this makes the author name clickable and points to this link.

author_name
string

Name of the author.

collapsed
boolean

Causes the image, audio, and video sections to be displayed as collapsed when set to true.

color
string

See background-css for the supported format.

fields
Array of object
object
short
boolean

Whether this field should be a short field.

title
string Required

The title of this field.

value
string Required

The value of this field, displayed underneath the title value.

image_url
string

The URL of the image to display in the attachment.

message_link
string

Only applicable if the ts parameter is provided, as it makes the time clickable to this link.

text
string

The text to display in the attachment.

thumb_url
string

The URL of a thumbnail image to display to the left of the attachment text.

title
string

Title to display for this attachment, displays under the author.

title_link
string

Providing this makes the title clickable, pointing to this link.

title_link_download
boolean

When this is true, a download icon appears and clicking this saves the link to file.

ts
string

Displays the time next to the text portion.

video_url
string

Video file to attach. See the HTML video element for information.

tmid
string

The ID of the message to reply to in a thread.

tshow
boolean

Set to true to also show the thread reply in the room. Requires tmid.

blocks
Array of object

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:

  • blocks is not an array of objects.
  • The elements of an actions or context block is missing or is not an array of objects.
  • The fields of a section block is not an array of objects.
  • An input block has no element object.
  • A linear_scale element has a non-numeric minValue or maxValue, or more than 100 points.
  • An appId contains 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.

object
type
string
text
object
type
string
text
string
fields
Array of object
object
type
string
text
string
customFields
object

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.

Example{ "priority": "high" }
_id
string

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.

ExampleKx7Pq2LmZr4TnB9vW
location
object

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.

Example{ "type": "Point", "coordinates": [ -46.6333, -23.5505 ] }
groupable
boolean

Set to false to show the message with its own header instead of grouping it with the sender's previous message.

Examplefalse
parseUrls
boolean

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.

Exampletrue
text
string

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.

ExampleHello from the API
e2e
string

The encryption state of an end-to-end encrypted message: pending or done.

Examplepending
e2eMentions
object

Mentions in an end-to-end encrypted message, as e2eUserMentions and e2eChannelMentions arrays.

Example{ "e2eUserMentions": [ "@john.doe" ], "e2eChannelMentions": [] }
content
object

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.

Example{ "algorithm": "rc.v2.aes-sha2", "ciphertext": "kTnW8xZq0r2YbPpL3sVd", "iv": "c2FtcGxlLWl2LXZhbHVl", "kid": "a1b2c3d4-kid" }
previewUrls
Array of string

The URLs in msg to preview.

string
Responses
200

OK

Example
{
  "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
}
Expand All
object
message
object
rid
string
msg
string
ts
string
u
object
_id
string
username
string
name
string
md
Array of object
object
mentions
Array of object
object
channels
Array of object
object
urls
Array of object
object
_updatedAt
string
_id
string
success
boolean
400

Bad Request

Missing Message
{
  "success": false,
  "error": "must have required property 'message'",
  "errorType": "error-invalid-params"
}
Thread Show Without Thread ID
{
  "success": false,
  "error": "tshow provided but missing tmid [invalid-params]",
  "errorType": "invalid-params",
  "details": {
    "method": "sendMessage"
  }
}
Missing Room ID
{
  "success": false,
  "error": "The 'rid' property on the message object is missing."
}
Invalid Room
{
  "success": false,
  "error": "error-invalid-room"
}
Unsupported Message Fields
{
  "success": false,
  "error": "The message fields cannot be set through 'chat.sendMessage': ts, u"
}
System Message Type
{
  "success": false,
  "error": "Cannot send system messages using 'chat.sendMessage'"
}
Invalid Blocks
{
  "success": false,
  "error": "must be array",
  "errorType": "error-invalid-params"
}
Invalid Block Item
{
  "success": false,
  "error": "must be object",
  "errorType": "error-invalid-params"
}
Missing Input Element
{
  "success": false,
  "error": "must have required property 'element'",
  "errorType": "error-invalid-params"
}
Linear Scale Not Numeric
{
  "success": false,
  "error": "Invalid blocks: blocks[0].elements[0] must have numeric minValue and maxValue"
}
Linear Scale Too Large
{
  "success": false,
  "error": "Invalid blocks: blocks[0].elements[0] cannot have more than 100 points"
}
Invalid App ID
{
  "success": false,
  "error": "Invalid blocks: blocks[0].appId must contain only letters, digits, \"-\" and \"_\""
}
Blocks Nested Too Deeply
{
  "success": false,
  "error": "Invalid blocks: blocks[0].d.a.a.a.a.a.a.a.a.a.a is nested too deeply"
}
Message Not an Object
{
  "success": false,
  "error": "must be object",
  "errorType": "error-invalid-params"
}
Missing Permission for Alias or Avatar
{
  "success": false,
  "error": "Not enough permission"
}
Invalid Attachment Field
{
  "success": false,
  "error": "Invalid attachment field, title and value is required"
}
Custom Fields Not Enabled
{
  "success": false,
  "error": "Custom fields not enabled"
}
Invalid Custom Fields
{
  "success": false,
  "error": "Invalid custom fields"
}
Expand All
object
success
boolean
error
string
errorType
string
details
object
method
string
401

Unauthorized

Authorization Error
{
  "success": false,
  "error": "You must be logged in to do this."
}
object
success
boolean
error
string