get_email from yesterday fetches one message by ID. But you need all invoice emails from a specific client — without scrolling through the inbox manually. Gmail's search syntax handles this server-side.
Like subject:Invoice from:acme@client.com is:unread? I use that in the Gmail search bar all the time.
That exact syntax, passed as a query parameter to GMAIL_FETCH_EMAILS. The filter runs on Gmail's servers — only matching messages cross the network. No loading everything and filtering in Python:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": "subject:Invoice is:unread", "max_results": 20}
)
messages = result.get("messages", [])I see both GMAIL_FETCH_EMAILS and GMAIL_SEARCH_EMAILS in the Action enum. Which one do I use for a query?
GMAIL_FETCH_EMAILS with a query parameter. GMAIL_SEARCH_EMAILS is an alias — both accept the same query string. The convention in this track is to use GMAIL_FETCH_EMAILS consistently so the pattern stays uniform across all lessons.
So I can search for subject:Invoice and get back only the invoice threads. Then pass each ID to get_email for the full content.
Invoice monitoring in two function calls. The freelancer who never misses a payment confirmation:
def search_emails(query: str) -> list:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": query, "max_results": 50}
)
messages = result.get("messages", [])
print(f"Found {len(messages)} messages matching '{query}'")
return messagesI have been manually searching for invoice confirmation emails for years. One function call from now on.
The query string is your invoice filter. Every Gmail search operator — from:, to:, subject:, is:unread, after:2026/04/01 — works the same way. Server-side filtering means fast results regardless of inbox size.
GMAIL_FETCH_EMAILS accepts a query parameter using the same syntax as the Gmail search bar:
result = toolset.execute_action(
action=Action.GMAIL_FETCH_EMAILS,
params={'query': 'subject:Invoice', 'max_results': 20}
)
messages = result.get('messages', [])'subject:Invoice' — emails with Invoice in the subject'from:client@example.com' — emails from a specific sender'is:unread' — unread emails only'after:2026/01/01' — emails after a dateThe returned list contains message dicts — each with at least a messageId you can pass to GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID for the full content.
get_email from yesterday fetches one message by ID. But you need all invoice emails from a specific client — without scrolling through the inbox manually. Gmail's search syntax handles this server-side.
Like subject:Invoice from:acme@client.com is:unread? I use that in the Gmail search bar all the time.
That exact syntax, passed as a query parameter to GMAIL_FETCH_EMAILS. The filter runs on Gmail's servers — only matching messages cross the network. No loading everything and filtering in Python:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": "subject:Invoice is:unread", "max_results": 20}
)
messages = result.get("messages", [])I see both GMAIL_FETCH_EMAILS and GMAIL_SEARCH_EMAILS in the Action enum. Which one do I use for a query?
GMAIL_FETCH_EMAILS with a query parameter. GMAIL_SEARCH_EMAILS is an alias — both accept the same query string. The convention in this track is to use GMAIL_FETCH_EMAILS consistently so the pattern stays uniform across all lessons.
So I can search for subject:Invoice and get back only the invoice threads. Then pass each ID to get_email for the full content.
Invoice monitoring in two function calls. The freelancer who never misses a payment confirmation:
def search_emails(query: str) -> list:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": query, "max_results": 50}
)
messages = result.get("messages", [])
print(f"Found {len(messages)} messages matching '{query}'")
return messagesI have been manually searching for invoice confirmation emails for years. One function call from now on.
The query string is your invoice filter. Every Gmail search operator — from:, to:, subject:, is:unread, after:2026/04/01 — works the same way. Server-side filtering means fast results regardless of inbox size.
GMAIL_FETCH_EMAILS accepts a query parameter using the same syntax as the Gmail search bar:
result = toolset.execute_action(
action=Action.GMAIL_FETCH_EMAILS,
params={'query': 'subject:Invoice', 'max_results': 20}
)
messages = result.get('messages', [])'subject:Invoice' — emails with Invoice in the subject'from:client@example.com' — emails from a specific sender'is:unread' — unread emails only'after:2026/01/01' — emails after a dateThe returned list contains message dicts — each with at least a messageId you can pass to GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID for the full content.
Create a free account to get started. Paid plans unlock all tracks.