Skip to content

Gmail — Apply label

Type: gmail-apply-label  ·  Package: Gmail v1.0.4  ·  Output: —

Applies one or more labels to an email. In Gmail, labels play the role of folders: use them to classify the emails your process already handled (e.g. Processed) and keep them apart from pending ones.

It works on the session created with Gmail — Connect. Pass it in the session parameter, or place this activity inside the body of Gmail — Connect to inherit it automatically.

  • Give the labels by name (e.g. Processed, or Suppliers/Invoices for a nested label; case-insensitive) or by ID (STARRED, IMPORTANT, Label_123…). Look up names and IDs with Get labels.
  • The labels must exist in the mailbox: the activity does not create them. Create them once in Gmail.
  • Before changing anything it resolves every label: if one doesn’t exist, it fails without applying any.
  • It keeps the labels the email already had. Applying a label it already has changes nothing and does not fail.
ParameterTypeDefaultDescription
idstring—Message ID.
labelsstring | List—Label name(s) or ID(s) to apply: text separated by commas or semicolons, or a list.
ParameterTypeDefaultDescription
sessionZoanGmailSession—Gmail — Connect session (inherited inside body).

This activity does not return a value.

MessageCause and fix
Label not found. Use an existing label name or ID.A label does not exist in the mailbox (or has a different name). Create it in Gmail or check the name with Get labels.
'labels' is required.labels is empty.
'id' is required.id is empty or the expression returned null.
Requested entity was not found.No email with that ID exists in the mailbox.
Gmail — Connect credential = credential("gmail-support")
└─ body:
Gmail — Get emails query = "is:unread -label:Processed" → output: newEmails
For each email in newEmails
└─ Gmail — Download attachments id = email["id"] folder = "C:\inbox"
Gmail — Apply label id = email["id"] labels = "Processed"