Make a Google Chat space discoverable to specific users in a Google Workspace organization

This page explains how to use the Google Chat API to share a Google Chat space with specific users in a Google Workspace organization, so that they can discover and join the space.

To specify the users in your organization that can discover and join a space, you create target audiences. A target audience is a group of people—such as specific departments or the entire organization—that you can share a Chat space with, to improve the space's awareness and shareability. Target audiences also let you manage and customize space memberships rather than needing to invite individual users to a space. For more information, see About target audiences.

You can only make named spaces discoverable to target audiences. You can't share other space types, such as direct messages or group conversations, with target audiences.

Prerequisites

Get the target audience ID

To get the ID of a target audience, do the following:

  1. In the Google Admin console, go to Menu > Directory > Target audiences.

    Go to Target audiences

  2. In the Target audiences table, click the Name field of the target audience.

  3. Find the target audience ID in the URL for the page. The URL format is https://admin.google.com/ac/targetaudiences/TARGET_AUDIENCE_ID, where TARGET_AUDIENCE_ID is the alphanumeric ID for your target audience.

In the next section, you use the target audience ID to either create a discoverable space or update an existing space to make it discoverable to the target audience.

Specify the target audience in your Chat API request

To create a space for a specific target audience, use the create() or setup() method on the Space resource. To make an existing space discoverable, use the update() method on the Space resource. Because only named spaces can be shared with target audiences, the space type (represented in the spaceType field) must be SPACE.

To make a space discoverable to your target audience, include the AccessSettings object in the Space resource as part of your Chat API request. In the object, specify audience field:

  "accessSettings": {
    "audience": "audiences/TARGET_AUDIENCE_ID"
  }

Replace TARGET_AUDIENCE_ID with the ID of the target audience that you obtained in the previous section. To use the default Chat space share settings for your Google Workspace organization, replace with default.

For details on creating or updating spaces using the Chat API, see the following guides: