> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.
# Create Group
> Create a new private channel, optionally including specified users. Refer to the Channels documents for information on the available room options.
The following permissions are required:
* `create-p`: This permission is required to create a private channel.
* `create-team-group`: This permission is required if you want to create a private channel from an existing team.
### Changelog
| Version | Description |
| ------- | ------------------------------------------------------------------------------------------- |
| 8.8.0 | Added support for enforcing end-to-end encryption when creating private rooms. |
| 6.4.1 | Added `excludeSelf` param |
| 0.35.0 | Added |
## OpenAPI
````json POST /api/v1/groups.create
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Rooms"
},
"servers": [
{
"url": "https://apiexplorer.support.rocket.chat"
}
],
"tags": [
{
"name": "Channels"
},
{
"name": "Directory"
},
{
"name": "Groups"
},
{
"name": "Rooms"
},
{
"name": "Teams"
},
{
"name": "Room Invites"
},
{
"name": "Subscriptions"
},
{
"name": "ABAC"
}
],
"paths": {
"/api/v1/groups.create": {
"post": {
"tags": [
"Groups"
],
"summary": "Create Group",
"description": "Create a new private channel, optionally including specified users. Refer to the Channels documents for information on the available room options.\n\nThe following permissions are required:\n* `create-p`: This permission is required to create a private channel.\n* `create-team-group`: This permission is required if you want to create a private channel from an existing team.\n\n### Changelog\n| Version | Description |\n| ------- | ------------------------------------------------------------------------------------------- |\n| 8.8.0 | Added support for enforcing end-to-end encryption when creating private rooms. |\n| 6.4.1 | Added `excludeSelf` param |\n| 0.35.0 | Added |",
"operationId": "post-api-v1-groups.create",
"parameters": [
{
"$ref": "#/components/parameters/Auth-Token"
},
{
"$ref": "#/components/parameters/UserId"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the new private group.",
"example": "groupname"
},
"readOnly": {
"type": "boolean",
"description": "Set if the private channel is read-only or not. The default value is false.",
"example": false
},
"members": {
"type": "array",
"description": "The users to add to the private channel when it is created.",
"items": {
"type": "string",
"example": "rocket.cat"
}
},
"excludeSelf": {
"type": "boolean",
"description": "If set to true, the user calling the endpoint is not added as a member of the private channel. The default value is false.",
"example": false
},
"customFields": {
"type": "object",
"description": "You add custom fields for private rooms using this parameter. Enter the key and value that you want to associate with this room. For example, `{ \"company\": \"sell-and-more\" }`. The custom fields are not displayed in the workspace UI."
},
"extraData": {
"type": "object",
"description": "Enter the following details for the object:\n\nNote: For more information, see Channels.",
"properties": {
"broadcast": {
"type": "boolean",
"description": "Whether the group should be a broadcast group. False by default."
},
"encrypted": {
"type": "boolean",
"description": "Whether the private room should use end-to-end encryption. When **Force end-to-end encryption on private rooms** is enabled, omit this field or set it to `true`. Setting it to `false` returns the `error-encrypted-private-rooms-enforced` error. Federated private rooms are exempt from this policy."
},
"teamId": {
"type": "string",
"description": "Enter the team ID for which you want to create a group. You will get an error if the team does not exist."
}
}
}
},
"required": [
"name"
]
},
"examples": {
"Example": {
"value": {
"name": "groupname",
"members": [
"rocket.cat"
],
"readOnly": true,
"excludeSelf": true,
"customFields": {
"type": "default"
},
"extraData": {
"broadcast": true,
"encrypted": true,
"teamId": "658441562dd9f928ad9951aa"
}
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"group": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"name": {
"type": "string"
},
"t": {
"type": "string"
},
"msgs": {
"type": "integer"
},
"u": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"ts": {
"type": "string"
},
"ro": {
"type": "boolean"
},
"sysMes": {
"type": "boolean"
},
"_updatedAt": {
"type": "string"
}
}
},
"success": {
"type": "boolean"
}
}
},
"examples": {
"Success": {
"value": {
"group": {
"_id": "NtR6RQ7NvzA9ejecX",
"name": "testing",
"t": "p",
"msgs": 0,
"u": {
"_id": "aobEdbYhXfu5hkeqG",
"username": "tester"
},
"ts": "2016-12-09T16:53:06.761Z",
"ro": false,
"sysMes": true,
"_updatedAt": "2016-12-09T16:53:06.761Z"
},
"success": true
}
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
},
"errorType": {
"type": "string"
}
}
},
"examples": {
"Name is required": {
"value": {
"success": false,
"error": "Body param \"name\" is required"
}
},
"Private room encryption is enforced": {
"value": {
"success": false,
"error": "Workspace policy requires all private rooms to be encrypted. [error-encrypted-private-rooms-enforced]",
"errorType": "error-encrypted-private-rooms-enforced"
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/authorizationError"
}
}
}
}
},
"components": {
"parameters": {
"Auth-Token": {
"name": "X-Auth-Token",
"in": "header",
"description": "The `authToken` of the authenticated user.",
"required": true,
"schema": {
"type": "string"
},
"example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
},
"UserId": {
"name": "X-User-Id",
"in": "header",
"description": "The `userId` of the authenticated user.",
"required": true,
"schema": {
"type": "string"
},
"example": "rbAXPnMktTFbNpwtJ"
}
},
"responses": {
"authorizationError": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
}
}
},
"examples": {
"Authorization Error": {
"value": {
"success": false,
"error": "You must be logged in to do this."
}
}
}
}
}
}
}
}
}
````