The Admin SDK Directory service allows you to use the Admin SDK's
Directory API
in Apps Script. This API gives
administrators of Google Workspace domains (including
resellers) the ability to
manage devices, groups, users, and other entities in their domains.
Reference
For detailed information on this service, see the
reference documentation
for the Admin SDK
Directory API. Like all advanced services in Apps Script, the Admin SDK
Directory service uses the same objects, methods, and parameters as the public
API. For more information, see
How method signatures are determined
.
To report issues and find other support, see the
Admin SDK Directory support guide
.
Sample code
The sample code below uses
version 1
of
the API.
List all users
This sample lists all the users in a domain sorted by first name.
Get user
This sample gets a user by their email address and logs all of their data as a
JSON string.
Add user
This sample adds a new user to the domain, including only the required
information. For the full list of user fields, see the API's
reference documentation
.
Create alias
This sample creates an alias (nickname) for a user.
List all groups
This sample lists all the groups in the domain.
Add group member
This sample adds a user to an existing group in the domain.