Learn how to install, configure, and use the Google Workspace command-line
interface (CLI).

The Google Workspace command-line interface, `gwscli`, is a unified
terminal client that connects AI agents such as Claude Code, Codex, and
[Antigravity](https://antigravity.google/) to Google Workspace services. After you
install the CLI, connect your account, and install the packaged agent skills,
your agent runs the appropriate commands when you make requests in plain
language. The CLI also supports developers working directly in an interactive
terminal.

You can authenticate interactively with a Google Account or pass an existing
OAuth or domain-wide delegation access token. When accessing data in a
Google Workspace organization, all actions follow the organization's
administrator access and security policies. For details, see
[Set up authentication](https://developers.google.com/workspace/guides/workspace-cli.md.txt#authentication).

Because the CLI discovers commands, parameters, and schemas dynamically at
runtime, command interfaces and output schemas might change without backward
compatibility. Don't rely on fixed command signatures in static scripts.

The CLI provides the following features:

- Dynamic runtime command discovery and schema inspection for AI agents
- Structured JSON output for automated data processing
- Packaged agent skills that provide domain context and safety guidance
- Built-in human-in-the-loop verification for sensitive actions

## What your agent can do

The command-line interface supports the following Google Workspace
services and actions. For the full list of commands, see
[Complete command reference](https://developers.google.com/workspace/guides/workspace-cli.md.txt#all-commands).

| Service | Actions | Required project services |
|---|---|---|
| Google Calendar | List calendars and events, search events, suggest free meeting times, and create, update, respond to, or delete events. | `calendar-json.googleapis.com`, `calendarmcp.googleapis.com` |
| Google Chat | Find spaces, direct messages, and group chats, read and search messages, and send messages. Sending messages requires a Google Workspace account and a configured Google Chat app. | `chat.googleapis.com`, `chatmcp.googleapis.com` |
| Google Docs | Read document content and structure, and apply batch edits to documents. | `docs.googleapis.com`, `docsmcp.googleapis.com` |
| Google Drive | Search, list, read, and download files, inspect metadata and sharing permissions, create or copy files, and upload local files or new file revisions. | `drive.googleapis.com`, `drivemcp.googleapis.com` |
| Gmail | Search and read threads and messages, list and create drafts and replies, manage labels, and move messages or threads to or from Trash and Spam. | `gmail.googleapis.com`, `gmailmcp.googleapis.com` |
| The People API, in [Developer Preview](https://developers.google.com/workspace/preview.md.txt) | View your profile, search personal contacts, and search your organization's directory. Directory search requires a Google Workspace account. | `people.googleapis.com` |
| Google Sheets | Read spreadsheets and cell ranges, write values and formulas, insert rows or columns, and apply batch spreadsheet updates. | `sheets.googleapis.com`, `sheetsmcp.googleapis.com` |
| Google Slides | Read presentations and individual slides, fetch slide thumbnail images, and apply batch edits to presentations. | `slides.googleapis.com`, `slidesmcp.googleapis.com` |
| Google Tasks | List task lists and tasks, view task details, create and update tasks, mark tasks complete or incomplete, and delete or restore tasks. | `tasks.googleapis.com`, `tasksmcp.googleapis.com` |

### Example agent prompts

After you complete setup and install the agent skills, you can ask your AI
agent questions and tasks in plain language, such as:

- "What's on my calendar for the rest of today?"
- "Summarize my unread email from this week and create a draft reply to my manager proposing Tuesday."
- "Find my docs about the Q3 plan and list the open action items."
- "Add the open action items from my Q3 plan doc to my Tasks list."

## Prerequisites

Before installing the command-line interface, verify the following
requirements:

- An environment running Linux, macOS, or Windows on x86_64 or ARM64.
- A Google Cloud project. To create a project, see [Create a Google Cloud project](https://developers.google.com/workspace/guides/create-project.md.txt). If your organization administrator doesn't allow users to create new projects, you might encounter a `resourcemanager.projects.create` permission error. Use an existing project or see [Troubleshooting](https://developers.google.com/workspace/guides/workspace-cli.md.txt#troubleshooting).
- On Linux or macOS, `curl` for the quick-install script, or another HTTP download tool such as `wget` for manual downloads. On Windows, PowerShell.

Depending on your setup, you might also need the following:

- The Google Cloud CLI if you enable services from the command line during manual setup. To install it, see [Install the Google Cloud CLI](https://cloud.google.com/sdk/docs/install).
- If sending messages in Chat with `gwscli chat send_message`, a Google Workspace account and a configured Google Chat app in your Google Cloud project. For setup steps, see [Configure the Google Chat API](https://developers.google.com/workspace/chat/configure-chat-api.md.txt).
- If accessing the People API with `gwscli people` commands, a Google Cloud project enrolled in the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview.md.txt).

> [!NOTE]
> **Note:** Using `gwscli` incurs no separate tool charge. Requests count toward your Google Cloud project's Google Workspace usage tier and quotas. For details on usage tiers, limits, and pricing, see the [Google Workspace usage tiers and quotas](https://developers.google.com/workspace/tools-safety) documentation.

## Install the command-line interface

Install the command-line interface with the quick-install script, or download
the prebuilt binary manually for your operating system and CPU architecture.

### Quick install

### Linux and macOS

```bash
curl -fsSL https://dl.google.com/workspace-cli/install.sh | bash
```

Installs to `~/.local/bin`. To change this, set `GWSCLI_INSTALL_DIR`.

### Windows

In PowerShell:

```bash
iex ((New-Object Net.WebClient).DownloadString('https://dl.google.com/workspace-cli/install.ps1'))
```

Installs to `$HOME\bin` and adds it to your user `PATH`. To change the
install directory, set `$env:GWSCLI_INSTALL_DIR`.

### Manual install

Download the prebuilt binary and documentation assets for your operating
system and CPU architecture.

### Linux x86_64

Run the following commands to download the Linux x86_64 binary and assets,
and make the binary executable:

```bash
mkdir -p ~/.gwscli
curl -fsSL https://dl.google.com/workspace-cli/linux/gwscli \
    -o /usr/local/bin/gwscli
curl -fsSL https://dl.google.com/workspace-cli/README.md \
    -o ~/.gwscli/README.md
curl -fsSL https://dl.google.com/workspace-cli/NOTICES.txt \
    -o ~/.gwscli/NOTICES.txt
chmod +x /usr/local/bin/gwscli
```

### Linux ARM64

Run the following commands to download the Linux ARM64 binary and assets,
and make the binary executable:

```bash
mkdir -p ~/.gwscli
curl -fsSL https://dl.google.com/workspace-cli/linux_arm64/gwscli \
    -o /usr/local/bin/gwscli
curl -fsSL https://dl.google.com/workspace-cli/README.md \
    -o ~/.gwscli/README.md
curl -fsSL https://dl.google.com/workspace-cli/NOTICES.txt \
    -o ~/.gwscli/NOTICES.txt
chmod +x /usr/local/bin/gwscli
```

### macOS Apple silicon

Run the following commands to download the macOS binary for Apple silicon,
grant execute permissions, and clear the quarantine attribute:

```bash
mkdir -p ~/.gwscli
curl -fsSL https://dl.google.com/workspace-cli/macos_silicon/gwscli \
    -o /usr/local/bin/gwscli
curl -fsSL https://dl.google.com/workspace-cli/README.md \
    -o ~/.gwscli/README.md
curl -fsSL https://dl.google.com/workspace-cli/NOTICES.txt \
    -o ~/.gwscli/NOTICES.txt
chmod +x /usr/local/bin/gwscli
xattr -d com.apple.quarantine /usr/local/bin/gwscli
```

### macOS Intel

Run the following commands to download the macOS binary for Intel processors,
grant execute permissions, and clear the quarantine attribute:

```bash
mkdir -p ~/.gwscli
curl -fsSL https://dl.google.com/workspace-cli/macos_intel/gwscli \
    -o /usr/local/bin/gwscli
curl -fsSL https://dl.google.com/workspace-cli/README.md \
    -o ~/.gwscli/README.md
curl -fsSL https://dl.google.com/workspace-cli/NOTICES.txt \
    -o ~/.gwscli/NOTICES.txt
chmod +x /usr/local/bin/gwscli
xattr -d com.apple.quarantine /usr/local/bin/gwscli
```

### Windows x86_64

Run the following commands in PowerShell to download the Windows x86_64
binary and assets. Invoke `curl.exe` explicitly because `curl` is an alias
for `Invoke-WebRequest` in PowerShell:

```bash
New-Item -ItemType Directory -Force -Path "$HOME\bin", "$HOME\.gwscli"
curl.exe -fsSL https://dl.google.com/workspace-cli/windows/gwscli.exe `
    -o "$HOME\bin\gwscli.exe"
curl.exe -fsSL https://dl.google.com/workspace-cli/README.md `
    -o "$HOME\.gwscli\README.md"
curl.exe -fsSL https://dl.google.com/workspace-cli/NOTICES.txt `
    -o "$HOME\.gwscli\NOTICES.txt"
```

### Windows ARM64

Run the following commands in PowerShell to download the Windows ARM64 binary
and assets. Invoke `curl.exe` explicitly because `curl` is an alias for
`Invoke-WebRequest` in PowerShell:

```bash
New-Item -ItemType Directory -Force -Path "$HOME\bin", "$HOME\.gwscli"
curl.exe -fsSL https://dl.google.com/workspace-cli/windows_arm64/gwscli.exe `
    -o "$HOME\bin\gwscli.exe"
curl.exe -fsSL https://dl.google.com/workspace-cli/README.md `
    -o "$HOME\.gwscli\README.md"
curl.exe -fsSL https://dl.google.com/workspace-cli/NOTICES.txt `
    -o "$HOME\.gwscli\NOTICES.txt"
```

If `/usr/local/bin` requires elevated permissions on Linux or macOS, download
the binary to a writable folder on your `PATH`, such as `~/.local/bin` or
`~/bin`. On Windows, make sure `$HOME\bin` is included in your `PATH`.

### Install with an AI agent

If you're working inside an AI coding agent, you can also download the agent
installation prompt and ask your agent to follow it:

```bash
curl -fsSL -O https://dl.google.com/workspace-cli/INSTALL_PROMPT.md
```

Complete interactive credential setup and sign-in yourself in your local
terminal rather than through your agent.

### Verify the installation

After installing the binary, verify that the tool runs:

```bash
gwscli version
```

## Set up authentication

The command-line interface uses OAuth 2.0 to authenticate requests. You can
authenticate with your own OAuth client ID or supply an existing OAuth access
token directly.

Interactive sign-in with `gwscli auth login` requires a web browser that can
reach `localhost` on the same machine running the CLI. Run interactive sign-in
from your local terminal, or see
[Browser redirect requirements](https://developers.google.com/workspace/guides/workspace-cli.md.txt#browser-redirect) for remote and headless
environments.

### Option 1: Configure your own OAuth client

To allow the command-line interface to manage tokens and refresh sessions,
configure an OAuth client ID in your Google Cloud project. Run these
setup steps in your own terminal rather than through an AI agent because setup
and sign-in wait for interactive input.

Follow [Quick setup: Personal mode](https://developers.google.com/workspace/guides/workspace-cli.md.txt#personal-mode) to configure credentials
and sign in for a single-user project. For an existing or multi-user
Google Cloud project, complete [Manual setup](https://developers.google.com/workspace/guides/workspace-cli.md.txt#manual-setup) and then
continue to [Sign in to services](https://developers.google.com/workspace/guides/workspace-cli.md.txt#login).

#### Quick setup: Personal mode

Personal mode in the Google Cloud console creates a single-user OAuth 2.0 client
that works only for your Google Account, automatically enables core
Google Workspace services, and skips OAuth consent screen setup and
app verification.

1. Open the [Google Cloud console personal mode setup page](https://console.cloud.google.com/auth/overview/personal?apis=ws,wsmcp,tasksmcp&clientType=desktop&isAgent=true). This link pre-selects the required Google Workspace services, desktop application type, and agent flag.
2. Select your Google Cloud project or create a new personal-mode
   project.

   If your organization administrator doesn't allow users to create new
   projects, you might encounter the error `You do not have the required
   "resourcemanager.projects.create" permission to create projects in this
   location.` Select an existing project or see
   [Troubleshooting](https://developers.google.com/workspace/guides/workspace-cli.md.txt#troubleshooting).
3. Click **Create Client** and download the client secret JSON file.

4. Register your credentials with the command-line interface:

   ```bash
   gwscli auth setup
   ```

   When prompted, enter the path to your downloaded client secret JSON file
   and enter `Y` to confirm the registration.
5. Sign in to authorize services, starting with read-only scopes:

   ```bash
   gwscli auth login --bundle=readonly
   ```

   Open the printed URL in your browser to complete consent. To authorize
   write access, run `gwscli auth login <service>` for a single service or
   `gwscli auth login` for all services. For more scope options, see
   [Sign in to services](https://developers.google.com/workspace/guides/workspace-cli.md.txt#login).

#### Manual setup

If you aren't using personal mode, complete all three manual setup steps in
your Google Cloud project before signing in.

##### Step 1: Enable the required services

Each command group requires enabling both the underlying product API and its
companion `*mcp.googleapis.com` service in your Google Cloud project,
except `people`, which uses `people.googleapis.com` for both.

To enable services only for specific products, pass the service names from the
**Required project services** column in
[What your agent can do](https://developers.google.com/workspace/guides/workspace-cli.md.txt#what-your-agent-can-do). For example, to enable only
Drive:

```bash
gcloud services enable --project=PROJECT_ID \
    drive.googleapis.com drivemcp.googleapis.com
```

To enable all supported services at once, run:

```bash
gcloud services enable --project=PROJECT_ID \
    gmail.googleapis.com drive.googleapis.com docs.googleapis.com \
    sheets.googleapis.com slides.googleapis.com calendar-json.googleapis.com \
    chat.googleapis.com people.googleapis.com tasks.googleapis.com \
    gmailmcp.googleapis.com drivemcp.googleapis.com docsmcp.googleapis.com \
    sheetsmcp.googleapis.com slidesmcp.googleapis.com \
    calendarmcp.googleapis.com chatmcp.googleapis.com \
    tasksmcp.googleapis.com
```

Replace `PROJECT_ID` with your Google Cloud project ID.

If you plan to send messages in Chat with
`gwscli chat send_message`, also configure a
Chat app in your Google Cloud project as
described in [Configure the Google Chat API](https://developers.google.com/workspace/chat/configure-chat-api.md.txt).

##### Step 2: Create a credentials file

Before creating a client ID, make sure you have configured your OAuth consent
screen in **Google Auth Platform** . If your consent screen audience is set to
**External** , add your email address under **Audience**
\> **Test users** so consent isn't refused.
For details, see
[Set up the OAuth consent screen](https://developers.google.com/workspace/guides/configure-mcp-servers.md.txt#configure-consent-screen).

1. In the Google Cloud console, go to **Google Auth Platform** \> **Clients** \> **Create Client**.
2. In the **Application type** menu, select **Desktop app**.
3. Enter a **Name** for the client.
4. Select **Use this client for an AI-powered agent**.
5. Click **Create** and download the JSON credentials file to your local machine.

If you already have a **Desktop app** OAuth 2.0 client ID, you can select
**Use this client for an AI-powered agent** on that client in
**Google Auth Platform** \> **Clients** , as
described in [Manage OAuth Clients](https://support.google.com/cloud/answer/15549257). If you can't change
this setting on an existing client, or if the client also supports non-agent
features, create a new client ID for your agent. For detailed credential
creation steps, see
[Create access credentials](https://developers.google.com/workspace/guides/create-credentials.md.txt).

##### Step 3: Register credentials with the CLI

Run the `auth setup` command and provide the path to your downloaded client
secret file:

```bash
gwscli auth setup --oauth_client_file=/path/to/client_secret.json
```

This command removes any prior tokens and configures the new client. Enter `Y`
when prompted to confirm the registration.

#### Sign in to services

Authorize access for a specific command, one or more services, read-only
operations, or all supported services. The CLI prints an authorization URL and
starts a local listener on `http://127.0.0.1:<port>/` to receive the OAuth
callback after you grant consent in your browser.

Authentication is incremental. When you run `gwscli auth login` again for
additional commands or services, the CLI merges the newly granted scopes with
your existing authorized scopes.

> [!NOTE]
> **Note:** Follow the principle of least privilege, especially when configuring credentials for AI agents. Start with read-only access or grant only the minimum scopes required for your task rather than authorizing all services at once.

- To authorize read-only access across all services, add the `--bundle` flag:

  ```bash
  gwscli auth login --bundle=readonly
  ```
- To authorize read-only access for a single service, combine the service name
  with `--bundle=readonly`:

  ```bash
  gwscli auth login chat --bundle=readonly
  ```
- To authorize access for an individual action, pass both the service and the
  command:

  ```bash
  gwscli auth login gmail search_threads
  ```
- To authorize access for a single service, pass the service name:

  ```bash
  gwscli auth login drive
  ```
- To authorize access for multiple services in a single command, pass the
  service names separated by spaces:

  ```bash
  gwscli auth login chat gmail
  ```
- To authorize multiple specific commands at once, pass each target in quotes:

  ```bash
  gwscli auth login "chat search_messages" "gmail create_draft"
  ```
- To authorize all supported services at once, run:

  ```bash
  gwscli auth login
  ```

To verify the signed-in account and check the active scopes, run:

```bash
gwscli auth status
```

To refresh authorized tokens manually, run:

```bash
gwscli auth refresh
```

> [!NOTE]
> **Note:** Google OAuth 2.0 access tokens typically expire after 1 hour. When you run a command, `gwscli` checks token expiry and automatically uses your cached refresh token to obtain a new access token when needed. Run `auth refresh` only when you want to force an immediate token refresh. For details on token lifetimes and refresh token expiration rules, see [Using OAuth 2.0 to Access Google APIs](https://developers.google.com/identity/protocols/oauth2.md.txt).

To log out and revoke active tokens, run:

```bash
gwscli auth logout
```

To remove your configured OAuth client and reset authentication credentials,
run:

```bash
gwscli auth reset
```

#### Browser redirect requirements

> [!CAUTION]
> **Caution:** Interactive OAuth sign-in with `gwscli auth login` starts a temporary local server on `http://127.0.0.1:<port>/` and waits for your browser to redirect back to that address.

Interactive sign-in requires a machine that can open a web browser and deliver
OAuth redirects to `http://127.0.0.1:<port>/`. Without extra port forwarding,
`gwscli auth login` won't complete in the following environments:

- Headless environments without browser access
- Cloud Shell or remote SSH sessions without local port forwarding
- Containerized environments without `localhost` port mapping

To authenticate on a remote SSH host or container, forward the dynamic port
printed by `gwscli auth login` from your local computer to `127.0.0.1:<port>`
on the remote host before completing consent in your local browser.
Alternatively, obtain an access token separately and pass it with
`--oauth_token` as described in
[Option 2: Pass an existing OAuth token](https://developers.google.com/workspace/guides/workspace-cli.md.txt#oauth-token).

### Option 2: Pass an existing OAuth token

If your platform already manages Google OAuth 2.0 tokens, pass an access token
directly on any command using the global `--oauth_token` flag:

```bash
gwscli --oauth_token="$ACCESS_TOKEN" calendar list_events
```

> [!CAUTION]
> **Caution:** Passing a bearer token as a command-line flag can expose the token in local process listings such as `ps` or `/proc/<pid>/cmdline`, shell history, or agent transcripts. Avoid typing literal token strings on the command line, and use short-lived tokens with only the scopes you need.

When you pass `--oauth_token`, the command-line interface doesn't prompt for
consent or refresh expired tokens. Verify the following requirements for the
token:

- **Required scopes** : The token must include the OAuth scopes required by the
  command. To check which scopes a command needs before calling it, pass
  `--show-scopes`:

  ```bash
  gwscli calendar list_events --show-scopes
  ```

  You can also print only the comma-separated minimal scopes with
  `auth login --print-scope-only`:

  ```bash
  gwscli auth login --print-scope-only calendar list_events
  ```
- **Enabled project services** : The Google Cloud project that owns the
  issuing credentials must have the required services enabled, as shown in
  [Step 1: Enable the required services](https://developers.google.com/workspace/guides/workspace-cli.md.txt#enable-apis).

- **Supported credential types** : User-delegated OAuth tokens must come from an
  OAuth client ID with **Use this client for an AI-powered agent** selected.
  Access tokens minted by a service account with
  [domain-wide delegation](https://developers.google.com/workspace/guides/configure-mcp-servers.md.txt#domain-wide-delegation) are also accepted.

## Discover commands and schemas

The CLI uses a standard command syntax:

```bash
gwscli <service> <action> [flags]
```

Because the command-line interface discovers services, actions, and schemas
dynamically from the backend at runtime, updates might not be backward
compatible. AI agents and developers should inspect `--help` and `--schema` at
runtime rather than hardcoding command signatures in static scripts.

### List available services

To display all supported services and utility commands, run the help command:

```bash
gwscli --help
```

### List service actions

To list available actions for a specific service, pass the service name with
the help flag:

```bash
gwscli drive --help
```

### Inspect action parameters and flags

To inspect the parameters, flags, and output format summary for an action, run
the action with the help flag:

```bash
gwscli drive list_recent_files --help
```

To include the supported and recommended minimal OAuth scopes in the help
output, add `--show-scopes`:

```bash
gwscli drive list_recent_files --show-scopes
```

### Inspect the JSON schema

To print the full JSON output schema and field definitions without executing
the action, pass the `--schema` flag:

```bash
gwscli drive search_files --schema
```

## Parse command output and transfer files

The command-line interface prints results directly to standard output.

- **Structured JSON** : Commands that return lists, files, or event records
  output valid JSON. You can filter and format the output using tools like `jq`:

  ```bash
  gwscli drive search_files \
      --query="title contains 'Quarterly'" \
      | jq '.files[] | {id: .id, title: .title}'
  ```
- **Document content** : Commands that fetch document contents also return JSON.
  For example, `docs read_doc` outputs the document JSON representation with
  text and structural elements, and `drive read_file_content` returns JSON with
  a `fileContent` string field containing the formatted plain text or Markdown:

  ```bash
  gwscli drive read_file_content --fileId="FILE_ID" \
      | jq -r '.fileContent'
  ```
- **Download files** : To download binary files or export
  Google Workspace documents directly to a local path, use
  `drive download_file_content`:

  ```bash
  gwscli drive download_file_content --fileId="FILE_ID" \
      --destinationPath="./report.pdf" --exportMimeType="application/pdf"
  ```

  For Google Workspace documents, `--exportMimeType` is optional and
  defaults to plain text formats such as `text/plain` or `text/csv` when
  omitted. To export to another format, pass a supported MIME type from
  [Export MIME types for Google Workspace documents](https://developers.google.com/workspace/drive/api/guides/ref-export-formats.md.txt). For
  other files such as PDFs or images, `--exportMimeType` is ignored. Run
  `gwscli drive download_file_content --help` to inspect the flag details.
- **Upload local files and revisions** : To upload a local file from disk as a
  new Drive file using resumable upload, pass `--filePath` to
  `drive create_file`:

  ```bash
  gwscli drive create_file --filePath="./report.pdf" \
      --title="Quarterly Report"
  ```

  To upload a new content revision for an existing non-Google Workspace
  file in Drive, pass `--filePath` to
  `drive upload_file_revision`:

  ```bash
  gwscli drive upload_file_revision --fileId="FILE_ID" \
      --filePath="./report-v2.pdf"
  ```

## Install packaged agent skills

The CLI includes pre-packaged agent skills that teach AI coding agents how to
discover commands, handle authentication and confirmation prompts safely, and
parse command output.

To list all available packaged agent skills embedded in the CLI, run:

```bash
gwscli skills list
```

To install the agent skills into your agent's skill discovery folder, pass
`--dir`. For example, use `~/.agents/skills` for agents that read the shared
skills folder, or `~/.claude/skills` for Claude Code:

```bash
gwscli skills install --dir ~/.agents/skills
```

> [!IMPORTANT]
> **Important:** After installing or updating skills, verify that your AI agent has loaded the new skill files. Most agent harnesses read skills only at startup, so start a new session, reload skills in your harness, or restart the agent before running tasks.

Whenever you update the `gwscli` binary, also refresh your installed skills as
described in [Update the CLI and agent skills](https://developers.google.com/workspace/guides/workspace-cli.md.txt#update).

## Update the CLI and agent skills

The command-line interface doesn't auto-update in the background. Check the
[Google Workspace CLI release notes](https://developers.google.com/workspace/cli/release-notes)
periodically for new releases, and compare against your installed version:

```bash
gwscli version
```

To update the binary, re-run the [quick-install script](https://developers.google.com/workspace/guides/workspace-cli.md.txt#quick-install) or
download the latest binary for your platform using the
[manual install steps](https://developers.google.com/workspace/guides/workspace-cli.md.txt#manual-install). Your existing OAuth client
configuration and cached tokens are preserved across binary updates.

### Refresh packaged agent skills

Packaged agent skills are embedded inside the `gwscli` binary. After updating
the binary, refresh your installed skills with `--overwrite` so your agent
receives the latest command guidance and version metadata:

```bash
gwscli skills install --dir ~/.agents/skills --overwrite
```

Passing `--overwrite` replaces only the `gwscli` skill subdirectories in the
target folder and leaves other unrelated skills untouched. If you customized
the `gwscli` skill files directly, back them up or install to a temporary
folder first to compare changes before running `--overwrite`. After refreshing
skills, make sure your agent loads the updated skill files.

## Complete command reference

Because service commands are discovered dynamically at runtime, available
commands and flags can change across releases. Run
`gwscli <service> <action> --help` to view the current flags and output format
for any command.

### Service commands

In the **Access** column below, **Read-only** commands only read data and are
included when you sign in with `--bundle=readonly`. **Write** commands create,
modify, or delete data.

| Service | Command | Description | Access |
|---|---|---|---|
| Calendar | `calendar list_calendars` | List calendars that you own or subscribe to. | Read-only |
| Calendar | `calendar list_events` | List events on a calendar matching time or text filters. | Read-only |
| Calendar | `calendar get_event` | Get details for a single event. | Read-only |
| Calendar | `calendar search_events` | Search events on your primary calendar. | Read-only |
| Calendar | `calendar suggest_time` | Suggest available times across one or more calendars. | Read-only |
| Calendar | `calendar create_event` | Create an event on a calendar. | Write |
| Calendar | `calendar update_event` | Update an existing event on a calendar. | Write |
| Calendar | `calendar respond_to_event` | Respond to an event invitation. | Write |
| Calendar | `calendar delete_event` | Delete an event from a calendar. | Write |
| Chat | `chat search_conversations` | Find spaces, direct messages, and group chats. | Read-only |
| Chat | `chat list_messages` | Read messages from a conversation in Markdown format. | Read-only |
| Chat | `chat search_messages` | Search messages across spaces or within a conversation. | Read-only |
| Chat | `chat send_message` | Send a message to a conversation. Requires a Google Workspace account and a configured Chat app. | Write |
| Docs | `docs read_doc` | Read the JSON representation of a document. | Read-only |
| Docs | `docs update_doc` | Apply batch updates to edit a document. | Write |
| Drive | `drive search_files` | Search files using structured query terms. | Read-only |
| Drive | `drive list_recent_files` | List recent files. | Read-only |
| Drive | `drive get_file_metadata` | Get metadata details for a file. | Read-only |
| Drive | `drive get_file_permissions` | List access permissions for a file. | Read-only |
| Drive | `drive read_file_content` | Read a text representation of a file and optional comments. | Read-only |
| Drive | `drive download_file_content` | Download a binary file or export a document to local disk. | Read-only |
| Drive | `drive create_file` | Create a file or folder, or upload a local file from disk. | Write |
| Drive | `drive upload_file_revision` | Upload a new content revision for an existing non-Google Workspace file. | Write |
| Drive | `drive copy_file` | Copy an existing file. | Write |
| Gmail | `gmail search_threads` | Search or list email threads. | Read-only |
| Gmail | `gmail get_thread` | Read a full email thread and its messages. | Read-only |
| Gmail | `gmail get_message` | Read a single email message by ID. | Read-only |
| Gmail | `gmail list_drafts` | List draft emails. | Read-only |
| Gmail | `gmail get_draft` | Read a draft email by ID. | Read-only |
| Gmail | `gmail list_labels` | List system and user labels. | Read-only |
| Gmail | `gmail create_draft` | Create a draft email or reply without sending it. | Write |
| Gmail | `gmail create_label` | Create a label. | Write |
| Gmail | `gmail label_thread` | Add labels to a thread. | Write |
| Gmail | `gmail label_message` | Add labels to a single message. | Write |
| Gmail | `gmail unlabel_thread` | Remove labels from a thread. | Write |
| Gmail | `gmail unlabel_message` | Remove labels from a single message. | Write |
| Gmail | `gmail update_message_labels` | Add and remove labels on a message in one step. | Write |
| Gmail | `gmail trash_thread` | Move a thread to Trash. | Write |
| Gmail | `gmail trash_message` | Move a single message to Trash. | Write |
| Gmail | `gmail untrash_thread` | Restore a thread from Trash. | Write |
| Gmail | `gmail untrash_message` | Restore a single message from Trash. | Write |
| Gmail | `gmail mark_thread_spam` | Mark a thread as spam. | Write |
| Gmail | `gmail mark_message_spam` | Mark a single message as spam. | Write |
| Gmail | `gmail unmark_thread_spam` | Unmark a thread as spam. | Write |
| Gmail | `gmail unmark_message_spam` | Unmark a single message as spam. | Write |
| Gmail | `gmail apply_sensitive_thread_label` | Move a thread to Trash or Spam. Prefer `trash_thread` or `mark_thread_spam`. | Write |
| Gmail | `gmail apply_sensitive_message_label` | Move a message to Trash or Spam. Prefer `trash_message` or `mark_message_spam`. | Write |
| People API | `people get_user_profile` | Get your profile name and email address. Available in [Developer Preview](https://developers.google.com/workspace/preview.md.txt). | Read-only |
| People API | `people search_contacts` | Search your personal contacts. Available in [Developer Preview](https://developers.google.com/workspace/preview.md.txt). | Read-only |
| People API | `people search_directory_people` | Search your organization's directory. Requires a Google Workspace account. Available in [Developer Preview](https://developers.google.com/workspace/preview.md.txt). | Read-only |
| Sheets | `sheets get_spreadsheet` | Read spreadsheet metadata and content. | Read-only |
| Sheets | `sheets get_values` | Read values from a range of cells. | Read-only |
| Sheets | `sheets update_values` | Write values to a range of cells. | Write |
| Sheets | `sheets update_formulas` | Write formulas to a range of cells. | Write |
| Sheets | `sheets insert_dimension` | Insert rows or columns in a sheet. | Write |
| Sheets | `sheets update_spreadsheet` | Apply batch updates to a spreadsheet. | Write |
| Slides | `slides read_presentation` | Read the JSON representation of a presentation. | Read-only |
| Slides | `slides read_slide_page` | Read a single slide from a presentation. | Read-only |
| Slides | `slides read_slide_page_thumbnail` | Get the thumbnail image URL and dimensions for a slide. | Read-only |
| Slides | `slides update_presentation` | Apply batch updates to edit a presentation. | Write |
| Tasks | `tasks list_task_lists` | List your task lists. | Read-only |
| Tasks | `tasks list_tasks` | List tasks across one or all task lists. | Read-only |
| Tasks | `tasks get_task` | Get details for a single task by ID. | Read-only |
| Tasks | `tasks create_task` | Create a task in a task list. | Write |
| Tasks | `tasks update_task` | Update an existing task. | Write |
| Tasks | `tasks complete_task` | Mark a task as complete. | Write |
| Tasks | `tasks uncomplete_task` | Mark a task as incomplete. | Write |
| Tasks | `tasks delete_task` | Delete a task. | Write |
| Tasks | `tasks undelete_task` | Restore a deleted task. | Write |

<br />

### Utility commands

The following built-in commands manage local authentication, agent skills,
telemetry settings, and version details:

| Command | Description |
|---|---|
| `auth setup` | Register an OAuth 2.0 client secret JSON file. |
| `auth login` | Sign in and authorize scopes for services or commands. |
| `auth status` | Display granted OAuth scopes and the signed-in user profile. |
| `auth refresh` | Force a manual refresh of cached OAuth tokens. |
| `auth logout` | Revoke active OAuth tokens and clear cached session state. |
| `auth reset` | Sign out and remove the registered OAuth client credentials. |
| `skills list` | List embedded agent skills packaged with the binary. |
| `skills install` | Install embedded agent skills into a target directory. |
| `logging on` | Enable usage telemetry in your local configuration. |
| `logging off` | Disable usage telemetry in your local configuration. |
| `logging status` | Display whether usage telemetry is currently enabled. |
| `privacy` | Print the Google Privacy Policy URL. |
| `terms` | Print the Google APIs Terms of Service URL. |
| `version` | Print the installed `gwscli` version. |

## Security and governance

When using the command-line interface directly or through AI agents, follow
these security and governance practices.

### Protect against prompt injection

Language models can encounter untrusted text in email bodies, shared files, or
external web pages that carry hidden instructions.

- Use the command-line interface only with AI agents and workflows that you trust.
- Start with read-only access and grant write scopes only for the services you need.
- Don't feed unverified documents or messages from unknown senders into agent prompts.
- Review actions taken by your agent and ensure agents don't forward sensitive contents to external destinations.

### Screen requests and responses

You can configure project-level security filters in Google Cloud to
screen CLI inputs and responses for prompt injection, sensitive data, or
harmful content. Any MCP floor settings configured on your Google Cloud
project apply to `gwscli` requests as well. For setup steps, see
[Configure security for Google Workspace MCP servers](https://developers.google.com/workspace/guides/configure-mcp-security.md.txt).

### Automate in headless environments safely

The `auth login` and `auth setup` commands wait for interactive browser or
terminal input and block indefinitely in unattended environments. Don't invoke
interactive setup or sign-in commands in automated background jobs or headless
scripts.

In headless environments, pre-authorize credentials beforehand or pass
externally managed access tokens with `--oauth_token`. If an automated agent
encounters an authentication or scope error, stop execution and surface the
error rather than attempting interactive sign-in.

### Human-in-the-loop verification

Google Workspace enforces user and administrator approval policies for
sensitive actions, such as sending messages, sharing content externally,
trashing items, or deleting data. Other write actions run without asking once
you've granted the required OAuth scopes, so always review what your agent
does.

When an action requires confirmation, the command-line interface pauses, prints
a prompt to standard error, and waits for an approval choice on standard input:

```text
Allow this app to use send_message?

approval_choice
(Options: Allow once, Always allow this tool, Don't allow):
```

The command-line interface accepts choice identifiers such as `ALLOW_ONCE`,
`ALLOW_TOOL_ALWAYS`, or `DENY_ONCE` on standard input. Sticky options such as
`ALLOW_TOOL_ALWAYS` appear only in an interactive terminal when permitted by
policy for the action or target resource. When an AI agent runs the command,
the agent must prompt the user for explicit confirmation and write the user's
chosen identifier to standard input, or a human running the CLI directly can
type the choice in the terminal.

Google Workspace administrators can customize these rules for external
agents in the Google Admin console under **Agents**
\> **Settings**
\> **User review for external agents** .
Administrators can allow actions without prompts, require confirmation on every
command by unchecking **Except when user always allows** , or block external and
internal collaboration or data access. For details on policy evaluation and
related OAuth, data loss prevention (DLP), attribution, and audit controls, see
[Administrator user review policies](https://developers.google.com/workspace/guides/mcp-elicitation.md.txt#admin-policies) and
[Manage AI agent access \& user review](https://knowledge.workspace.google.com/admin/apps/control-which-apps-access-google-workspace-data#ai-agents).

### Manage usage telemetry

Usage telemetry sends diagnostic and command-execution metadata to Google to
help monitor reliability and improve the command-line interface. Google handles
collected telemetry data in accordance with the
[Google Privacy Policy](https://policies.google.com/privacy).

Usage telemetry is enabled by default. You can check the current setting or
turn usage telemetry off or on persistently at any time:

```bash
gwscli logging off      # Turn off usage telemetry
gwscli logging status   # Show the current setting
gwscli logging on       # Turn usage telemetry back on
```

To disable usage telemetry for a single terminal session or automated
environment without modifying your configuration file, set the
`GWSCLI_TELEMETRY_ENABLED` environment variable to `0`, `false`, `off`, or
`no`:

```bash
export GWSCLI_TELEMETRY_ENABLED=0
```

When usage telemetry is enabled, each command invocation records only the
following operational signals:

- **Command metadata**: The target service and action name, the names of flags passed to the command, and the number of positional arguments
- **Environment metadata**: The CLI version, build variant, operating system, and CPU architecture
- **Execution diagnostics**: Execution status, command duration, HTTP status codes, enumerated error codes or Go error types, and crash stack traces

The CLI never collects flag values, OAuth tokens, search queries, document
IDs, email addresses, or resource content.

Telemetry events are sent directly to Google when a command finishes and aren't
written to a local log file. You can inspect whether telemetry is active by
running `gwscli logging status` or by reading the `telemetry_enabled` field in
your local `gwscli/config.json` configuration file:

- **Linux** : `~/.config/gwscli/config.json`
- **macOS** : `~/Library/Application Support/gwscli/config.json`
- **Windows** : `%AppData%\gwscli\config.json`

To print the [Google Privacy Policy](https://policies.google.com/privacy) or
[Google APIs Terms of Service](https://developers.google.com/terms.md.txt) URLs from the terminal, run
`gwscli privacy` or `gwscli terms`. Usage is also subject to the
[Google Workspace user data and developer policy](https://developers.google.com/workspace/workspace-api-user-data-developer-policy.md.txt).

## Troubleshooting

Use the following table to resolve common setup, authentication, and execution
issues:

| Issue | Resolution |
|---|---|
| `You do not have the required "resourcemanager.projects.create" permission to create projects in this location.` | Your organization administrator doesn't allow users to create new Google Cloud projects. Select an existing Google Cloud project, or ask your administrator to allow project creation or grant you the Project Creator role, `roles/resourcemanager.projectCreator`. For details on project creation permissions and error messages, see [Create a project](https://docs.cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project) and [Permission error messages](https://docs.cloud.google.com/iam/docs/permission-error-messages) in the Google Cloud documentation. |
| `insufficient authentication scopes` or missing cached token | Run `gwscli <service> <action> --show-scopes` or `gwscli auth login --print-scope-only <service> <action>` to check the required scopes. If using an OAuth client, inspect active scopes with `gwscli auth status` and run `gwscli auth login <service> <action>` in your local terminal. If passing `--oauth_token`, mint a new access token that includes the required scopes. |
| Sign-in doesn't finish over SSH or in a remote shell | Run `gwscli auth login` on a local machine with a browser, forward the printed `127.0.0.1:<port>` over SSH, or pass a token with `--oauth_token`. See [Browser redirect requirements](https://developers.google.com/workspace/guides/workspace-cli.md.txt#browser-redirect). |
| Service not enabled or permission denied | Enable the required services from [Step 1: Enable the required services](https://developers.google.com/workspace/guides/workspace-cli.md.txt#enable-apis) in the Google Cloud project that owns your OAuth client or that issued the token passed to `--oauth_token`. For user-delegated OAuth clients, verify that **Use this client for an AI-powered agent** is selected, and add your account under **Test users** if your consent screen audience is **External**. |
| `gwscli chat send_message` fails | Configure a Chat app in your Google Cloud project as described in [Configure the Chat API](https://developers.google.com/workspace/chat/configure-chat-api.md.txt). Sending messages requires a Google Workspace account and isn't supported for personal Google Accounts. |
| Command pauses and waits for input | The action requires human-in-the-loop confirmation on standard error. Review the prompt and provide an approval choice on standard input. See [Human-in-the-loop verification](https://developers.google.com/workspace/guides/workspace-cli.md.txt#human-in-the-loop). |

## Related topics

- [Google Workspace CLI release notes](https://developers.google.com/workspace/cli/release-notes)
- [Configure Google Workspace MCP servers](https://developers.google.com/workspace/guides/configure-mcp-servers.md.txt)
- [Handle user approvals with form elicitation](https://developers.google.com/workspace/guides/mcp-elicitation.md.txt)
- [Install developer tools](https://developers.google.com/workspace/guides/developer-tools.md.txt)
- [Use Large Language Models (LLMs) to develop on
  Google Workspace](https://developers.google.com/workspace/guides/build-with-llms)