Overview
The Gmail service provides access to Gmail v1 API for sending email, reading messages, managing labels, and configuring filters. API:gmail (v1)
Common Use Cases
- Send and read emails
- Search messages
- Manage labels and filters
- Set up push notifications
- Triage inbox
Helper Commands
+send
Send a simple text email:
- Automatic RFC 2822 formatting
- Base64 encoding handled internally
- For HTML bodies or attachments, use the raw API
+watch
Set up push notifications to a Pub/Sub topic:
- Pub/Sub topic must exist
- Topic must grant
publishpermission togmail-api-push@system.gserviceaccount.com
+triage
Query unread messages and mark as read:
Command Examples
List Messages
Example Response
Example Response
Get Message Details
Example Response
Example Response
Send a Message
Simple text email
Using helper
Modify Message Labels
Mark as read
Archive message
Add label
Trash a Message
Manage Labels
List labels
Create label
Delete label
Get User Profile
Example Response
Example Response
Manage Drafts
List drafts
Create draft
Send draft
Manage Filters
List filters
Create filter
Search Operators
Gmail search syntax in theq parameter:
From specific sender
Has attachment
Date range
Combine conditions
Resources
users.messages- Email messagesusers.threads- Email threadsusers.labels- Label managementusers.drafts- Draft messagesusers.settings.filters- Email filtersusers.settings.forwardingAddresses- Forwarding configusers.settings.sendAs- Send-as aliases
gws gmail <resource> --help to see all available methods.
Related Commands
Calendar
Schedule meetings from email
Chat
Team messaging