Method: spaces.create
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างพื้นที่ทำงาน ใช้เพื่อสร้างพื้นที่ทำงานที่มีชื่อหรือแชทกลุ่มใน Import mode
ได้ ดูตัวอย่างได้ที่สร้างพื้นที่ทำงาน
รองรับการตรวจสอบสิทธิ์ประเภทต่อไปนี้
เมื่อตรวจสอบสิทธิ์ในฐานะแอป จะต้องตั้งค่าฟิลด์ 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
URL ใช้ไวยากรณ์การแปลงรหัส gRPC
พารามิเตอร์การค้นหา
พารามิเตอร์ |
requestId |
string
ไม่บังคับ ตัวระบุที่ไม่ซ้ำกันสำหรับคำขอนี้ ขอแนะนำให้ใช้ UUID แบบสุ่ม การระบุรหัสคำขอที่มีอยู่จะแสดงพื้นที่ทำงานที่สร้างด้วยรหัสนั้นแทนที่จะสร้างพื้นที่ทำงานใหม่ การระบุรหัสคำขอที่มีอยู่จากแอป Chat เดียวกันกับผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์รายอื่นจะทำให้เกิดข้อผิดพลาด
|
เนื้อความของคำขอ
เนื้อความของคำขอมีอินสแตนซ์ของ 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
ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-29 UTC
[null,null,["อัปเดตล่าสุด 2025-07-29 UTC"],[[["\u003cp\u003eCreates a space in Google Chat, which can be a named space or a group chat, supporting app and user authentication.\u003c/p\u003e\n"],["\u003cp\u003eWhen using app authentication, the space.customer field is required and no members are added in Import mode; otherwise, the calling user becomes a member.\u003c/p\u003e\n"],["\u003cp\u003eUses the \u003ccode\u003ePOST https://chat.googleapis.com/v1/spaces\u003c/code\u003e HTTP request to create a space and requires specific OAuth scopes for authorization.\u003c/p\u003e\n"],["\u003cp\u003eThe request body should contain a Space object and the response, if successful, will contain the newly created Space object.\u003c/p\u003e\n"],["\u003cp\u003eIf the displayName already exists, an \u003ccode\u003eALREADY_EXISTS\u003c/code\u003e error will be returned, suggesting to try a different displayName.\u003c/p\u003e\n"]]],["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"],null,["# Method: spaces.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nCreates a space. Can be used to create a named space, or a group chat in `Import mode`. For an example, see [Create a space](https://developers.google.com/workspace/chat/create-spaces).\n\nSupports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):\n\n- [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with [administrator approval](https://support.google.com/a?p=chat-app-auth) and one of the following authorization scopes:\n\n - `https://www.googleapis.com/auth/chat.app.spaces.create`\n - `https://www.googleapis.com/auth/chat.app.spaces`\n- [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following authorization scopes:\n\n - `https://www.googleapis.com/auth/chat.spaces.create`\n - `https://www.googleapis.com/auth/chat.spaces`\n - `https://www.googleapis.com/auth/chat.import` (import mode spaces only)\n\nWhen authenticating as an app, the `space.customer` field must be set in the request.\n\nWhen authenticating as an app, the Chat app is added as a member of the space. However, unlike human authentication, the Chat app is not added as a space manager. By default, the Chat app can be removed from the space by all space members. To allow only space managers to remove the app from a space, set `space.permission_settings.manage_apps` to `managersAllowed`.\n\nSpace membership upon creation depends on whether the space is created in `Import mode`:\n\n- **Import mode:** No members are created.\n- **All other modes:** The calling user is added as a member. This is:\n - The app itself when using app authentication.\n - The human user when using user authentication.\n\nIf you receive the error message `ALREADY_EXISTS` when creating a space, try a different `displayName`. An existing space within the Google Workspace organization might already use this display name.\n\n### HTTP request\n\n`POST https://chat.googleapis.com/v1/spaces`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Query parameters\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `requestId` | `string` Optional. A unique identifier for this request. A random UUID is recommended. Specifying an existing request ID returns the space created with that ID instead of creating a new space. Specifying an existing request ID from the same Chat app with a different authenticated user returns an error. |\n\n### Request body\n\nThe request body contains an instance of [Space](/workspace/chat/api/reference/rest/v1/spaces#Space).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Space](/workspace/chat/api/reference/rest/v1/spaces#Space).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/chat.app.spaces.create`\n- `https://www.googleapis.com/auth/chat.app.spaces`\n- `https://www.googleapis.com/auth/chat.import`\n- `https://www.googleapis.com/auth/chat.spaces`\n- `https://www.googleapis.com/auth/chat.spaces.create`\n\nFor more information, see the [Authorization guide](/workspace/chat/authenticate-authorize)."]]