建立聊天室。可用於在 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 | 
 (選用步驟) 這項要求的專屬 ID。建議使用隨機 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
詳情請參閱授權指南。