Method: spaces.create

创建聊天室。可用于在 Import mode 中创建命名空间或群聊。如需查看示例,请参阅创建聊天室

支持以下类型的身份验证

  • 应用身份验证,需要获得管理员批准,并使用以下授权范围之一:

    • https://www.googleapis.com/auth/chat.app.spaces.create
    • https://www.googleapis.com/auth/chat.app.spaces
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.spaces.create
    • https://www.googleapis.com/auth/chat.spaces
    • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)

以应用身份进行身份验证时,必须在请求中设置 space.customer 字段。

以应用身份进行身份验证时,Chat 应用会添加为聊天室的成员。不过,与人工身份验证不同的是,Chat 应用不会作为聊天室管理员添加。默认情况下,所有聊天室成员都可以从聊天室中移除 Chat 应用。如需仅允许聊天室管理员从聊天室中移除应用,请将 space.permission_settings.manage_apps 设置为 managersAllowed

创建聊天室时的成员资格取决于聊天室是否在 Import mode 中创建:

  • 导入模式:不创建任何成员。
  • 所有其他模式:将调用用户添加为成员。这是:
    • 使用应用身份验证时的应用本身。
    • 使用用户身份验证时的人类用户。

如果您在创建聊天室时收到 ALREADY_EXISTS 错误消息,请尝试使用其他 displayName。Google Workspace 组织内的现有聊天室可能已使用此显示名称。

HTTP 请求

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

网址采用 gRPC 转码语法。

查询参数

参数
requestId

string

可选。相应请求的唯一标识符。建议使用随机 UUID。指定现有请求 ID 会返回使用该 ID 创建的聊天室,而不是创建新聊天室。如果指定同一 Chat 应用中具有不同已验证用户的现有请求 ID,则会返回错误。

请求正文

请求正文包含一个 Space 实例。

响应正文

如果成功,响应正文将包含一个新创建的 Space 实例。

授权范围

需要以下 OAuth 范围之一:

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

如需了解详情,请参阅授权指南