Add User to a Group

Table of Contents

Overview

The zoho.directory.addUserToGroup task is used to add a user to a specified group in an organization.

Syntax

<response> = zoho.directory.addUserToGroup(<orgID>, <groupID>, <userData>, <connection>);

Scope

ZohoDirectory.Groups.CREATE, ZohoDirectory.Groups.UPDATE

where:

ParameterDescriptionData type
responseis the variable that will hold the details of the user that need to be added to the specified group.KEY-VALUE
<orgID>is the ID of the organization to which the user needs to be added.NUMBER
<groupID>is the ID of the group to which the user needs to be added.NUMBER
<userData>

is the variable that will hold the user data like user ID and role to be added.

user_id :

  • NUMBER

member_role :

  • NUMBER 
KEY-VALUE
<connection>is the name of the Zoho Directory connection.TEXT

Example

The following script adds a user with ID - 1510XXXXXXXX to a specified group with ID - 68XXXXXXX  in Zoho Directory organization with ID - 72XXXXXXX:

userData = Map();
userData.put("user_id",1510XXXXXXXX);
userData.put("member_role", 0);
response = zoho.directory.addUserToGroup(72XXXXXXX, 68XXXXXXX ,userData, "zoho_directory_connection")

where:

response
This is the KEY-VALUEresponse returned by Zoho Directory.
72XXXXXXX
This is the NUMBERthat represents the organization ID of Zoho Directory account.
zoho_directory_connection
This is the TEXTthat represents the link name of the connection.
68XXXXXXX
This is the NUMBERthat represents the group ID to which the user needs to be added.
"member_role", 0
This is the VALUEthat represents the role of user. 0 is for members, and 2 is for moderators.

Response format

{
  "status_code": 201,
  "members": {
    "result": {
       "$zgid": {
          "failed_userlist": [],
          "existing_users": ["1511**********"],
          "success_userlist": [],
          "updated_users": []
      }
   },
 "href": "https://directory.zoho.com/api/v1/orgs/72*******/groups/68*******/members/1510*********"
 },
 "resource_name": "members",
 "message": "Success"
}