Stay organized with collections Save and categorize content based on your preferences.
Creates a message in a Google Chat space. For an example, see Send a message.
Supports the following types of authentication:
https://www.googleapis.com/auth/chat.bot
https://www.googleapis.com/auth/chat.messages.create
https://www.googleapis.com/auth/chat.messages
https://www.googleapis.com/auth/chat.import
(import mode spaces only)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.
For webhook requests, the response doesn't contain the full message. The response only populates the name
and thread.name
fields in addition to the information that was in the request.
POST https://chat.googleapis.com/v1/{parent=spaces/*}/messages
The URL uses gRPC Transcoding syntax.
Path parameters Parametersparent
string
Required. The resource name of the space in which to create a message.
Format: spaces/{space}
threadKey
(deprecated)
string
Optional. Deprecated: Use thread.thread_key
instead. ID for the thread. Supports up to 4000 characters. To start or add to a thread, create a message and specify a threadKey
or the thread.name
. For example usage, see Start or reply to a message thread.
requestId
string
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
enum (
MessageReplyOption
)
Optional. Specifies whether a message starts a thread or replies to one. Only supported in named spaces.
When responding to user interactions, this field is ignored. For interactions within a thread, the reply is created in the same thread. Otherwise, the reply is created as a new thread.
messageId
string
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 name
field).
The value for this field must meet the following requirements:
client-
. For example, client-custom-name
is a valid custom ID, but custom-name
is not.For details, see Name a message.
Request bodyThe request body contains an instance of Message
.
If successful, the response body contains a newly created instance of Message
.
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.
MessageReplyOptionSpecifies how to reply to a message. More states might be added in the future.
EnumsMESSAGE_REPLY_OPTION_UNSPECIFIED
Default. Starts a new thread. Using this option ignores any thread ID
or threadKey
that's included. REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD
Creates the message as a reply to the thread specified by thread ID
or threadKey
. 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 threadKey
. If a new threadKey
is used, a new thread is created. If the message creation fails, a NOT_FOUND
error is returned instead.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-07 UTC."],[[["Creates a message in a Google Chat space, attributing it to the Chat app or user based on authentication."],["Supports sending text, cards, and widgets using app authentication, while user authentication only allows text."],["Offers different message reply options for starting new threads or replying within existing ones."],["Requires specific authorization scopes for the request, such as `chat.bot` or `chat.messages`."],["Provides a way to name a message with a custom ID for easy retrieval and management within a space."]]],["This document outlines the process for creating messages in Google Chat spaces via the `create()` method, using either user or app authentication. Messages can include text, cards, and widgets, with a maximum size of 32,000 bytes. The process involves a POST request to a specified URL with path parameters for the space and query parameters like `threadKey`, `requestId`, `messageReplyOption` and `messageId`. The request body defines the message content, and the successful response returns the new message details. It also specifies the required OAuth scopes.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4