For the complete documentation index, see llms.txt. This page is also available as Markdown.

Message Search

Use message search to find messages across every mailbox Material syncs, then take bulk actions on the results. You can also save a search as a detection.

To open message search, from the left navigation expand Explorer, then click Messages. You can also use ⌘K to open the quick action menu from anywhere in the Material UI and search messages from there.

Search modes

Message search has three modes, which you choose with Search Mode at the top of the search:

  • Quick: a form where you search by Date range, To, From, Subject, Message ID, and Has attachments, without writing a query.

  • Prompt: describe the messages you're looking for in plain English, and Material writes the query for you.

  • Query: write the query yourself in MQL (Material Query Language), using the syntax and fields on this page.

Prompt mode isn't available if you've opted out of Material's GenAI capabilities.

Quick and Prompt both create an MQL query. To see it, switch to Query. This is a good way to learn the syntax, or to get a valid query you can copy into a custom detection, a force unlock request, or the Messages search API.


Write a query

In Query mode, Material suggests fields, operators, and values as you type, and checks the query as you go. Search is only available when the query is valid.

  • Use the DOWN and UP arrow keys to move through the suggestions, then press ENTER or TAB to add the one you've selected.

  • Press ESCAPE to close the suggestions, or DOWN to open them again.

  • Your recent searches also show up in the suggestions, so you can rerun a query quickly.

Every query is made of fields, operators, and values. For example, this query finds unread messages from Gmail addresses that failed SPF:

Fields

Fields are grouped under two namespaces:

Namespace
What it searches
Examples

message

The message itself: sender, recipients, subject, headers, attachments, links, mailbox status, and how Material classified it

message.subject, message.from.addresses, message.attachments.has_attachments

account

The mailbox the message is in

account.email

Separate each level of a field with a period, for example message.from.domains.

Values

  • Put text values in double quotes, for example message.subject:~"invoice".

  • Write numbers without quotes, for example message.recipients.count > 50.

  • Use true/false fields on their own, without an operator. For example, message.status.is_inbox finds messages in the inbox, and not message.status.is_inbox finds messages that aren't.

Operators

Operator
Meaning
Example

:~

Contains (not case-sensitive)

message.subject:~"invoice"

!:~

Doesn't contain (not case-sensitive)

message.from.domains!:~"example.com"

:

Contains (case-sensitive)

message.subject:"URGENT"

!:

Doesn't contain (case-sensitive)

message.subject!:"RE:"

==

Is exactly

message.headers.dmarc == "fail"

!=

Isn't exactly

message.headers.spf != "pass"

<, <=, >, >=

Less than, less than or equal to, greater than, greater than or equal to

message.recipients.count >= 100

is null

Has no value

message.subject is null

is not null

Has a value

message.headers.in_reply_to is not null

in

Value is in a list field

"<app-id>" in account.appsWithAccess

and

Both conditions must be true

message.status.is_inbox and message.links.has_links

or

Either condition must be true

message.status.is_spam or message.status.is_trash

not

The condition must be false

not message.attachments.has_attachments

( )

Group conditions

message.links.has_links and (message.status.is_inbox or message.status.is_unread)

in only works with list fields like account.appsWithAccess. To match one of several values, join conditions with or, for example message.subject:~"invoice" or message.subject:~"payment".

When you aren't sure which operator to use, use :~. It matches text anywhere in the field and ignores capitalization.

When a field holds more than one value, such as message.from.addresses or message.attachments.name, a positive operator like :~ matches if any value matches. A negative operator like !:~ matches only if none of the values match.

and is applied before or, so use parentheses whenever you combine them.

Regular expressions

To match a pattern, use a regex function. Regular expressions only work inside these functions, not with the operators above.

Function
Matches when

regex.contains(field, "pattern")

Part of the field matches the pattern (case-sensitive)

regex.icontains(field, "pattern")

Part of the field matches the pattern (not case-sensitive)

regex.match(field, "pattern")

The whole field matches the pattern (case-sensitive)

regex.imatch(field, "pattern")

The whole field matches the pattern (not case-sensitive)

You can add more than one pattern. The function matches if any of them match:

Patterns use RE2 syntax.

Example queries

Zipped attachments in the inbox

message.attachments.mime_type:~"zip" and message.status.is_inbox

Messages from Gmail senders in spam or trash

message.from.addresses:~"@gmail.com" and (message.status.is_spam or message.status.is_trash)

Messages that failed DMARC and include links

message.headers.dmarc == "fail" and message.links.has_links

Messages sent to a personal email address with an attachment

message.recipients.has_personal_email and message.attachments.has_attachments

Messages with any sensitive category

message.context.category.any

Messages marked suspicious

message.riskType.suspicious

Messages sent to an address where the username starts with "g," ends with "a," and is 8 characters long

regex.icontains(message.to, "g.{6}a@")


Search fields and detection fields

Custom detections, custom sensitive categories, sensitive category exemptions, and force unlock requests use the same MQL, with two differences:

  • Some fields are search-only. message.context, message.riskType, account.appsWithAccess, and account.appsWithContentAccess describe how Material has already classified a message, so they're only available in message search. A search that uses them can't be saved as a detection.

  • Message body fields need content access. message.body fields are only available if you have permission to view message content.

The Available in column in the reference below shows where you can use each field.

Daily search quota

Message search has a daily quota. Searches you run in the Material UI, through the API, and through the Material MCP server all count toward the same quota.

Each search uses one unit of quota for every UTC day its date range covers, not one per search. For example:

  • A search over one week uses 7 units.

  • Ten searches over the same week use 70 units.

  • One search over a year uses 365 units.

  • A search over one full day in U.S. Eastern Time covers parts of two UTC days, so it uses 2 units.

Running exactly the same search again within 24 hours returns the saved results and doesn't use any quota.

When you reach the quota, the Material UI shows an error with the time the quota resets, and API requests return 429 Too Many Requests. A search that's rejected doesn't use any quota, so a search with a shorter date range may still run. The quota resets at midnight UTC.

If you have questions about your quota, contact Material support.

Search efficiently

These tips help your searches run faster and use less of your quota:

  • Search the shortest date range you need. A narrow date range is faster and uses less quota than a broad search you filter afterward.

  • Combine searches when possible. How complex a search is doesn't affect how much quota it uses, so one combined search uses less than several separate ones. For example, to find messages from two addresses, run message.from.addresses == "a@example.com" or message.from.addresses == "b@example.com" instead of one search per address. To cover a long period, use a few wide date ranges rather than many short ones.

  • Use exact match or contains when you know the value. Regex functions check every message in the date range, so they're slower than ==, :, and :~.

  • Use a true/false field when one fits. Fields like message.attachments.has_attachments, message.links.has_links, and message.recipients.has_personal_email are faster than a text or regex match that does the same thing.

  • Only search the message body when you need to. Material already pulls details like links, attachments, and recipients out of each message, and searching those fields is faster. If you do need the body, message.body.html, message.body.plain, and message.body.text all take about the same time.

  • Leave out conditions you don't need. The order of conditions in a query doesn't affect speed.

  • Reuse saved results. Running exactly the same query over the same date range within 24 hours returns the saved results, whether you search in the Material UI, through the API, or through the MCP server. When the Material UI shows saved results, a banner tells you how old they are. Click re-run the search in the banner only if you need the latest results, because that runs the search again and uses quota. If you start the same search twice at once, both run, so wait for the first one to finish before you retry.

Message Search Operator Reference

Property
Type
Description
Available in

message

object

Details about the message itself

Search, detections

message.subject

string

The message subject

Search, detections

message.from

object

The sender of the message

Search, detections

message.from.addresses

array

The sender's email addresses, including addresses from the Original-From and Original-Sender headers

Search, detections

message.from.display_names

array

The sender's display names

Search, detections

message.from.domains

array

The domains of the sender's email addresses

Search, detections

message.from.raw

string

The From header exactly as it appears in the message

Search, detections

message.to

string

The email addresses in the To header, without display names

Search, detections

message.cc

string

The email addresses in the Cc header, without display names

Search, detections

message.bcc

string

The email addresses in the Bcc header, without display names. Only available for sent messages from inside your organization.

Search, detections

message.recipients

object

Everyone the message was sent to: the to, cc, and bcc fields combined

Search, detections

message.recipients.addresses

string

The recipients' email addresses

Search, detections

message.recipients.count

number

The number of different email addresses the message was sent to. An address that appears in more than one field counts once. The sender's copy in their sent folder includes bcc recipients. A recipient's copy only includes the addresses that recipient can see.

Search, detections

message.recipients.has_disposable_email

bool

Messages where any recipient's address is from a disposable email service

Search, detections

message.recipients.has_personal_email

bool

Messages where any recipient's address is at a personal email domain, such as gmail.com. This doesn't check whether the address belongs to a specific person.

Search, detections

message.recipients.has_vip

bool

Messages where any recipient is marked as a VIP

Search, detections

message.participants

object

Everyone on the message: the sender and all recipients combined

Search, detections

message.participants.addresses

string

The email addresses of the sender and all recipients

Search, detections

message.participants.has_disposable_email

bool

Messages where anyone on the message has an address from a disposable email service

Search, detections

message.participants.has_personal_email

bool

Messages where anyone on the message has an address at a personal email domain, such as gmail.com. This doesn't check whether the address belongs to a specific person.

Search, detections

message.participants.has_vip

bool

Messages where anyone on the message is marked as a VIP

Search, detections

message.headers

object

Details from the message headers

Search, detections

message.headers.dkim

string

The result of the DKIM check: pass, fail, neutral, none, policy, temperror, or permerror. In most searches, compare with == "pass" or != "fail" rather than listing each result.

Search, detections

message.headers.dmarc

string

The result of the DMARC check: pass, fail, none, temperror, or permerror. In most searches, compare with == "pass" or != "fail" rather than listing each result.

Search, detections

message.headers.in_reply_to

string

