Gmail — Apply or remove a label on a thread
Input
label requiredThe label name, matched exactly against the account's labels. Exactness matters, because Gmail's own picker offers to create "Lunch" even when "Lunch Bill" exists, so a partial name would quietly make a second label. Gmail's category names (Social, Updates, Forums, Promotions) appear in the same menu but are not user labels.
threadId requiredThe thread's hex id, as returned by mail.google.com/search_emails (its threadId field, Gmail's data-legacy-thread-id). Note that list_inbox does not return thread ids. Must be a received thread: Gmail does not render a conversation heading for a thread you sent to yourself, and those are refused rather than risk labelling the wrong thread.
create optionalAllow creating the label when the account does not have it. Default false, so a typo fails loudly instead of quietly making a new label. Ignored when remove is true.
Default: falseremove optionalLeave false (the default) to apply the label. Set true to take it off.
Default: falseaccount optionalOptional authuser value for a browser signed into several Google accounts. Omit for the default (u/0).
Output
label requiredapplied requiredWhether the thread carries the label after this run, read from a Gmail label search rather than the label menu, which does not report applied state in conversation view.
threadId requiredalready_present requiredTrue when the thread was already in the requested state, so nothing was written.
created optionalaccountUsed optionalverified_by optional'search' when the outcome was confirmed against Gmail's own label search; 'unconfirmed' when the label holds more threads than the first search page, so absence could not be told apart from paging.
availableLabels optionalsync_acknowledged optionalWhether Gmail's own sync write was observed for this toggle.
