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
選用設定。此要求的專屬 ID。建議使用隨機 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
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-02-27 (世界標準時間)。
[null,null,["上次更新時間:2025-02-27 (世界標準時間)。"],[[["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"]]