organize_messages
Organize Gmail threads in bulk: archive (remove from Inbox), trash (move to Trash — RECOVERABLE, this is not a permanent delete), mark_read, mark_unread, star, unstar, add_label, remove_label, mark_spam (report as spam — also removes from Inbox), unmark_spam (not spam — restores to Inbox). Pass thread ids from search_messages results together with the account each belongs to; a batch may span several connected accounts and is capped at 50. add_label/remove_label take a label NAME — add_label creates it on that account if missing, remove_label never creates one. One item failing never aborts the rest: every item comes back with ok/error, and a missing-permission failure is flagged reconnect so you can tell the user to reconnect that account rather than showing a generic error. This CHANGES the user's mailbox — confirm the threads and the action with them before calling. Needs gmail.modify (reconnect on a permission error).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | Threads to act on — up to 50 per call. A batch may span several accounts. | |
| label | No | Label NAME (not id) — required for add_label/remove_label, ignored otherwise. add_label creates the label on that account when it has none by that name; remove_label never creates one and fails just that item if the name does not exist. | |
| action | Yes | What to do with every thread in `items`: archive (remove from Inbox), trash (move to Trash — recoverable, NOT a permanent delete), mark_read, mark_unread, star, unstar, add_label, remove_label, mark_spam (report as spam — also removes from Inbox), unmark_spam (not spam — restores to Inbox). |