Portal Community

label/getMany

List all Gmail labels in the authenticated account, including both system labels and user-created labels.

Label ID Lookup: This is the primary operation for resolving user label IDs before using them in message/addLabel, message/getMany, thread/addLabel, and thread/removeLabel. User label IDs are account-specific — always look them up dynamically.

When to Use

Configuration

Connection

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

Operation Fields

FieldTypeDefaultDescription
limitint optionalMaximum number of labels to return. When not set, all labels are returned (Gmail typically has under 500 labels per account).

Sample Configuration

{
  "nodeType": "Gmail",
  "operation": "label/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d"
}

Validation Errors

ErrorCauseResolution
INVALID_CREDENTIALOAuth token expired or credential not foundRe-authenticate in BizFirst Credentials Manager
QUOTA_EXCEEDEDGmail API quota exhaustedReduce call frequency; label lists rarely change so cache results

Output

Success Port

FieldTypeDescription
labelsarrayArray of label objects (both system and user labels)
labels[].labelIdstringGmail label ID
labels[].namestringLabel display name
labels[].typestringsystem or user
labels[].labelListVisibilitystringLabel list visibility setting
labels[].messageListVisibilitystringMessage list visibility setting
statusstringsuccess
errorCodestringEmpty on success

Error Port

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

Sample Output

{
  "labels": [
    { "labelId": "INBOX", "name": "INBOX", "type": "system", "labelListVisibility": "labelShow", "messageListVisibility": "show" },
    { "labelId": "SENT", "name": "SENT", "type": "system", "labelListVisibility": "labelShow", "messageListVisibility": "show" },
    { "labelId": "Label_987654321", "name": "BizFirst/Processed", "type": "user", "labelListVisibility": "labelShow", "messageListVisibility": "show" },
    { "labelId": "Label_123456789", "name": "Support/Open", "type": "user", "labelListVisibility": "labelShow", "messageListVisibility": "show" }
  ],
  "status": "success",
  "errorCode": ""
}

Expression Reference

ExpressionResolves ToExample Use
{{labelList.labels}}Full array of label objectsLoop for label audit
{{labelList.labels | where: 'name', 'BizFirst/Processed' | first | prop: 'labelId'}}Label ID for "BizFirst/Processed"Resolved ID for message/addLabel
{{labelList.labels | where: 'type', 'user'}}Only user-created labelsFilter for cleanup audit

Node Policies & GuardRails

PolicyRule
Cache Label ResultsLabel lists change infrequently — call label/getMany once at workflow start and store results in a workflow variable rather than calling repeatedly
Credential StorageStore OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration
Dynamic ID ResolutionNever hardcode user label IDs in workflow config — always resolve them via label/getMany at runtime since IDs are account-specific
Quota ManagementLabel list operations cost 1 quota unit — very cheap, but caching avoids unnecessary calls in long-running workflows
System Label ConstantsSystem label IDs (INBOX, SENT, TRASH, SPAM, STARRED, IMPORTANT, UNREAD) are constants — no lookup needed for these
Test IsolationTest label listing against a dedicated Gmail test account that mirrors production label structure

Examples

Example 1: Workflow Initialization — Label ID Lookup

At workflow start, retrieve all labels and store the "BizFirst/Processed" label ID in a workflow variable.

{
  "nodeType": "Gmail",
  "operation": "label/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d"
}

Example 2: Label Inventory Report

List all user-created labels and generate a report of label names and message counts for administrative review.

{
  "nodeType": "Gmail",
  "operation": "label/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d"
}

Example 3: Upsert Label Check

Before creating a "Compliance/GDPR" label, check if it already exists to avoid the duplicate-name error.

{
  "nodeType": "Gmail",
  "operation": "label/getMany",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d"
}