Skip to main content

Overview

The Admin SDK Directory API allows Google Workspace administrators to manage users, groups, organizational units, devices, and other domain resources. API Name: admin
Version: directory_v1
Official Documentation: Admin SDK Reference

Common Resources

Users

Manage user accounts in your domain.
userKey
string
required
The user’s primary email address, alias, or unique ID
domain
string
The domain name (for listing users)
maxResults
integer
Maximum number of results per page (default: 100, max: 500)

Groups

Manage groups and group memberships.
groupKey
string
required
The group’s email address, alias, or unique ID
domain
string
The domain name

Organizational Units

Manage organizational structure.
customerId
string
required
Unique customer ID or my_customer for your domain
orgUnitPath
string
Full path of the organizational unit

Common Methods

List Users

gws admin users list --params '{
  "domain": "example.com",
  "maxResults": 50
}'
users
array
Array of user objects
id
string
Unique user ID
primaryEmail
string
User’s primary email address
name
object
User’s name (givenName, familyName)
orgUnitPath
string
User’s organizational unit

Get User

gws admin users get --params '{
  "userKey": "alice@example.com"
}'

Create User

gws admin users insert --json '{
  "primaryEmail": "newuser@example.com",
  "name": {
    "givenName": "New",
    "familyName": "User"
  },
  "password": "TempPassword123!"
}'

Update User

gws admin users update \
  --params '{"userKey": "alice@example.com"}' \
  --json '{
    "name": {
      "givenName": "Alice",
      "familyName": "Johnson"
    },
    "orgUnitPath": "/Engineering"
  }'

Delete User

gws admin users delete --params '{
  "userKey": "olduser@example.com"
}'

Group Management

gws admin groups list --params '{
  "domain": "example.com",
  "maxResults": 100
}'

Device Management

gws admin chromeosdevices list --params '{
  "customerId": "my_customer",
  "maxResults": 50
}'

Organizational Units

# List OUs
gws admin orgunits list --params '{
  "customerId": "my_customer"
}'

# Create OU
gws admin orgunits insert \
  --params '{"customerId": "my_customer"}' \
  --json '{
    "name": "Sales",
    "parentOrgUnitPath": "/",
    "description": "Sales department"
  }'

Response Format

List users response:
{
  "users": [
    {
      "id": "12345678901234567890",
      "primaryEmail": "alice@example.com",
      "name": {
        "givenName": "Alice",
        "familyName": "Smith",
        "fullName": "Alice Smith"
      },
      "isAdmin": false,
      "isDelegatedAdmin": false,
      "creationTime": "2024-01-15T10:00:00.000Z",
      "orgUnitPath": "/Engineering"
    }
  ],
  "nextPageToken": "abc123..."
}
User details response:
{
  "id": "12345678901234567890",
  "primaryEmail": "alice@example.com",
  "name": {
    "givenName": "Alice",
    "familyName": "Smith"
  },
  "isAdmin": false,
  "suspended": false,
  "orgUnitPath": "/Engineering",
  "phones": [{"value": "+1-555-123-4567", "type": "work"}],
  "organizations": [{"title": "Software Engineer", "department": "Engineering"}]
}

Key Resources

  • users - Manage user accounts
  • groups - Manage groups
  • members - Manage group memberships
  • orgunits - Manage organizational units
  • chromeosdevices - Manage Chrome OS devices
  • mobiledevices - Manage mobile devices
  • domains - Manage domain settings
  • roles - Manage admin roles
  • schemas - Manage custom user schemas

Common Use Cases

Provision New Employee

# 1. Create user
gws admin users insert --json '{
  "primaryEmail": "newuser@example.com",
  "name": {"givenName": "New", "familyName": "User"},
  "password": "TempPass123!",
  "orgUnitPath": "/Engineering"
}'

# 2. Add to groups
gws admin members insert \
  --params '{"groupKey": "engineering@example.com"}' \
  --json '{"email": "newuser@example.com"}'

Suspend User Account

gws admin users update \
  --params '{"userKey": "alice@example.com"}' \
  --json '{"suspended": true}'

Make User Admin

gws admin users makeAdmin \
  --params '{"userKey": "alice@example.com"}' \
  --json '{"status": true}'

Learn More

Schema Inspection

Before calling any method, inspect its schema:
gws schema admin.users.list
gws schema admin.users.insert