- HTTP request
- Path parameters
- Request body
- Response body
- Authorization scopes
- SearchMessagesView
- SearchMessageResult
- Try it!
Searches for messages in Google Chat that the calling user has access to. Returns a list of messages matching the search criteria.
To search across all spaces the user has access to, set parent to spaces/-. Using any other value for parent results in an INVALID_ARGUMENT error. The returned messages have their name field populated with the full resource name, which includes the specific space in which the message resides.
This API doesn't return all message types. The types of messages listed below aren't included in the response. Use messages.list to list all messages.
- Private Messages that are visible to the authenticated user.
- Messages posted by Chat apps in spaces or group chats.
- Messages in a Chat app DM.
- Messages from blocked users.
- Messages in spaces that the caller has muted.
Requires user authentication with one of the following authorization scopes:
https://www.googleapis.com/auth/chat.messages.readonlyhttps://www.googleapis.com/auth/chat.messages
HTTP request
POST https://chat.googleapis.com/v1/{parent=spaces/*}/messages:search
The URL uses gRPC Transcoding syntax.
Path parameters
| Parameters | |
|---|---|
parent |
Required. The resource name of the space to search within. To search across all spaces the user has access to, set this field to To limit the search to one or more spaces, use |
Request body
The request body contains data with the following structure:
| JSON representation |
|---|
{
"filter": string,
"pageSize": integer,
"pageToken": string,
"orderBy": string,
"view": enum ( |
| Fields | |
|---|---|
filter |
Required. A search query. The query can specify one or more search keywords, which are used to filter the results, You can also filter the results using the following message fields:
For advanced filtering, the following functions are also available:
Using the
Using the
Across different fields, only Among the same field:
Parentheses are required to disambiguate operator precedence when combining The following example queries are valid: The maximum query length is 1,000 characters. Invalid queries are rejected by the server with an |
pageSize |
Optional. The maximum number of results to return. The service may return fewer than this value. If unspecified, at most 25 are returned. The maximum value is 100. If you use a value more than 100, it's automatically changed to 100. |
pageToken |
Optional. A token, received from the previous search messages call. Provide this parameter to retrieve the subsequent page. When paginating, all other parameters provided should match the call that provided the page token. Passing different values to the other parameters might lead to unexpected results. |
orderBy |
Optional. How the results list is ordered. Supported attributes to order by are:
The default ordering is |
view |
Optional. Specifies what kind of search results view to return. The default is |
Response body
Response message for searching messages.
If successful, the response body contains data with the following structure:
| JSON representation |
|---|
{
"results": [
{
object ( |
| Fields | |
|---|---|
results[] |
The list of search results that matched the query. |
nextPageToken |
A token that can be used to retrieve the next page. If this field is empty, there are no subsequent pages. |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.messages.readonly
For more information, see the Authorization guide.
SearchMessagesView
The kinds of view that are supported for partial search results.
| Enums | |
|---|---|
SEARCH_MESSAGES_VIEW_UNSPECIFIED |
The default / unset value. The API will default to the BASIC view. |
SEARCH_MESSAGES_VIEW_BASIC |
Includes only the matched messages in the results, but no additional metadata. This is the default value. |
SEARCH_MESSAGES_VIEW_FULL |
Includes everything in the results: the matched messages and additional metadata. |
SearchMessageResult
A single result item from a message search.
| JSON representation |
|---|
{ "message": { object ( |
| Fields | |
|---|---|
message |
The matched message. |
spaceMuteSetting |
The mute setting of the calling user for the space where the message is posted. The caller app can use this information to decide how to process the message depending on whether the space is muted for the user or not. Only returned if the request view is
|
read |
Indicates if the matched message is read by the calling user. Only returned if the request view is
|