bulk_modify
Apply label changes to all messages matching a Gmail query in batches of 1000, with partial-failure reporting. Ideal for mass archive, labeling, or mark-read.
Instructions
Bulk-apply label changes to every message matching a Gmail query, batched at 1000 messages per API request. Returns matched/modified counts, affected thread IDs (capped at 500 — modifiedThreadCount has the true total), and per-chunk failures (partial success is reported, not hidden). If more messages match than maxMessages, only the first maxMessages are processed and 'capped' is true — raise maxMessages or re-run to finish the rest. Note: the query hits Gmail's search index as-is, WITHOUT the live re-verification search performs — for read-state-precise bulk ops, verify with search first. USE WHEN: mass operations — 'archive all newsletters older than 30 days' (query + remove INBOX), bulk labeling, bulk mark-read. DO NOT USE: for a single thread (use modify_labels or the dedicated tools), or with neither add nor remove. SIDE EFFECTS: modifies up to maxMessages messages in one call; label changes are reversible by the inverse call.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| add | No | ||
| query | Yes | ||
| remove | No | ||
| maxMessages | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| capped | Yes | ||
| failed | Yes | ||
| matchedMessages | Yes | ||
| modifiedThreads | Yes | ||
| modifiedMessages | Yes | ||
| modifiedThreadCount | Yes |