Method: spaces.create
创建聊天室。可用于在 Import mode
中创建命名聊天室或群聊。如需查看示例,请参阅创建聊天室。
支持以下类型的身份验证:
以应用身份进行身份验证时,必须在请求中设置 space.customer
字段。
聊天室在创建时的成员资格取决于聊天室是在 Import mode
中创建的:
- 导入模式:系统不会创建任何成员。
- 所有其他模式:系统会将发起通话的用户添加为成员。具体如下:
- 使用应用身份验证时,应用本身。
- 使用用户身份验证时的人为用户。
如果您在创建聊天室时收到错误消息 ALREADY_EXISTS
,请尝试使用其他 displayName
。Google Workspace 组织中现有的聊天室可能已使用此显示名称。
HTTP 请求
POST https://chat.googleapis.com/v1/spaces
网址采用 gRPC 转码语法。
查询参数
参数 |
requestId |
string
可选。此请求的唯一标识符。建议使用随机 UUID。指定现有请求 ID 会返回使用该 ID 创建的聊天室,而不是创建新的聊天室。使用其他经过身份验证的用户指定同一 Chat 应用中的现有请求 ID 会返回错误。
|
响应正文
如果成功,响应正文将包含一个新创建的 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
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-02。
[null,null,["最后更新时间 (UTC):2024-12-02。"],[[["Creates a space in Google Chat, which can be a named space or a group chat, supporting app and user authentication."],["When using app authentication, the space.customer field is required and no members are added in Import mode; otherwise, the calling user becomes a member."],["Uses the `POST https://chat.googleapis.com/v1/spaces` HTTP request to create a space and requires specific OAuth scopes for authorization."],["The request body should contain a Space object and the response, if successful, will contain the newly created Space object."],["If the displayName already exists, an `ALREADY_EXISTS` error will be returned, suggesting to try a different displayName."]]],["This content outlines how to create a space using the Chat API. Key actions include sending a `POST` request to `https://chat.googleapis.com/v1/spaces`. The request may include a unique `requestId` and must contain a `Space` instance in the body. Authentication can be app-based or user-based, requiring specific OAuth scopes. Space membership varies by import mode; no members in import mode, otherwise the caller is added. Response will contain new space information.\n"]]