Method: spaces.setup

Stay organized with collections Save and categorize content based on your preferences.

Creates a space and adds users to it. If users can't be added directly, sends them invitations to join. Spaces with threaded replies, and spaces with guest access are not supported.

Requires user authentication and the chat.spaces.create 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.SPACE and Space.displayName.

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

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

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

requestId

string

Optional. A unique identifier for this request. A random UUID is recommended. This request is only idempotent if a requestId is provided or if the DM already exists. Specifying an existing value for requestId from the same Chat app with a different authenticated user returns an error.

memberships[]

object (Membership)

Optional. The initial set of in-domain users or groups invited to join the space.

The set currently allows 20 memberships maximum.

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

Required for Space.spaceType.SPACE, along with at least one membership.

Required for Space.spaceType.GROUP_CHAT, along with at least two memberships.

Required for Space.spaceType.DIRECT_MESSAGE with a human user, along with exactly one membership.

Not supported: Inviting out-of-domain users, or adding other Chat apps.

Response body

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

Authorization Scopes

Requires the following OAuth scope:

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

For more information, see the Authorization guide.