Gmail CLI
for cmdhub.
Messages, threads, drafts, labels, and attachments with command-level schema.
cmdhub get gmail
data_object Agent Contract
Agents should start with auth/status and discovery commands, inspect schemas before composition, and treat commands marked as mutating as state-changing operations.
Output
Use human output for reading, `--json` for one object, and `--jsonl` for pipes.
Auth
Google OAuth. Used for Gmail messages, threads, drafts, labels, and attachments.
Refs
Prefer list/search, then short refs or piped JSONL. Use `resolve` to inspect cached refs.
Schemas
Use `gmail schema` and `catalog.json` to inspect fields, flags, examples, and side effects.
Auth scopes
openidemailprofilehttps://mail.google.com/terminal Command Reference
Generated from source. Global flags apply to all commands.
Global Flags
--json
bool
Emit JSON machine output--jsonl
bool
Emit JSONL records for piping--output, -o
string
Compatibility output mode: json|jsonl. Prefer --json or --jsonl--view
string = summary
View mode: summary|full--profile
string = default
Config/auth profile--config
string
Config path override--quiet, -q
bool
Suppress non-essential diagnostics--debug
bool
Enable debug diagnostics--limit
int = 50
Maximum items to emit--page-size
int = 50
Requested upstream page size--cursor
string
Continuation cursor--no-paginate
bool
Fetch only one page--version, -v
bool
Print version informationgmail attachment
Work with Gmail attachmentsgmail attachment get
Download a Gmail attachmentDownload one Gmail attachment to a local file or emit its contents.
Pass –message-id and –attachment-id directly, or pipe one full message item that contains exactly one attachment. If the message contains multiple attachments, pass –attachment-id explicitly. With –message-id, a local attachment ref such as a1 is resolved within that message if it is not already cached. Use –emit-content to include a UTF-8 text preview and base64 payload in the command output for agent-visible verification.
--attachment-id
string
Gmail attachment id--emit-content
bool
Include text/base64 content in the response--message-id
string
Gmail message id--output-file
string
Path to save the attachmentgmail auth
Manage Gmail authenticationgmail auth login
Start Gmail OAuth logingmail auth logout
Clear auth stategmail auth refresh
Refresh stored tokengmail auth status
Show auth statusgmail auth whoami
Return the authenticated Gmail addressgmail capabilities
Describe capabilitiesgmail config
Inspect local configurationgmail config explain
Explain resolved configurationgmail doctor
Run Gmail adapter diagnosticsgmail draft
Work with Gmail draftsgmail draft create
Create a Gmail draftCreate a new Gmail draft.
Pass recipients with –to, then provide –subject and –body. Use repeated –attach flags to include local files.
--attach
stringSlice = []
File path(s) to attach--body
string
Draft body--subject
string
Draft subject--to
string
Comma-separated recipientsgmail draft delete
Delete a draftDelete one Gmail draft.
The target may be a canonical draft id, a short ref such as d1, or one piped draft item.
--id
string
Draft idgmail draft get
Get a draftGet one Gmail draft.
The target may be a canonical draft id, a short ref such as d1, a shortened canonical id, or one piped draft item.
--id
string
Draft idgmail draft list
List draftsList Gmail drafts and cache local draft references such as d1.
Use –query with Gmail search syntax to narrow drafts by subject, recipient, or tokens. Use –jsonl when the next step is another draft command such as get, send, or delete.
--query
string
Raw Gmail search query for draftsgmail draft send
Send a draftSend one Gmail draft.
The target may be a canonical draft id, a short ref such as d1, or one piped draft item from stdin.
--id
string
Draft idgmail draft update
Update a draftUpdate one Gmail draft.
The target may be a canonical draft id, a short ref such as d1, or one piped draft item. Omitted fields are preserved from the current draft.
--attach
stringSlice = []
File path(s) to attach--body
string
Draft body--id
string
Draft id--subject
string
Draft subject--to
string
Comma-separated recipientsgmail filter
Manage simple Gmail filtersgmail filter create
Create a simple Gmail filter--archive
bool
Skip inbox for matching mail--from
string
Filter sender criteria--important
bool
Mark matching mail important--label
string
Comma-separated label IDs, names, or local refs to apply--query
string
Provider-native Gmail filter query criteria--read
bool
Mark matching mail read--star
bool
Star matching mail--subject
string
Filter subject criteria--to
string
Filter recipient criteria--yes
bool
Confirm filter creationgmail filter delete
Delete a Gmail filter--id
string
Gmail filter id or local ref--yes
bool
Confirm filter deletiongmail filter get
Get a Gmail filter--id
string
Gmail filter id or local refgmail filter list
List Gmail filtersgmail history
Inspect Gmail mailbox historygmail history list
List Gmail history records from a known historyId--history-type
stringSlice = []
History type filter; repeat or comma-separate--start-history-id
string
Gmail historyId from message/thread metadatagmail label
Work with Gmail labelsList Gmail labels and cache local label refs such as l1.
Use this before label add or label remove if you need to inspect available labels for the current mailbox.
gmail label create
Create a user Gmail label--name
string
New user label namegmail label delete
Delete a user Gmail label--id
string
Gmail label id, name, or local ref--yes
bool
Confirm destructive label deletiongmail label get
Get a Gmail label--id
string
Gmail label id, name, or local refgmail label list
List Gmail labels--query
string
Filter labels locally by name or idgmail label update
Rename a user Gmail label--id
string
Gmail label id, name, or local ref--name
string
Updated user label namegmail login
Start Gmail OAuth logingmail logout
Clear auth stategmail message
Work with Gmail messagesWork with Gmail messages.
Use explicit subcommands such as list, get, reply, or archive. As a convenience,
gmail message <message-id> is treated as gmail message get <message-id>.
gmail message archive
Archive a message by removing INBOXArchive one Gmail message.
The target may come from an explicit id, a short ref such as m1, or piped message items. Batch archive requires –all.
--all
bool
Confirm batch archive--id
string
Gmail message idgmail message create
Create a new Gmail message or draftCreate a new Gmail message.
Pass –draft to save the message as a draft. Without –draft this command sends immediately.
--attach
stringSlice = []
File path(s) to attach--body
string
Message body--draft
bool
Save as draft instead of sending--subject
string
Message subject--to
string
Comma-separated recipientsgmail message delete
Permanently delete a messagePermanently delete one Gmail message.
Use this carefully. The target may come from an explicit id, a short ref such as m1, or piped message items. Batch permanent delete requires –all –yes.
--all
bool
Confirm batch permanent delete--id
string
Gmail message id--yes
bool
Confirm destructive permanent deletegmail message forward
Create a forward draftCreate a Gmail forward draft for one message.
The target may come from an explicit id, a short ref such as m1, or one piped message item. This command creates a draft rather than sending immediately.
--body
string
Forward body text--id
string
Gmail message id--to
string
Comma-separated recipientsgmail message get
Get a full message with parsed MIME contentGet one Gmail message in full detail.
The target may be:
- a full Gmail message id
- a stored short id such as 19d…9b7
- a cached marker such as m1
- one piped message item from stdin
If you already listed messages, prefer a short ref or piped jsonl instead of copying the full id. Use message get when you need the subject, parsed body, headers, or attachments for a message you just found with message list.
--id
string
Gmail message idgmail message important
Mark a message as important--all
bool
Confirm batch important--id
string
Gmail message idgmail message label
Modify Gmail labelsAdd or remove Gmail labels on one message.
List labels first if you need valid label refs, then pass the message target directly or via stdin.
gmail message label add
Add labels to a messageAdd one or more Gmail labels to one message.
Pass –label with one or more Gmail label ids, names, or local refs such as l1. The target message may come from an explicit id, a short ref such as m1, or piped message items. Batch label changes require –all.
--all
bool
Confirm batch label add--id
string
Gmail message id--label
string
Comma-separated label IDs, names, or local refs to addgmail message label remove
Remove labels from a messageRemove one or more Gmail labels from one message.
Pass –label with one or more Gmail label ids, names, or local refs such as l1. The target message may come from an explicit id, a short ref such as m1, or piped message items. Batch label changes require –all.
--all
bool
Confirm batch label remove--id
string
Gmail message id--label
string
Comma-separated label IDs, names, or local refs to removegmail message list
List messagesList Gmail messages and cache local follow-up references.
Human output shows local markers such as m1 and shortened canonical ids. Use –jsonl when you want the results to feed directly into another gmail command. If you need message bodies, headers, or attachments, follow up with gmail message get rather than stopping at list output.
The most common next steps are:
- gmail message get
- gmail message reply
- gmail message archive
- gmail attachment get
--from
string
Filter by sender--has-attachment
bool
Filter to messages with attachments--in
string
Mailbox/search bucket, e.g. inbox, sent, trash--include-spam-trash
bool
Include spam and trash in search results--label
string
Comma-separated Gmail label IDs--newer-than
string
Gmail relative time filter, e.g. 7d--older-than
string
Gmail relative time filter, e.g. 30d--query
string
Raw Gmail search query--subject
string
Filter by subject terms--to
string
Filter by recipient--unread
bool
List unread messages onlygmail message not-important
Remove important marker from a message--all
bool
Confirm batch not-important--id
string
Gmail message idgmail message read
Mark a message as readMark one Gmail message as read.
The target may come from an explicit id, a short ref such as m1, or piped message items. Batch read marking requires –all.
--all
bool
Confirm batch read marking--id
string
Gmail message idgmail message reply
Send or draft a replySend or draft a Gmail reply for one message.
The target may come from an explicit id, a short ref such as m1, or one piped message item. Pass –draft to save the reply as a draft. Without –draft this command sends immediately.
--all
bool
Reply to all recipients--body
string
Reply body text--draft
bool
Save as draft instead of sending--id
string
Gmail message idgmail message star
Star a message--all
bool
Confirm batch star--id
string
Gmail message idgmail message trash
Move a message to trashMove one Gmail message to trash.
The target may come from an explicit id, a short ref such as m1, or piped message items. Batch trash requires –all.
--all
bool
Confirm batch trash--id
string
Gmail message idgmail message unread
Mark a message as unreadMark one Gmail message as unread.
The target may come from an explicit id, a short ref such as m1, or piped message items. Batch unread marking requires –all.
--all
bool
Confirm batch unread marking--id
string
Gmail message idgmail message unstar
Remove star from a message--all
bool
Confirm batch unstar--id
string
Gmail message idgmail message untrash
Restore a message from trashRestore one Gmail message from trash.
The target may come from an explicit id, a short ref such as m1, or piped message items. Batch restore requires –all.
--all
bool
Confirm batch untrash--id
string
Gmail message idgmail profile
Manage provider profilesgmail profile create
Create an unauthenticated provider profilegmail profile delete
Delete a local provider profilegmail profile list
List provider profilesgmail profile rename
Rename a local provider profilegmail profile use
Set the default provider profilegmail resolve
Resolve a local marker or stored short referenceResolve a Gmail short reference into its canonical payload.
Use this when you have a marker such as m1, t1, d1, l1, or u1, or a stored short id such as 19d…9b7, and want to inspect what it refers to.
Resolution is profile-scoped. If a marker does not resolve, verify –profile and rerun the relevant list command.
gmail schema
Emit Gmail adapter schema hintsShow schema hints for the Gmail resource payloads emitted or accepted by this CLI.
Use this when you need to understand the shape of structured output for follow-up automation or parsing.
--in
bool
Show input schema--out
bool
Show output schemagmail send-as
Inspect Gmail send-as aliasesgmail send-as get
Get one send-as aliasgmail send-as list
List verified sender aliasesgmail thread
Work with Gmail threadsgmail thread archive
Archive a thread by removing INBOX from existing messages--all
bool
Confirm batch thread mutation--id
string
Gmail thread idgmail thread delete
Permanently delete a thread--all
bool
Confirm batch permanent delete--id
string
Gmail thread id--yes
bool
Confirm destructive permanent deletegmail thread get
Get a full threadGet one Gmail thread in full detail.
The target may be a canonical thread id, a short ref such as t1, a shortened canonical id, or one piped thread item.
--id
string
Gmail thread idgmail thread important
Mark existing messages in a thread as important--all
bool
Confirm batch thread mutation--id
string
Gmail thread idgmail thread list
List threadsList Gmail threads and cache local thread references such as t1.
Use this when you want to act on conversation-level results rather than individual messages. Use –jsonl when the next step should consume one thread item from stdin.
--from
string
Filter by sender--has-attachment
bool
Filter to threads with attachments--in
string
Mailbox/search bucket, e.g. inbox, sent, trash--include-spam-trash
bool
Include spam and trash in search results--label
string
Comma-separated Gmail label IDs--newer-than
string
Gmail relative time filter, e.g. 7d--older-than
string
Gmail relative time filter, e.g. 30d--query
string
Raw Gmail search query--subject
string
Filter by subject terms--to
string
Filter by recipient--unread
bool
List unread threads onlygmail thread not-important
Remove important from existing messages in a thread--all
bool
Confirm batch thread mutation--id
string
Gmail thread idgmail thread read
Mark a thread as read--all
bool
Confirm batch thread mutation--id
string
Gmail thread idgmail thread reply
Send or draft a reply to the latest message in a threadSend or draft a Gmail reply using the latest message in a thread.
This is useful when your workflow is organized around conversation results from thread list rather than message list. Pass –draft to save the reply as a draft. Without –draft this command sends immediately.
--all
bool
Reply to all recipients--body
string
Reply body text--draft
bool
Save as draft instead of sending--id
string
Gmail thread idgmail thread star
Star existing messages in a thread--all
bool
Confirm batch thread mutation--id
string
Gmail thread idgmail thread trash
Move a thread to trash--all
bool
Confirm batch thread trash--id
string
Gmail thread idgmail thread unread
Mark a thread as unread--all
bool
Confirm batch thread mutation--id
string
Gmail thread idgmail thread unstar
Unstar existing messages in a thread--all
bool
Confirm batch thread mutation--id
string
Gmail thread idgmail thread untrash
Restore a thread from trash--all
bool
Confirm batch thread restore--id
string
Gmail thread idgmail vacation
Manage Gmail vacation respondergmail vacation disable
Disable vacation responder--yes
bool
Confirm vacation responder disablegmail vacation get
Get vacation responder settingsgmail vacation update
Enable or update vacation responder settings--body
string
Vacation responder plain-text body--contacts-only
bool
Restrict replies to contacts--domain-only
bool
Restrict replies to domain--end
string
Optional provider end time--start
string
Optional provider start time--subject
string
Vacation responder subject--yes
bool
Confirm vacation responder updategmail version
Show gmail version informationplay_circle Live Examples
Output captured from a real workspace. Regenerate with
scripts/gen-docs.sh --update.
auth
Authenticated as kestrelphilip@gmail.com Next steps: - Messages: gmail message list --limit 10 - Drafts: gmail draft list --limit 10 - Capabilities: gmail capabilities
messages
REF TITLE STATUS WHEN OWNER
m1 A new device logged into your account unread Sat, 30 May 2026 07:45:31 +0000 Notion Team <notify@updates.notion.so>
m2 Declined: Location Timezone Target {id}... @ Tue Jun 2, 2026 10am - 10:30am (GMT+2) (kestrelphilip@gmail.com) unread Fri, 29 May 2026 06:48:47 +0000 Philip Sterne <sterne@gmail.com>
m3 Declined: Location Timezone Target {id} @ Tue Jun 2, 2026 10am - 10:30am (GMT+2) (kestrelphilip@gmail.com) unread Fri, 29 May 2026 06:48:44 +0000 Philip Sterne <sterne@gmail.com>
m4 Declined: Location Timezone Target {id} @ Tue Jun 2, 2026 10am - 10:30am (GMT+2) (kestrelphilip@gmail.com) unread Fri, 29 May 2026 06:48:43 +0000 Philip Sterne <sterne@gmail.com>
m5 Declined: Location Timezone Target {id} @ Tue Jun 2, 2026 10am - 10:30am (GMT+2) (kestrelphilip@gmail.com) unread Fri, 29 May 2026 06:48:42 +0000 Philip Sterne <sterne@gmail.com>
Next steps:
- More: gmail message list --limit 5 --cursor c1
- Open: gmail message get m1
- Messages: gmail message list --limit 10
- Drafts: gmail draft list --limit 10threads
REF TITLE STATUS WHEN OWNER
t1 A new device logged into your account 1 messages Sat, 30 May 2026 07:45:31 +0000 Notion Team <notify@updates.notion.so>
t2 Declined: Location Timezone Target {id}... @ Tue Jun 2, 2026 10am - 10:30am (GMT+2) (kestrelphilip@gmail.com) 1 messages Fri, 29 May 2026 06:48:47 +0000 Philip Sterne <sterne@gmail.com>
t3 Declined: Location Timezone Target {id} @ Tue Jun 2, 2026 10am - 10:30am (GMT+2) (kestrelphilip@gmail.com) 2 messages Fri, 29 May 2026 06:48:44 +0000 Philip Sterne <sterne@gmail.com>
Next steps:
- More: gmail thread list --limit 3 --cursor c1
- Open: gmail thread get t1
- Messages: gmail message list --limit 10
- Drafts: gmail draft list --limit 10labels
REF TITLE
l1 CHAT
l2 SENT
l3 INBOX
l4 IMPORTANT
l5 TRASH
l6 DRAFT
l7 SPAM
l8 CATEGORY_FORUMS
l9 CATEGORY_UPDATES
l10 CATEGORY_PERSONAL
l11 {id}
l12 CATEGORY_SOCIAL
l13 STARRED
l14 UNREAD
Next steps:
- Open: gmail label get l1
- Messages: gmail message list --limit 10
- Drafts: gmail draft list --limit 10
- Capabilities: gmail capabilitiesdrafts
REF TITLE STATUS WHEN OWNER
d1 cmdhub-eval-draft draft Tue, 26 May 2026 11:37:20 -0500 test@example.com
d2 {id} draft Tue, 26 May 2026 12:31:26 -0400 kestrelphilip@gmail.com
d3 Re: Join your team on Notion draft Thu, 23 Apr 2026 09:40:22 -0500 Notion Team <notify@updates.notion.so>
Next steps:
- Open: gmail draft get d1
- Messages: gmail message list --limit 10
- Drafts: gmail draft list --limit 10
- Capabilities: gmail capabilitiesalt_route Composition Patterns
Bridge your ecosystem with zero middleware.
# Inspect one message and then hand it to an agent transform
gmail message list --label INBOX --limit 1 --jsonl \
| agent adapt --to "gcal event create"