Portal Community

message/getMany

List and filter Gmail messages using search queries, label filters, date ranges, and sender criteria.

Search Query Tip: The filterQ field accepts Gmail's native search syntax. Test your query in the Gmail web UI search bar before using it in automation. Multiple operators are ANDed together automatically.

When to Use

Configuration

Connection

FieldTypeDescription
credentialIdGuid requiredOAuth2 credential ID from BizFirst Credentials Manager. Requires gmail.readonly scope.

Operation Fields

FieldTypeDefaultDescription
returnAllbool optionalfalseWhen true, retrieves all matching messages (ignores limit). Use with caution — may return thousands of results.
limitint optional50Maximum number of messages to return when returnAll is false. Max: 500.
simplebool optionaltrueWhen true, returns simplified message objects (headers + metadata). When false, includes full body content.
downloadAttachmentsbool optionalfalseDownload attachment binaries for each message. Only effective with simple: false.
filterQstring optionalGmail search query string (e.g. from:client@example.com subject:Invoice). Supports full Gmail query syntax.
labelIdsstring[] optionalFilter by label IDs. Only messages with ALL specified labels are returned. Use label/getMany to resolve label IDs.
readStatusenum optionalFilter by read status: read or unread.
receivedAfterstring optionalISO date string — return messages received after this date (e.g. 2024-01-01).
receivedBeforestring optionalISO date string — return messages received before this date.
senderstring optionalFilter by sender email address. Equivalent to adding from: to filterQ.

Sample Configuration

{
  "nodeType": "Gmail",
  "operation": "message/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "returnAll": false,
  "limit": 25,
  "simple": true,
  "filterQ": "from:vendor@example.com subject:Invoice has:attachment",
  "receivedAfter": "2024-01-01",
  "receivedBefore": "2024-01-31",
  "readStatus": "unread"
}

Validation Errors

ErrorCauseResolution
INVALID_CREDENTIALOAuth token expired or credential not foundRe-authenticate in BizFirst Credentials Manager
INVALID_QUERY: filterQMalformed Gmail search queryValidate the query in Gmail web UI before using in workflow
INVALID_DATE: receivedAfterDate string is not parseableUse ISO format: YYYY-MM-DD
LIMIT_EXCEEDEDlimit value exceeds maximum of 500Set limit to 500 or lower; use pagination for larger sets
QUOTA_EXCEEDEDGmail API quota exhaustedReduce list frequency; implement exponential backoff on retries

Output

Success Port

FieldTypeDescription
messagesarrayArray of message objects. Each object contains the fields described below.
messages[].messageIdstringGmail message ID
messages[].threadIdstringThread the message belongs to
messages[].snippetstringShort message preview
messages[].fromstringSender address
messages[].tostringPrimary recipient(s)
messages[].subjectstringEmail subject
messages[].datestringMessage date (RFC 2822)
messages[].labelIdsstring[]Applied label IDs
statusstringsuccess
errorCodestringEmpty on success

Error Port

On failure, routes to the error port with status: "error", errorCode, and errorMessage.

Sample Output

{
  "messages": [
    {
      "messageId": "18e4a2f9d3c0b1a7",
      "threadId": "18e4a2f9d3c0b1a7",
      "snippet": "Please find invoice #INV-001 attached...",
      "from": "vendor@example.com",
      "to": "accounts@bizfirstai.com",
      "subject": "Invoice #INV-001",
      "date": "Mon, 15 Jan 2024 09:34:12 +0000",
      "labelIds": ["INBOX", "UNREAD"]
    },
    {
      "messageId": "18e4b1c2d3e4f5a6",
      "threadId": "18e4b1c2d3e4f5a6",
      "snippet": "Attached is invoice #INV-002 for January...",
      "from": "vendor@example.com",
      "to": "accounts@bizfirstai.com",
      "subject": "Invoice #INV-002",
      "date": "Wed, 17 Jan 2024 14:21:05 +0000",
      "labelIds": ["INBOX", "UNREAD"]
    }
  ],
  "status": "success",
  "errorCode": ""
}

Expression Reference

ExpressionResolves ToExample Use
{{gmailList.messages}}Array of message objectsLoop node input
{{gmailList.messages[0].messageId}}First result's message IDPass to message/get for full content
{{$vars.vendorEmail}}Dynamic sender filter from workflow variablesender or filterQ field
{{$now | dateFormat:'YYYY-MM-01'}}First day of current monthreceivedAfter field
{{$now | dateFormat:'YYYY-MM-DD'}}Today's datereceivedBefore field

Node Policies & GuardRails

PolicyRule
Credential StorageStore OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration
ReturnAll SafetyAvoid returnAll: true on large inboxes — set a reasonable limit and use date filters to scope results
Quota Managementmessages.list costs 5 quota units per call; each subsequent message/get for full content adds 5 more — plan batch sizes carefully
Query ValidationTest filterQ queries in Gmail web UI before automation; invalid queries return zero results silently
PII ProtectionDo not log message content arrays in workflow execution history — email data contains PII
Test IsolationTest filtering workflows against a dedicated Gmail test account to avoid unintended modifications to production inbox

Examples

Example 1: Process Unread Support Inbox

Scheduled trigger fires hourly, retrieves all unread INBOX messages, and routes each to a support workflow.

{
  "nodeType": "Gmail",
  "operation": "message/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "returnAll": false,
  "limit": 50,
  "labelIds": ["INBOX"],
  "readStatus": "unread",
  "simple": true
}

Example 2: Monthly Invoice Retrieval

Retrieve all vendor invoice emails received in the current month for accounting batch processing.

{
  "nodeType": "Gmail",
  "operation": "message/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "filterQ": "from:vendor@example.com subject:Invoice has:attachment",
  "receivedAfter": "{{$now | dateFormat:'YYYY-MM-01'}}",
  "receivedBefore": "{{$now | dateFormat:'YYYY-MM-DD'}}",
  "simple": false,
  "downloadAttachments": true,
  "limit": 100
}

Example 3: CRM Sender Sync

Retrieve all emails from a specific client and append them to the CRM contact timeline.

{
  "nodeType": "Gmail",
  "operation": "message/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "sender": "{{crm.contact.email}}",
  "simple": true,
  "returnAll": true
}