> ## Documentation Index
> Fetch the complete documentation index at: https://learn.workflow.dog/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Messages

> Find Gmail message IDs using Gmail search syntax and date filters.

The **Search Messages** action searches a Gmail mailbox and returns matching
message IDs. Its query uses the same operators as Gmail's search bar.

## Inputs

| Input                    | Type           | Required | Description                                                 |
| ------------------------ | -------------- | -------- | ----------------------------------------------------------- |
| **Third-party account**  | Google account | Yes      | Account whose mailbox is searched.                          |
| **Query**                | String         | Yes      | Gmail search query. Whitespace-only text is ignored.        |
| **Max Results**          | Number         | No       | Maximum IDs to return, from `1` to `100`. Defaults to `10`. |
| **Include Spam & Trash** | Boolean        | No       | Whether Spam and Trash are included. Defaults to `false`.   |
| **After Date**           | Date           | No       | Only messages after this calendar date.                     |
| **Before Date**          | Date           | No       | Only messages before this calendar date.                    |

The date inputs are appended to the Gmail query using `after:YYYY/M/D` and
`before:YYYY/M/D`. You can combine them with operators in **Query**:

```text theme={null}
from:billing@example.com has:attachment
```

## Outputs

| Output          | Type            | Description                          |
| --------------- | --------------- | ------------------------------------ |
| **Message IDs** | List of strings | Gmail IDs for the matching messages. |

This action returns identifiers only. Repeat over **Message IDs** and use **Get
Message by ID** when you need subjects, bodies, or attachments.

## Example: process recent invoices

Configure **Search Messages** with:

* **Query** — `subject:invoice has:attachment`
* **After Date** — The start of the current month.

Repeat over the returned **Message IDs** and pass each one to **Get Message by
ID** to load the invoice email's content and attachments.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Expected messages are missing">
    Test the same query in Gmail, check the date boundaries, and enable
    **Include Spam & Trash** if those folders should be searched.
  </Accordion>

  <Accordion title="Only some matches are returned">
    Increase **Max Results** up to `100`. The action returns a single result
    page and does not expose pagination.
  </Accordion>
</AccordionGroup>
