Last active
April 8, 2026 02:46
-
-
Save YoRyan/4f9d28531d2b2eb9014dcb2c627aa10b to your computer and use it in GitHub Desktop.
Discover the API label ID's used by your Gmail account using Google Apps Script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This work is marked CC0 1.0 Universal. | |
| // To view a copy of this mark, visit https://creativecommons.org/publicdomain/zero/1.0/ | |
| function listLabels() { | |
| const labels = Gmail.Users.Labels | |
| .list("me") | |
| .labels; | |
| console.log( | |
| "System Labels:\n\n" + | |
| labels | |
| .filter(label => label.type === "system") | |
| .map(label => label.id) | |
| .sort() | |
| .join("\n") | |
| ); | |
| console.log( | |
| "User Labels:\n\n" + | |
| labels | |
| .filter(label => label.type === "user") | |
| .map(label => `${label.name} => ${label.id}`) | |
| .sort() | |
| .join("\n") | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment