Skip to content

Search the mailbox

POST
/mail/mailboxes/{mailbox}/search
curl --request POST \
--url https://mail.work.optidata.cloud/api/mail/mailboxes/78/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "page": 1, "should_match_all": true, "from": "john.roe@example.com", "unread": true, "content": "invoice" }'

Search across the mailbox. Every criterion is optional except page; send the ones you care about and leave the rest out.

By default a message needs to satisfy any criterion you send. Set should_match_all to true to require all of them. Scope the search to one folder with folder_id (or folder_name); omit both to search everything.

Results follow the caller’s listing preference — threads when conversation grouping is on, individual messages when it is off — and page with the same page semantics as a folder listing.

mailbox
required
integer

Id of the mailbox. Every mailbox the caller may use is listed in their account.

Media typeapplication/json

The search criteria. All are optional except page; by default a message needs to satisfy any of them, unless should_match_all is set.

object
page
required

1-based page number.

integer
>= 1
should_match_all

Require every criterion instead of any.

boolean | null
subject

Words in the subject.

string | null
content

Words anywhere in the message.

string | null
from

Sender name or address.

string | null
to

Recipient name or address.

string | null
after

Only messages on or after this date.

string | null
before

Only messages on or before this date.

string | null
read
boolean | null
unread
boolean | null
flagged
boolean | null
folder_id

Restrict the search to one folder.

integer | null
folder_name

Restrict the search to a folder by name.

string | null
Examples

Unread mail from one sender, with an attachment word in the body

{
"page": 1,
"should_match_all": true,
"from": "john.roe@example.com",
"unread": true,
"content": "invoice"
}

One page of results.

Media typeapplication/json

One page of search results.

object
conversations

The matching threads, when the caller groups by conversation.

Array
object
id

Id of the thread. A single-message thread reports the message id with the sign flipped.

string | integer
date
string
subject
string | null
fragment

Preview snippet of the newest message.

string | null
unreadMessages
integer
totalMessages
integer
type

How an outgoing message came to be.

string
Allowed values: new reply forward
replyServerMessageId
string | null
tagIds
Array<string | integer>
flags

The state of a message or thread, as a set of booleans.

object
isUnread
boolean
isFlagged

The user starred it.

boolean
hasAttachment
boolean
isReplied
boolean
isSentByMe
boolean
isForwarded
boolean
isInvite

It carries a calendar invitation.

boolean
isDraft
boolean
isDeleted
boolean
isNotificationSent

A read receipt was requested.

boolean
isUrgent
boolean
isLowPriority
boolean
isPriority
boolean
participants

The addresses of a message, grouped by role.

object
from
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
to
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
cc
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
bcc
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
replyTo
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
sender
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
notification
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
resentFrom
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
messages

The messages of the thread. In a listing they carry ids and flags only; read the bodies with the reader operations.

Array<object>

A message as it appears inside a listing or a thread.

object
id
string | integer
date
string
subject
string | null
fragment
string | null
conversationId
string | integer | null
messageIdHeader

The RFC 5322 Message-ID header.

string | null
sizeBytes
integer | null
folderId
string | integer | null
flags

The state of a message or thread, as a set of booleans.

object
isUnread
boolean
isFlagged

The user starred it.

boolean
hasAttachment
boolean
isReplied
boolean
isSentByMe
boolean
isForwarded
boolean
isInvite

It carries a calendar invitation.

boolean
isDraft
boolean
isDeleted
boolean
isNotificationSent

A read receipt was requested.

boolean
isUrgent
boolean
isLowPriority
boolean
isPriority
boolean
participants

The addresses of a message, grouped by role.

object
from
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
to
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
cc
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
bcc
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
replyTo
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
sender
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
notification
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
resentFrom
Array<object>

One participant of a message.

object
name

Display name, when one is known.

string | null
email
string format: email
type

The role the address plays: f sender, t recipient, c carbon copy, b blind copy, r reply-to.

string | null
body

Left empty in listings; read the body with a reader operation.

Array
attachments
Array<object>

A file carried by a message.

object
part

MIME part number, used to download it.

string | integer
filename
string | null
contentType
string | null
contentId

The cid an inline image is referenced by inside the body.

string | null
disposition

attachment or inline.

string | null
hasExplicitAttachmentDisposition
boolean
fallbackOrdinal

Position used to name a file that arrived without one.

integer | null
sizeBytes
integer | null
icon

Icon hint for a file-type badge.

string | null
url

