Search a mail folder
search_mailFind messages in a Proton Mail folder by sender, recipient, subject, text, date, or unread status, and return paged results with message IDs for reading threads or attachments.
Instructions
Search one mail folder for messages matching the filters and return a page of rows, newest first; nothing is changed or marked read.
Use it to find messages and the message_id that read_thread, show_thread, list_attachments and preview_action(ids=...) take. Use count_mail when only a number is needed, and preview_action(query=...) to select a whole set for a change, not pages.
All filters apply together. from_, to and subject are case-insensitive header substrings; text searches the raw message, so on a large folder give since or before or it times out, and each message in that range is then read; query adds and, or and not. To continue, pass next_cursor with identical filters; it follows one UID snapshot.
Returns messages (message_id; folder, uidvalidity and uid, the canonical real-folder handle, with alias added for a view such as All Mail; from, to, subject, date, date_local, seen and a snippet), next_cursor, total, total_is_exact and partial. A null next_cursor means finished only when partial=false; partial=true has partial_reason. text_scan_limited with a next_cursor means follow it; the same reason with a null cursor and a hint means a message was left undecided; otherwise narrow the search or reindex. skipped_uids names, by UID in the searched folder, messages skipped on this page because their read stalled. Unbounded All Mail may apply a 30-day applied_since; timeouts add timed_out and error; incomplete index coverage adds index_note and index_status. Malformed INTERNALDATE values are left out of matches and totals.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | To header contains this text, ignoring case. | |
| text | No | Raw message contains this, ignoring case. Bridge reads the whole folder to answer, which a large folder cannot finish in time, whatever the dates. There, give since or before: the messages in that range are read one by one, and next_cursor continues the reading. | |
| from_ | No | Sender contains this text, ignoring case. | |
| limit | No | Messages per page; above 100 is capped at 100. | |
| query | No | Conditions joined with and, or and not; the entries of one object all apply. from, to, subject and text match substrings; and and or take a list of 1 to 20 queries, not takes one query. At most 20 conditions in 5 nested levels. For example {"or": [{"from": "a@example.test"}, {"subject": "invoice", "not": {"text": "unsubscribe"}}]}. | |
| since | No | Earliest date, inclusive, as YYYY-MM-DD. | |
| before | No | Latest date, exclusive, as YYYY-MM-DD. | |
| cursor | No | next_cursor from the previous page, with identical filters. | |
| folder | No | The mailbox to search, by its exact LIST name, such as INBOX, Archive, Sent, All Mail, Folders/Receipts or Labels/Work. | INBOX |
| subject | No | Subject contains this text, ignoring case. | |
| unread_only | No | Only unread messages. Takes only a JSON boolean. | |
| exclude_text | No | Leave out messages whose text contains this, as Bridge matches it. | |
| exclude_subject | No | Leave out messages whose subject contains this text. | |
| include_snippets | No | false omits snippets and avoids body and structure retrieval. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||