Skip to main content

Search messages

GET 

/api/accounts/:accountId/search

Searches the account's folders with IMAP SEARCH and streams the results as they are found, as newline-delimited JSON (application/x-ndjson). Each line is one event: start (with totalFolders), progress for each folder, indexing while the server builds its full-text index, matches with the message headers found in a folder (each tagged with folder and folderName), and finally done with the total.

At least one criterion is required. With only q, a message matches when q is in its subject, from, to or body. When any other criterion is set, including filter, all given criteria must match and q is searched in the full text. Folders are searched in order, Inbox and the other special folders first, and the search stops once limit messages are found. Folders under Virtual and the All Mail folder are never searched, and folder cannot name them. Trash is skipped unless includeTrash is set or folder names it; a folder that fails is skipped.

Errors after the stream has started, including an unknown folder, arrive as a line { "type": "error", "error": "..." }, not as an HTTP status.

Request​

Responses​

Newline-delimited search events.