Searches for emails
POST/v2/users/:email/messages/query
Searches for emails in the specified user's mailbox using a query statement. Only basic information is returned by default. Use $select to specify additional fields, such as $select=internetMessageId,toRecipients.
Search results do not support returning body, internetMessageHeaders, replyTo, and isReadReceiptRequested via $select. To retrieve these fields, call the single email retrieval API.
Query Syntax
For query syntax, refer to KQL. String values can be enclosed in double quotes. A " inside double quotes must be represented as two consecutive double quotes. When double quotes are not used, the value cannot contain whitespace, double quotes, or parentheses.
Example:
date>2025-01-01T00:00:00Z AND (NOT folderId:3) AND (NOT folderId:6)
(from:"alice") OR (to:"alice<a@b.com>" AND folderId:1 AND toEmail="a@b.com")
(subject:"test") OR (attachname:"""quoteString""" AND from:alice<a@b.com>)
Supported Fields
- Common fields:
date,size,tag,folderId,isRead,hasAttachments,subject,attachname, andbody. - Sender and recipient fields:
from,fromEmail,to, andtoEmail. isReadandhasAttachmentssupport1,0,true, andfalse.fromandtosupport thealias<address@example.com>format.fromEmailandtoEmailuse plain email addresses.
Operators
- Field operators:
:(contains),=(equals),>(greater than),>=(greater than or equal to),<(less than), and<(less than or equal to). - Logical operators:
AND,OR, andNOT. - Operator precedence:
NOT>AND>OR.
Request
Path parameters
User email address.
Query parameters
Body parameters
Query statement.
Starting offset identifier of the email. Its value is taken from the nextCursor field in the response. An empty string indicates starting from the beginning.
Number of emails returned. Maximum value: 100.
Response
- none:
- posting:
- partial_success:
- success:
- failed:
- unknown:
messages object[]
Email list.
Email message ID formatted per RFC 2822 (Optional field: returned when the $select=internetMessageId query parameter is included in the URL). To request multiple fields, separate them with commas.
Email subject.
Email summary information.
The importance of the email. Possible values: HIGH, NORMAL, LOW. Defaults to NORMAL. - PRY_HIGH: - PRY_NORMAL:
Possible values: [PRY_HIGH, PRY_NORMAL]
from object
Owner of the mailbox from which the email is sent. In most cases, this value is the same as the "sender" attribute.
Email address of the person or entity.
Display name of the person or entity.
toRecipients object[]
Recipients of the email (optional field: returned after adding the $select=toRecipients query parameter in the URL; use commas to separate multiple fields).
Email address of the person or entity.
Display name of the person or entity.
ccRecipients object[]
CC recipients of the email. (Optional field: returned by adding the $select=ccRecipients query parameter in the URL. Separate multiple fields with commas.)
Email address of the person or entity.
Display name of the person or entity.
bccRecipients object[]
Blind carbon copy (BCC) recipients of the email (Optional field: returned when the $select=bccRecipients query parameter is included in the URL). To request multiple fields, separate them with commas.
Email address of the person or entity.
Display name of the person or entity.
sender object
The account actually used to generate the email. In most cases, this value is the same as the "from" attribute. Under any circumstances, this value must correspond to the actual mailbox used (Optional field: returned after adding the $select=sender query parameter in the URL. For multiple fields, separate them with commas).
Email address of the person or entity.
Display name of the person or entity.
internetMessageHeaders object
Set of email headers as defined by RFC 5322.
Set of email headers as defined by RFC 5322.
Unique identifier of the folder to which the email belongs.
Unique email identifier.
Indicates whether the email contains attachments (excluding inline resources).
Indicates whether the email is read.
Unique identifier of the conversation to which the email belongs.
Email sending time.
Last modification time of the message (Optional field: returned when the $select=lastModifiedDateTime query parameter is added to the URL; separate multiple fields with commas).
Time when the recipient received the email (Optional field: returned after adding the $select=receivedDateTime query parameter to the URL. Separate multiple fields with commas.)
List of email tags. (Optional field: Returns when the $select=tags query parameter is added to the URL. Use commas to separate multiple fields.)
Indicates whether the email has been replied to.
Indicates whether the email has been forwarded.
Email sending status (optional field: returned when $select=sendStatus is added to the URL; use commas to separate multiple fields).
Possible values: [none, posting, partial_success, success, failed, unknown]
Email size in bytes.
Total number of emails.
Next page cursor. $ indicates the end of the email list.
Errors
401 | Access is unauthorized. Please check whether the correct authorization token is passed. |
403 | No API access permission. Please complete the relevant authorization on the application management page of the domain administrator. |
412 |