Skip to content

Query messages

POST
/v1/messages/query
curl --request POST \
--url https://api.inboxcnx.com/v1/messages/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "filter": { "operator": "OR", "conditions": [ { "q": "invoice" }, { "from": "accounts@example.com" } ] }, "sort": [ { "property": "receivedAt", "isAscending": false } ], "limit": 25 }'

Finds stored mail with a filter tree that combines conditions with AND, OR and NOT, for searches a flat query string cannot express. Conditions nest to any depth. Every condition field a plain GET /v1/messages accepts is also valid inside a filter tree.

A condition object (for example { "from": "alice@example.com" }) matches messages satisfying all of its fields. Wrap conditions in an operator node to combine them explicitly:

{
  "operator": "OR",
  "conditions": [
    {
      "q": "invoice"
    },
    {
      "from": "accounts@example.com"
    }
  ]
}

This matches messages where the search text matches “invoice” OR the sender is accounts@example.com.

Omit filter entirely to match every message the caller can see. The filter tree is limited to 6 levels of nesting and 40 conditions in total; a tree that exceeds either limit is rejected with filter_depth_exceeded or filter_condition_count_exceeded.

Results are paginated the same way as GET /v1/messages; include: ["total"] adds the number of matches.

Requires the read:messages scope.

Media typeapplication/json
object
filter
Any of:
object
operator
required

How to combine conditions. AND matches only if every condition matches; OR matches if any condition matches; NOT matches only if none of the conditions match.

string
Allowed values: AND OR NOT
conditions
required
Array<object> recursive
sort

How to sort the results, as an array with exactly one entry: [{ property, isAscending }]. A longer array is rejected. Omit to sort by receivedAt descending (newest first). Relevance sorting is not available here; use sort=relevance on GET /v1/messages instead.

Array<object>
<= 1 items
object
property
required
string
Allowed values: receivedAt sentAt
isAscending
required
boolean
cursor

Opaque pagination cursor: a previous response’s nextCursor or prevCursor, passed back verbatim. A cursor issued under one sort order is rejected if reused with another.

string
limit

Page size, between 1 and 200. Default 50.

integer
>= 1 <= 200
include

total adds the number of matching results, counted up to 10000.

Array<string>
Allowed values: total

Example

{
"filter": {
"operator": "OR",
"conditions": [
{
"q": "invoice"
},
{
"from": "accounts@example.com"
}
]
},
"sort": [
{
"property": "receivedAt",
"isAscending": false
}
],
"limit": 25
}

A page of message summaries, without body and attachments

Media typeapplication/json
object
data
required
Array<object>
object
id
required
string format: uuid
providerMessageId
required
string
providerThreadId
required
string | null
source
required
string
Allowed values: gmail m365 imap
receivedAt
required
string
sentAt
required
string | null
subject
required
string | null
from
required
Array<object> | null
object
name
required
string | null
email
required
string
sender
required
Array<object> | null
object
name
required
string | null
email
required
string
to
required
Array<object> | null
object
name
required
string | null
email
required
string
cc
required
Array<object> | null
object
name
required
string | null
email
required
string
bcc
required
Array<object> | null
object
name
required
string | null
email
required
string
replyTo
required
Array<object> | null
object
name
required
string | null
email
required
string
messageId
required
Array<string> | null
inReplyTo
required
Array<string> | null
references
required
Array<string> | null
size
required
integer
keywords
required
object
key
additional properties
boolean
labels
required
object
system
required
Array<string>
Allowed values: inbox archive drafts sent trash junk all flagged important
custom
required
Array<string>
language
required
string | null
preview
required
string | null
<= 256 characters
hasAttachment
required
boolean
raw
required
object
downloadUrl
required
string | null
enrichment
required
object
application
object
key
additional properties
stateAt
required
string | null
deletedAt
required
string | null
grantId
required
string
nextCursor
required

Pass back as cursor for the next page. Null on the last page.

string | null
prevCursor
required

Pass back as cursor for the previous page. Null on the first page.

string | null
total

Present only when requested with include. exact is false once the count reaches 10000 (or the depth cap of a relevance search); count is then that cap.

object
count
required
integer
exact
required
boolean

Example

{
"data": [
{
"source": "gmail",
"labels": {
"system": [
"inbox"
]
}
}
]
}

Invalid filter tree, malformed cursor, or a tree past the depth/count limit

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string

Example generated

{
"error": {
"code": "example",
"message": "example"
}
}

The credential lacks the read:messages scope

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string

Example generated

{
"error": {
"code": "example",
"message": "example"
}
}

The query exceeded the read timeout

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string

Example generated

{
"error": {
"code": "example",
"message": "example"
}
}