Query threads
const url = 'https://api.inboxcnx.com/v1/threads/query';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"filter":{"operator":"OR","conditions":[{"participant":"alice@example.com"},{"hasAttachment":true}]},"sort":[{"property":"lastMessageAt","isAscending":false}],"limit":25}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.inboxcnx.com/v1/threads/query \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "filter": { "operator": "OR", "conditions": [ { "participant": "alice@example.com" }, { "hasAttachment": true } ] }, "sort": [ { "property": "lastMessageAt", "isAscending": false } ], "limit": 25 }'Finds conversations 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/threads accepts is also valid inside a filter tree.
A condition object (for example { "participant": "alice@example.com" }) matches threads satisfying all of its fields. Wrap conditions in an operator node to combine them explicitly:
{
"operator": "OR",
"conditions": [
{
"participant": "alice@example.com"
},
{
"hasAttachment": true
}
]
}
This matches threads where Alice is a participant OR the thread has an attachment.
Omit filter entirely to match every thread 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/threads; include: ["total"] adds the number of matches.
Requires the read:messages scope.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
object
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.
object
Only threads with this exact address among their participants (senders and recipients).
Only threads from this mail provider.
Only the thread matching this source provider’s own thread id (Gmail/M365/IMAP thread id).
Only threads whose most recent message was received at or after this instant (inclusive).
Only threads whose most recent message was received strictly before this instant.
Only threads ingested through this connection grant.
Only threads in which at least one message carries this label (a system role or a custom label).
Only threads in which at least one message does NOT carry this label. notLabel=trash leaves out threads whose every message is in the trash.
How to sort the results, as an array with exactly one entry: [{ property, isAscending }]. A longer array is rejected. Omit to sort by most recently active thread first.
object
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.
Page size, between 1 and 200. Default 50.
total adds the number of matching results, counted up to 10000.
Example
{ "filter": { "operator": "OR", "conditions": [ { "participant": "alice@example.com" }, { "hasAttachment": true } ] }, "sort": [ { "property": "lastMessageAt", "isAscending": false } ], "limit": 25}Responses
Section titled “Responses”A page of threads, newest conversation first
object
object
object
object
object
object
object
Pass back as cursor for the next page. Null on the last page.
Pass back as cursor for the previous page. Null on the first page.
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
Example
{ "data": [ { "source": "gmail", "labels": { "system": [ "inbox" ] } } ]}Invalid filter tree, malformed cursor, or a tree past the depth/count limit
object
object
Example generated
{ "error": { "code": "example", "message": "example" }}The credential lacks the read:messages scope
object
object
Example generated
{ "error": { "code": "example", "message": "example" }}The query exceeded the read timeout
object
object
Example generated
{ "error": { "code": "example", "message": "example" }}