| name | googleworkspace |
| description | Manage Google Drive, Gmail, Calendar, Sheets, Docs, and Chat via the gws CLI |
| metadata | {"shelllm":{"requires":{"bins":["gws"]}}} |
googleworkspace — Google Workspace via the gws CLI
Overview
The gws CLI provides access to Google Workspace APIs (Drive, Gmail, Calendar, Sheets, Docs, Chat, and more). Commands are dynamically generated from Google's Discovery Service.
gws <service> <resource> <method> [flags]
Helper commands (prefixed with +) provide shortcuts for common workflows.
Authentication
gws auth login
export GOOGLE_WORKSPACE_CLI_TOKEN=$(gcloud auth print-access-token)
Global flags
| Flag | Description |
|---|
--params '{...}' | URL/query parameters (JSON) |
--json '{...}' | Request body (JSON) |
--dry-run | Preview request without calling the API |
--page-all | Auto-paginate all results (NDJSON output) |
--upload <PATH> | Upload file content (multipart) |
--format <FMT> | Output format: json (default), table, yaml, csv |
Discovering commands
Always inspect before calling an unfamiliar method:
gws <service> --help
gws schema <service>.<resource>.<method>
Gmail
gws gmail +send --to alice@example.com --subject "Hello" --body "Hi there"
gws gmail +triage
gws gmail +read --message-id MESSAGE_ID
gws gmail +reply --message-id MESSAGE_ID --body "Thanks!"
gws gmail +reply-all --message-id MESSAGE_ID --body "Acknowledged"
gws gmail +forward --message-id MESSAGE_ID --to bob@example.com
gws gmail +watch
gws gmail users messages list --params '{"maxResults": 10}'
Calendar
gws calendar +agenda
gws calendar +agenda --timezone America/New_York
gws calendar +insert --title "Standup" --time "2026-05-02T09:00:00"
gws calendar events list --params '{"calendarId": "primary", "maxResults": 5}'
gws calendar freebusy query --json '{"timeMin": "...", "timeMax": "...", "items": [{"id": "primary"}]}'
Drive
gws drive files list --params '{"pageSize": 10}'
gws drive +upload ./report.pdf --name "Q1 Report"
gws drive files get --params '{"fileId": "FILE_ID", "alt": "media"}' -o output.pdf
gws drive files list --params '{"q": "name contains '\''budget'\''", "pageSize": 10}'
gws drive files create --json '{"name": "Projects", "mimeType": "application/vnd.google-apps.folder"}'
Sheets
gws sheets +read --spreadsheet SPREADSHEET_ID --range "Sheet1!A1:D10"
gws sheets +append --spreadsheet SPREADSHEET_ID --values "Alice,95,A"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1:C10"}'
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'
Docs
gws docs +write --document-id DOC_ID --text "New paragraph of text"
gws docs documents get --params '{"documentId": "DOC_ID"}'
Chat
gws chat +send --space-id spaces/SPACE_ID --text "Deploy complete."
gws chat spaces list
Shell tips
Safety rules
- Confirm with the user before executing write or delete operations.
- Prefer
--dry-run for destructive operations until the user confirms.
- Never output secrets, API keys, or tokens directly.
Exit codes
| Code | Meaning |
|---|
| 0 | Success |
| 1 | API error (4xx/5xx) |
| 2 | Auth error |
| 3 | Validation error |
| 4 | Discovery error |
| 5 | Internal error |