- HTTP request
- Path parameters
- Query parameters
- Request body
- Response body
- Authorization scopes
- MessageReplyOption
- Try it!
Creates a message in a Google Chat space. For an example, see Send a message.
The create()
method requires either user authentication or app authentication. Chat attributes the message sender differently depending on the type of authentication that you use in your request.
The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (text
), cards (cardsV2
), and accessory widgets (accessoryWidgets
).
The following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (text
).
The maximum message size, including the message contents, is 32,000 bytes.
HTTP request
POST https://chat.googleapis.com/v1/{parent=spaces/*}/messages
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
parent |
Required. The resource name of the space in which to create a message. Format: |
Query parameters
Parameters | |
---|---|
threadKey |
Optional. Deprecated: Use |
requestId |
Optional. A unique request ID for this message. Specifying an existing request ID returns the message created with that ID instead of creating a new message. |
messageReplyOption |
Optional. Specifies whether a message starts a thread or replies to one. Only supported in named spaces. |
messageId |
Optional. A custom ID for a message. Lets Chat apps get, update, or delete a message without needing to store the system-assigned ID in the message's resource name (represented in the message The value for this field must meet the following requirements:
For details, see Name a message. |
Request body
The request body contains an instance of Message
.
Response body
If successful, the response body contains a newly created instance of Message
.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/chat.bot
https://www.googleapis.com/auth/chat.import
https://www.googleapis.com/auth/chat.messages
https://www.googleapis.com/auth/chat.messages.create
For more information, see the Authorization guide.
MessageReplyOption
Specifies how to reply to a message. More states might be added in the future.
Enums | |
---|---|
MESSAGE_REPLY_OPTION_UNSPECIFIED |
Default. Starts a new thread. Using this option ignores any thread ID or that's included. |
REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD |
Creates the message as a reply to the thread specified by thread ID or . If it fails, the message starts a new thread instead. |
REPLY_MESSAGE_OR_FAIL |
Creates the message as a reply to the thread specified by thread ID or . If a new threadKey is used, a new thread is created. If the message creation fails, a NOT_FOUND error is returned instead. |