searchEmailsWithHttpInfo method
Structured search across connected mail accounts.
Fan-out search. Mirrors listEmails's account/provider filter semantics. Date range filters are inclusive. The query string itself is passed via ?q= (not ?query=); structured filters go in their own params.
Note: This method returns the HTTP Response.
Parameters:
-
String q (required): Provider-specific full-text query string.
-
List<String> accountIds: Repeatable. Restrict to these connected-account row ids. Mutually orthogonal to
providers— when both are set the intersection is used. -
List<String> providers: Repeatable. Restrict to these provider ids (
gmail,outlook). -
String xWorkspaceID: Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
-
String from:
-
String to:
-
String subject:
-
bool hasAttachment:
-
bool isUnread:
-
bool isStarred:
-
List<String> labels:
-
DateTime after: Inclusive lower-bound date.
-
DateTime before: Inclusive upper-bound date.
-
int limit:
-
String nextPageToken: Cursor returned by the previous call.
Implementation
Future<Response> searchEmailsWithHttpInfo(String q, { List<String>? accountIds, List<String>? providers, String? xWorkspaceID, String? from, String? to, String? subject, bool? hasAttachment, bool? isUnread, bool? isStarred, List<String>? labels, DateTime? after, DateTime? before, int? limit, String? nextPageToken, }) async {
// ignore: prefer_const_declarations
final path = r'/v1/mail/search';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (accountIds != null) {
queryParams.addAll(_queryParams('multi', 'accountIds', accountIds));
}
if (providers != null) {
queryParams.addAll(_queryParams('multi', 'providers', providers));
}
queryParams.addAll(_queryParams('', 'q', q));
if (from != null) {
queryParams.addAll(_queryParams('', 'from', from));
}
if (to != null) {
queryParams.addAll(_queryParams('', 'to', to));
}
if (subject != null) {
queryParams.addAll(_queryParams('', 'subject', subject));
}
if (hasAttachment != null) {
queryParams.addAll(_queryParams('', 'hasAttachment', hasAttachment));
}
if (isUnread != null) {
queryParams.addAll(_queryParams('', 'isUnread', isUnread));
}
if (isStarred != null) {
queryParams.addAll(_queryParams('', 'isStarred', isStarred));
}
if (labels != null) {
queryParams.addAll(_queryParams('multi', 'labels', labels));
}
if (after != null) {
queryParams.addAll(_queryParams('', 'after', after));
}
if (before != null) {
queryParams.addAll(_queryParams('', 'before', before));
}
if (limit != null) {
queryParams.addAll(_queryParams('', 'limit', limit));
}
if (nextPageToken != null) {
queryParams.addAll(_queryParams('', 'nextPageToken', nextPageToken));
}
if (xWorkspaceID != null) {
headerParams[r'X-Workspace-ID'] = parameterToString(xWorkspaceID);
}
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}