> ## 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.
# Invite Users to Group
> Invite one user or bulk users to a private channel. Any of the following permissions are required:
* `add-user-to-joined-room`: This permission is required if you want to add users to the channel that you have joined.
* `add-user-to-any-p-room`: This permission is required to add users to any private channel.
You can identify the group by `roomId` or `roomName`, and the user(s) by `userId`, `username`, `userIds`, or `usernames`.
### Changelog
| Version | Description |
| ------- | ----------- |
| 0.48.0 | Added |
## OpenAPI
````json POST /api/v1/groups.invite
{
"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.invite": {
"post": {
"tags": [
"Groups"
],
"summary": "Invite Users to Group",
"description": "Invite one user or bulk users to a private channel. Any of the following permissions are required:\n* `add-user-to-joined-room`: This permission is required if you want to add users to the channel that you have joined.\n* `add-user-to-any-p-room`: This permission is required to add users to any private channel.\n\nYou can identify the group by `roomId` or `roomName`, and the user(s) by `userId`, `username`, `userIds`, or `usernames`.\n\n### Changelog\n| Version | Description |\n| ------- | ----------- |\n| 0.48.0 | Added |",
"operationId": "post-api-v1-groups.invite",
"parameters": [
{
"$ref": "#/components/parameters/Auth-Token"
},
{
"$ref": "#/components/parameters/UserId"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"roomId": {
"type": "string",
"description": "The group ID. This parameter is required if no `roomName` is provided. You can find the IDs by using any of the following endpoints:\n* Get List of User Groups: This endpoint returns all private channels in the workspace, if you have the required permissions to view them.\n* Get Groups: This endpoint returns the private channels that you are a member of.",
"example": "ByehQjC44FwMeiLbX"
},
"roomName": {
"type": "string",
"description": "The group name. This parameter is required if no `roomId` is provided.",
"example": "private-abc"
},
"userId": {
"type": "string",
"description": "The ID of the user to be invited. This parameter is required if no `username`, `userIds`, or `usernames` is provided.",
"example": "nSYqWzZ4GsKTX4dyK"
},
"username": {
"type": "string",
"description": "The username of the user to be invited. This parameter is required if no `userId`, `userIds`, or `usernames` is provided.",
"example": "john.doe"
},
"userIds": {
"type": "array",
"description": "An array of user IDs to invite. This parameter is required if no `userId`, `username`, or `usernames` is provided.",
"items": {
"type": "string"
},
"example": [
"nSYqWzZ4GsKTX4dyK",
"SYqWzZ4Gsasdfgh"
]
},
"usernames": {
"type": "array",
"description": "An array of usernames to invite. This parameter is required if no `userId`, `username`, or `userIds` is provided.",
"items": {
"type": "string"
},
"example": [
"john.doe",
"jane.doe"
]
}
}
},
"examples": {
"Invite by IDs": {
"value": {
"roomId": "ByehQjC44FwMeiLbX",
"userId": "nSYqWzZ4GsKTX4dyK"
}
},
"Invite by names": {
"value": {
"roomName": "private-abc",
"username": "john.doe"
}
},
"Invite multiple users by ID": {
"value": {
"roomId": "ByehQjC44FwMeiLbX",
"userIds": [
"nSYqWzZ4GsKTX4dyK",
"SYqWzZ4Gsasdfgh"
]
}
},
"Invite multiple users by username": {
"value": {
"roomName": "private-abc",
"usernames": [
"john.doe",
"jane.doe"
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"group": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"ts": {
"type": "string"
},
"t": {
"type": "string"
},
"name": {
"type": "string"
},
"usernames": {
"type": "array",
"items": {
"type": "string"
}
},
"u": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"msgs": {
"type": "integer"
},
"_updatedAt": {
"type": "string"
},
"lm": {
"type": "string"
}
}
},
"success": {
"type": "boolean"
}
}
},
"examples": {
"Success": {
"value": {
"group": {
"_id": "ByehQjC44FwMeiLbX",
"ts": "2016-11-30T21:23:04.737Z",
"t": "p",
"name": "testing",
"usernames": [
"testing",
"testing1"
],
"u": {
"_id": "aobEdbYhXfu5hkeqG",
"username": "testing1"
},
"msgs": 1,
"_updatedAt": "2016-12-09T12:50:51.575Z",
"lm": "2016-12-09T12:50:51.555Z"
},
"success": true
}
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
},
"errorType": {
"type": "string"
},
"details": {
"type": "object",
"properties": {
"method": {
"type": "string"
}
}
}
}
},
"examples": {
"Room parameter required": {
"value": {
"success": false,
"error": "The parameter \"roomId\" or \"roomName\" is required [error-room-param-not-provided]",
"errorType": "error-room-param-not-provided"
}
},
"User parameter required": {
"value": {
"success": false,
"error": "Please provide \"userId\" or \"username\" or \"userIds\" or \"usernames\" as param [error-users-params-not-provided]",
"errorType": "error-users-params-not-provided"
}
},
"Permission required": {
"value": {
"success": false,
"error": "Not allowed [error-not-allowed]",
"errorType": "error-not-allowed",
"details": {
"method": "addUsersToRoom"
}
}
}
}
}
}
},
"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": {
"status": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"examples": {
"Authorization Error": {
"value": {
"status": "error",
"message": "You must be logged in to do this."
}
}
}
}
}
}
}
}
}
````