ListLabels
List the user’s Gmail labels. Returns both system labels (INBOX, SENT, DRAFTS, UNREAD, STARRED, TRASH, SPAM, IMPORTANT, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS, etc.) and any custom user-created labels. Each label has a UUIDid and a name.
Gmail represents nearly every inbox operation as a label add/remove, so this tool is the first step for almost any thread-management action: call ListLabels once to find the label id by name, then pass that id to UpdateThreadLabels. Common pairings (look up the named system label here, then call UpdateThreadLabels with that id):
- Archive a thread → remove
INBOX(add=false) - Move back to inbox → add
INBOX(add=true) - Mark as read → remove
UNREAD(add=false) - Mark as unread → add
UNREAD(add=true) - Star → add
STARRED; Unstar → removeSTARRED - Move to trash → add
TRASH; Restore from trash → removeTRASH - Mark important → add
IMPORTANT; Mark unimportant → removeIMPORTANT - Report spam → add
SPAM; Not spam → removeSPAM - Apply or remove a custom user label → look up the label by its display name and add/remove it
ids, so a label id from one inbox will not work on a thread in another. When acting on a specific thread, pass its thread_id and this returns the labels of the inbox that owns that thread (the matching ids to pass to UpdateThreadLabels). Otherwise, in a multi-inbox setup, pass inbox (an inbox email address from ListInboxes) to list a specific inbox’s labels; omit both to use the primary inbox.