Search and list messages
list_messagesSearch Gmail messages using Gmail query syntax and get summaries with id, subject, sender, and date. Filter by labels, exclude spam/trash, and paginate results.
Instructions
Searches the mailbox with Gmail query syntax and returns one summary per message: id, threadId, labelIds, snippet, from, to, subject, date, internalDate. Filter with query (same operators as the Gmail search box: from:, to:, subject:, is:unread, is:starred, has:attachment, label:, newer_than:7d, before:/after:) and/or label_ids (all must match). Spam and trash are excluded unless include_spam_trash=true. Paginate with page_token from nextPageToken; page_size defaults to 25 (max 100 — each summary costs one metadata read, throttled to a few at a time). A message deleted between the search and its metadata read is skipped, so a page can hold slightly fewer summaries than page_size. Set include_metadata=false to get bare ids only (cheapest). resultSizeEstimate is an estimate, not an exact count. Read a full body with get_message; read a whole conversation with get_thread.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Gmail query syntax, e.g. "from:amy@example.com is:unread newer_than:7d has:attachment subject:invoice". Same operators as the Gmail search box. | |
| label_ids | No | Only messages carrying ALL of these label ids (see list_labels). | |
| page_size | No | Messages per page (1..100, default 25). | |
| page_token | No | nextPageToken from the previous page. | |
| include_metadata | No | false = bare ids only, no per-message metadata reads (default true). | |
| include_spam_trash | No | Also search SPAM and TRASH (default false). |