Gmail — Apply label
Gmail — Apply label
Section titled “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.
How it works
Section titled “How it works”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, orSuppliers/Invoicesfor 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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | Message ID. |
labels | string | List | — | Label name(s) or ID(s) to apply: text separated by commas or semicolons, or a list. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanGmailSession | — | Gmail — Connect session (inherited inside body). |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”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"Related activities
Section titled “Related activities”- Gmail — Remove label — remove a label.
- Gmail — Get labels — list the mailbox labels.
- Gmail — Get emails — find the emails to label.
- All Gmail activities