Portal Community

message/addLabel

Add one or more labels to a Gmail message for categorization, routing, and workflow state tracking.

Label IDs: Use label/getMany to retrieve label IDs for user-created labels. System label IDs are constants: INBOX, SENT, TRASH, SPAM, STARRED, IMPORTANT, UNREAD.

When to Use

Configuration

Connection

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

Operation Fields

FieldTypeDefaultDescription
messageIdstring requiredGmail message ID to apply labels to.
labelIdsstring[] optionalArray of label IDs to add. Can include system labels (STARRED, IMPORTANT) and user-created label IDs. Use label/getMany to resolve user label IDs.
System Label IDs: INBOX, SENT, TRASH, SPAM, STARRED, IMPORTANT, UNREAD. User-created label IDs are alphanumeric strings (e.g. Label_123456789) — retrieve them with label/getMany.

Sample Configuration

{
  "nodeType": "Gmail",
  "operation": "message/addLabel",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{processedEmail.messageId}}",
  "labelIds": ["Label_987654321", "STARRED"]
}

Validation Errors

ErrorCauseResolution
MISSING_FIELD: messageIdmessageId is emptyEnsure upstream node provides a valid message ID
INVALID_LABEL_IDOne or more label IDs do not exist in the accountUse label/getMany to retrieve valid label IDs before referencing them
MESSAGE_NOT_FOUNDMessage does not exist in the accountVerify message ID comes from the authenticated account
INVALID_CREDENTIALOAuth token expired or credential not foundRe-authenticate in BizFirst Credentials Manager
PERMISSION_DENIEDCredential lacks gmail.modify scopeRe-grant OAuth permissions with the correct scope

Output

Success Port

FieldTypeDescription
successbooltrue when labels were successfully applied
statusstringsuccess
errorCodestringEmpty on success

Error Port

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

Sample Output

{
  "success": true,
  "status": "success",
  "errorCode": ""
}

Expression Reference

ExpressionResolves ToExample Use
{{processedEmail.messageId}}Message ID from upstream processing nodemessageId field
{{labelLookup.processedLabelId}}Label ID from a previous label/getMany lookuplabelIds array element
{{classification.departmentLabelId}}Department label ID resolved from classification outputDynamic label routing
{{imapTrigger.messageId}}Message ID from IMAP triggerLabel immediately on receipt

Node Policies & GuardRails

PolicyRule
Label ID ResolutionAlways resolve user label IDs with label/getMany at workflow start — do not hardcode user label IDs as they differ between Gmail accounts
IdempotencyAdding a label that is already applied is a no-op — safe to call multiple times for the same message
Credential StorageStore OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration
System Label CautionAdding TRASH or SPAM via addLabel moves the message — use dedicated trash/spam operations for clarity
Quota ManagementLabel operations cost 1–5 quota units — safe for high-frequency use in batch workflows
Test IsolationTest label workflows against a dedicated Gmail test account before connecting production

Examples

Example 1: Apply Processing State Label

After extracting data from an email, apply a "Processed" label to prevent duplicate processing.

{
  "nodeType": "Gmail",
  "operation": "message/addLabel",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{dataExtraction.sourceMessageId}}",
  "labelIds": ["{{workflow.processedLabelId}}"]
}

Example 2: Priority Escalation

A sentiment analysis node detects an urgent customer complaint — apply STARRED and IMPORTANT labels.

{
  "nodeType": "Gmail",
  "operation": "message/addLabel",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{sentiment.urgentMessageId}}",
  "labelIds": ["STARRED", "IMPORTANT"]
}

Example 3: Department Routing Label

A subject-line classifier determines the department and applies the corresponding label for inbox routing.

{
  "nodeType": "Gmail",
  "operation": "message/addLabel",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{classifier.messageId}}",
  "labelIds": ["{{classifier.departmentLabelId}}"]
}