Get details about a user's thread read state Stay organized with collections Save and categorize content based on your preferences.
Page Summary
This guide explains how to use the
get()method to retrieve a user's read state within a Google Chat message thread using the Google Chat API.The
ThreadReadStateresource provides details about a user's last read message in a thread.To get the thread read state, you need a Google Workspace account, a configured Google Cloud project with the Google Chat API enabled, and the Node.js Cloud Client Library installed.
You must use the
chat.users.readstateorchat.users.readstate.readonlyauthorization scope and call theGetThreadReadState()method, specifying the thread read state's name.The API returns a
ThreadReadStateinstance containing the user's read state information.
This guide explains how to use theget()method on theThreadReadState resource of the Google Chat API to get detailsabout a user's read state within a message thread. To get the read state of amessage in a space, seeGet details about a user's space read state.
TheThreadReadState resourceis a singleton resource that represents details about aspecified user's last read message in a Google Chat message thread.
Prerequisites
Node.js
- A Business or EnterpriseGoogle Workspace account with access toGoogle Chat.
- Set up your environment:
- Create a Google Cloud project.
- Configure the OAuth consent screen.
- Enable and configure the Google Chat API with a name,icon, and description for your Chat app.
- Install the Node.js Cloud Client Library.
- Create OAuth client ID credentials for a desktop application. To run the sample in this guide, save the credentials as a JSON file named
credentials.jsonto your local directory.
- Choose an authorization scope that supports user authentication.
The code samples in this page use the gRPC API interface with the Google Cloud clientlibraries. Alternatively, you can use the REST API interface. For more information about the gRPCand REST interfaces, seeGoogle Chat API overview.
Get the calling user's thread read state
To get details about a user's read state within a message thread, include thefollowing in your request:
- Specify the
chat.users.readstateorchat.users.readstate.readonlyauthorization scope. - Call the
GetThreadReadState()method, passing thenameof the thread read state to get which includes auser ID or alias and a space ID. Getting thread read state only supportsgetting the read state of the calling user, which can be specified bysetting one of the following:- The
mealias. For example,users/me/spaces/SPACE/threads/THREAD/threadReadState. - The calling user's Workspace email address. For example,
users/user@example.com/spaces/SPACE/threads/THREAD/threadReadState. - The calling user's user ID. For example,
users/USER/spaces/SPACE/threads/THREAD/threadReadState.
- The
The following example gets the calling user's thread read state:
Node.js
import{createClientWithUserCredentials}from'./authentication-utils.js';constUSER_AUTH_OAUTH_SCOPES=['https://www.googleapis.com/auth/chat.users.readstate.readonly',];// This sample shows how to get the thread read state for a space and calling// userasyncfunctionmain(){// Create a clientconstchatClient=awaitcreateClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES,);// Initialize request argument(s)constrequest={// Replace SPACE_NAME and THREAD_NAME herename:'users/me/spaces/SPACE_NAME/threads/THREAD_NAME/threadReadState',};// Make the requestconstresponse=awaitchatClient.getThreadReadState(request);// Handle the responseconsole.log(response);}awaitmain();
To run this sample, replace the following:
SPACE_NAME: the ID from the space'sname.You can obtain the ID by calling theListSpaces()method or from the space's URL.THREAD_NAME: the ID from the thread'sname.You can obtain the ID from the response body returned after creating amessage asynchronously with the Chat API, or with thecustom nameassigned to the message at creation.
The Google Chat API gets the specified thread read state and returnsan instance ofThreadReadState.
Related topics
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.