$npx -y skills add googleworkspace/cli --skill recipe-label-and-archive-emailsApply Gmail labels to matching messages and archive them to keep your inbox clean.
| 1 | # Label and Archive Gmail Threads |
| 2 | |
| 3 | > **PREREQUISITE:** Load the following skills to execute this recipe: `gws-gmail` |
| 4 | |
| 5 | Apply Gmail labels to matching messages and archive them to keep your inbox clean. |
| 6 | |
| 7 | ## Steps |
| 8 | |
| 9 | 1. Search for matching emails: `gws gmail users messages list --params '{"userId": "me", "q": "from:notifications@service.com"}' --format table` |
| 10 | 2. Apply a label: `gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"addLabelIds": ["LABEL_ID"]}'` |
| 11 | 3. Archive (remove from inbox): `gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"removeLabelIds": ["INBOX"]}'` |