Signed download link, populated by the reader operations. Use it as-is.

string | null
inlineAttachments
Array<object>

A file carried by a message.

object
part

MIME part number, used to download it.

string | integer
filename
string | null
contentType
string | null
contentId

The cid an inline image is referenced by inside the body.

string | null
disposition

attachment or inline.

string | null
hasExplicitAttachmentDisposition
boolean
fallbackOrdinal

Position used to name a file that arrived without one.

integer | null
sizeBytes
integer | null
icon

Icon hint for a file-type badge.

string | null
url

Signed download link, populated by the reader operations. Use it as-is.

string | null
tagIds
Array<string | integer>
invite

The calendar invitation carried by the message, when there is one.

object | null
share

The folder-sharing offer carried by the message, when there is one.

object | null
conversationsSummary

Lightweight hits, carrying ids only.

Array<object>
object
totalConversations

How many results are on this page.

integer
hasMore
boolean
offset
integer
limit
integer
page
integer
sortBy
string
folders

The folders the results live in.

Array<object> | null

A folder of a mailbox.

object
id

Id of the folder.

string | integer
uuid
string format: uuid
name
string
path

Full path from the mailbox root.

string
role

What a folder is for. Custom marks a folder the user created; the others are the standard folders of a mailbox.

string
Allowed values: Inbox Snoozed Sent Drafts Archives Junk Trash Custom Important Scheduled SharedWithMe
rgb

Colour, as a hex triplet.

string | null
parentId
string | integer | null
parentUuid
string | null
unreadMessages
integer
totalMessages
integer
sizeBytes
integer
isDeletable

false for the standard folders.

boolean
isTrashFolder
boolean
subfolders
Array<object> recursive
shares

Sharing grants on this folder.

Array<object>
object
Example
{
"conversations": [
{
"id": "4185",
"date": "2026-08-19T12:41:47.000000Z",
"type": "new",
"participants": {
"from": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"to": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"cc": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"bcc": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"replyTo": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"sender": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"notification": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"resentFrom": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
]
},
"messages": [
{
"id": "4186",
"participants": {
"from": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"to": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"cc": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"bcc": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"replyTo": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"sender": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"notification": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
],
"resentFrom": [
{
"name": "Jane Doe",
"email": "jane.doe@acme.example",
"type": "f"
}
]
},
"attachments": [
{
"part": "2",
"filename": "report.docx",
"contentType": "application/pdf",
"disposition": "attachment"
}
],
"inlineAttachments": [
{
"part": "2",
"filename": "report.docx",
"contentType": "application/pdf",
"disposition": "attachment"
}
]
}
]
}
],
"sortBy": "dateDesc",
"folders": [
{
"id": "2",
"name": "Inbox",
"path": "Inbox/Suppliers",
"role": "Inbox",
"rgb": "#2F6FEB"
}
]
}

Missing, malformed or expired authentication key.

Media typeapplication/json

Authentication failures use an error key rather than message.

object
error
required
string
Examples
Examplemissing

No bearer token sent

{
"error": "JWT passport exception: Missing bearer token in request"
}

The caller may not act on this mailbox, user or resource.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Exampledenied
{
"message": "This action is unauthorized."
}

The request body or query string failed validation.

Media typeapplication/json
object
message
required

The first validation message.

string
errors
required

Validation messages keyed by field name.

object
key
additional properties
Array<string>
Examples
Exampleinvalid
{
"message": "The conversations field is required.",
"errors": {
"conversation_ids": [
"The conversations field is required."
]
}
}

Rate limit exceeded. Retry after the window resets.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Examplethrottled
{
"message": "Too Many Attempts."
}

The mail platform did not answer as expected — a folder or message that does not exist, or a transient failure. reference is the code to quote to support and fault_code names the underlying condition. A 503 with the same envelope means the platform is in maintenance; retry shortly.

Media typeapplication/json

Failure raised by the mail platform behind the API rather than by the request itself.

object
error
required

What went wrong, phrased for the end user.

string
status
required

Repeats the HTTP status code.

integer
help
required

Suggested next step.

string
reference
required

Support reference, e.g. MZ-502.

string
fault_code

Names the underlying condition, e.g. mail.NO_SUCH_FOLDER.

string | null
Examples

Unknown folder

{
"error": "The mail server did not answer as expected, so this action could not be completed.",
"status": 502,
"help": "If the problem persists, contact support and inform the error code above.",
"reference": "MZ-502",
"fault_code": "mail.NO_SUCH_FOLDER"
}