Method: spaces.setup

Creates a space and adds specified users to it. The calling user is automatically added to the space, and shouldn't be specified as a membership in the request. For an example, see Set up a space.

To specify the human members to add, add memberships with the appropriate member.name in the SetUpSpaceRequest. To add a human user, use users/{user}, where {user} is either the {person_id} for the person from the People API, or the id for the user in the Admin SDK Directory API. For example, if the People API Person resourceName is people/123456789, you can add the user to the space by including a membership with users/123456789 as the member.name.

For a space or group chat, if the caller blocks or is blocked by some members, then those members aren't added to the created space.

To create a direct message (DM) between the calling user and another human user, specify exactly one membership to represent the human user. If one user blocks the other, the request fails and the DM isn't created.

To create a DM between the calling user and the calling app, set Space.singleUserBotDm to true and don't specify any memberships. You can only use this method to set up a DM with the calling app. To add the calling app as a member of a space or an existing DM between two human users, see create a membership.

If a DM already exists between two users, even when one user blocks the other at the time a request is made, then the existing DM is returned.

Spaces with threaded replies or guest access aren't supported.

Requires user authentication and the chat.spaces.create or chat.spaces scope.

HTTP request

POST https://chat.googleapis.com/v1/spaces:setup

The URL uses gRPC Transcoding syntax.

Request body

The request body contains data with the following structure:

JSON representation
{
  "space": {
    object (Space)
  },
  "requestId": string,
  "memberships": [
    {
      object (Membership)
    }
  ]
}
Fields
space

object (Space)

Required. The Space.spaceType field is required.

To create a space, set Space.spaceType to SPACE and set Space.displayName.

To create a group chat, set Space.spaceType to GROUP_CHAT. Don't set Space.displayName.

To create a 1:1 conversation between humans, set Space.spaceType to DIRECT_MESSAGE and set Space.singleUserBotDm to false. Don't set Space.displayName or Space.spaceDetails.

To create an 1:1 conversation between a human and the calling Chat app, set Space.spaceType to DIRECT_MESSAGE and Space.singleUserBotDm to true. Don't set Space.displayName or Space.spaceDetails.

If a DIRECT_MESSAGE space already exists, that space is returned instead of creating a new space.

requestId

string

Optional. A unique identifier for this request. A random UUID is recommended. Specifying an existing request ID returns the space created with that ID instead of creating a new space. Specifying an existing request ID from the same Chat app with a different authenticated user returns an error.

memberships[]

object (Membership)

Optional. The initial set of in-domain users invited to join the space. The calling user is automatically added to the space, and shouldn't be specified as a membership.

The set currently allows up to 20 memberships (in addition to the caller).

The Membership.member field must contain a user with name populated and User.Type.HUMAN. All other fields are ignored.

Optional when setting Space.spaceType to SPACE.

Required when setting Space.spaceType to GROUP_CHAT, along with at least two memberships.

Required when setting Space.spaceType to DIRECT_MESSAGE with a human user, along with exactly one membership.

Must be empty when creating a 1:1 conversation between a human and the calling Chat app (when setting Space.spaceType to DIRECT_MESSAGE and Space.singleUserBotDm to true).

Not supported: Inviting guest users, or adding other Chat apps.

Response body

If successful, the response body contains an instance of Space.

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.create

For more information, see the Authorization guide.