Skip to main content
The Gmail resource exposes a Gmail account as a virtual filesystem mounted at some prefix such as /gmail/. For Google OAuth setup, see Google Workspace Setup.

Config

Filesystem Layout

Example:
Label directories appear at the root. System labels use the Gmail label ID (e.g., INBOX, SENT, STARRED). User-created labels use their label name with spaces replaced by underscores.

Date Directories

Inside each label, messages are grouped into date subdirectories formatted as YYYY-MM-DD. The date is derived from the message’s internalDate (epoch milliseconds) converted to a calendar date.

Message Files

Each message is stored as a .gmail.json file. The filename shape is:
Subjects are sanitized for filesystem safety and truncated when necessary. The message ID is embedded after __ and before .gmail.json.

Attachments

Messages that have attachments get a companion subdirectory with the same base name (without .gmail.json). Decoded attachment files are placed inside:

Cache

The Gmail resource uses IndexCacheStore (same as Slack, Discord, and other resources). Index entries store label IDs, message IDs, and message metadata. There is no separate content cache — file content caching is handled by the workspace IOResult mechanism.

Example

See examples/gmail/gmail.py for the full working example.

Finding IDs

Resource-specific commands require message IDs. These can be extracted from the filesystem:

Working with Large Labels

Labels with many messages are split into date directories. Tips for efficient access:

Shell Commands

Standard commands available on the mounted Gmail tree: Acting on Gmail (send, reply, forward, triage, raw API calls) goes through the gws CLI when installed.