The In-Reply-To header: the message ID of the message this one replies to

Search, detections

message.headers.message_id

string

The message ID set by the sender's email client, usually in the format <...@...>

Search, detections

message.headers.original_from

string

The Original-From header

Search, detections

message.headers.original_sender

string

The Original-Sender header

Search, detections

message.headers.reply_to

string

The email addresses in the Reply-To header, where replies to this message go

Search, detections

message.headers.spf

string

The result of the SPF check: pass, fail, softfail, neutral, none, policy, temperror, or permerror. In most searches, compare with == "pass" or != "fail" rather than listing each result.

Search, detections

message.attachments

object

Details about the message's attachments

Search, detections

message.attachments.has_archive

bool

Messages with an archive attachment, such as a .zip file

Search, detections

message.attachments.has_attachments

bool

Messages with any attachments

Search, detections

message.attachments.hash

string

The MD5 or SHA-256 hashes of the attachments

Search, detections

message.attachments.mime_type

string

The MIME types of the attachments, such as application/pdf

Search, detections

message.attachments.name

string

The file names of the attachments

Search, detections

message.links

object

Details about the links in the message

Search, detections

message.links.has_links

bool

Messages with any links

Search, detections

message.links.text

string

The display text of the links

Search, detections

message.links.url

string

The URLs of the links

Search, detections

message.body

object

The content of the message. Requires permission to view message content.

Search, detections

message.body.html

string

The HTML version of the message body

Search, detections

message.body.plain

string

The plain text version of the message body

Search, detections

message.body.text

string

All text content in the message body

Search, detections

message.status

object

Where the message is in the mailbox and whether it's been read

Search, detections

message.status.is_draft

bool

Messages that are drafts

Search, detections

message.status.is_inbox

bool

Messages in the inbox

Search, detections

message.status.is_retrieved

bool

Microsoft 365 messages in the Retrieved folder

Search, detections

message.status.is_sent

bool

Messages in the sent folder

Search, detections

message.status.is_spam

bool

Messages in the spam folder

Search, detections

message.status.is_surge

bool

Messages that Email Bomb Protection moved to the surge protection label or folder

Search, detections

message.status.is_trash

bool

Messages in the trash

Search, detections

message.status.is_unread

bool

Messages that haven't been read

Search, detections

message.context

object

How Material has classified the message

Search

message.context.account_access

bool

Messages about account access

Search

message.context.account_activation

bool

Messages about activating an account

Search

message.context.account_reset

bool

Messages about resetting a password or account

Search

message.context.account_verification

bool

Messages about verifying an account

Search

message.context.appId

array

Search for messages by application ID

Search

message.context.case

object

Search for messages by issue

Search

message.context.case.id

string

Search for messages in a specific issue, by issue ID. Use == or !=.

Search

message.context.case.in_case

bool

Messages that are currently in an issue

Search

message.context.category

object

Search for messages by the kind of sensitive data they contain

Search

message.context.category.any

bool

Messages that match any enabled sensitive category

Search

message.context.category.id

string

Search for messages that match a specific sensitive category. As you type, Material suggests your categories by name. Use == or !=.

Search

message.context.exempt

bool

Messages that are exempt

Search

message.context.rule

object

Search for messages by the detections they matched

Search

message.context.rule.id

array

Search for messages that matched a specific detection. As you type, Material suggests your detections by name. Use == or !=.

Search

message.context.rule.matched

bool

Messages that matched any detection

Search

message.riskType

object

The message's risk type: sensitive, suspicious, or none

Search

message.riskType.none

bool

Messages that aren't marked sensitive or suspicious

Search

message.riskType.sensitive

bool

Messages marked sensitive

Search

message.riskType.suspicious

bool

Messages marked suspicious

Search

account

object

Details about the account whose mailbox has the message

Search, detections

account.appsWithAccess

array

IDs of the OAuth apps that have access to this account. Use with in, for example "<app-id>" in account.appsWithAccess.

Search

account.appsWithContentAccess

array

IDs of the OAuth apps that have access to this account and can read its message content. Use with in.

Search

account.email

string

The email address of the account whose mailbox has the message

Search, detections


FAQ

Why does my search say a field is unavailable?

message.body fields need permission to view message content. If you don't have it, Material shows that the field is unavailable. Ask an admin to update your role.

Why can't I save my search as a detection?

Detections can't use message.context or message.riskType. These fields are only available in search. Remove them from the query, then save it again.

Can I search the text inside attachments?

No. Message search matches attachment names, MIME types, and hashes, and whether a message has attachments. It doesn't search the text inside an attachment, such as the text in a PDF.

How do I search by date?

Use the Date range picker next to the search. MQL doesn't have date fields.

Can I use these queries with the API?

Yes. The Messages search API accepts the same queries. Build and test your query in Query mode first, then copy it into your request.

Can I search for messages by Gmail label or Outlook folder?

You can search by the standard mailbox locations with message.status, such as message.status.is_inbox or message.status.is_spam. Custom labels and folders aren't searchable.

Last updated

Was this helpful?