mail_delete_folder
Delete an iCloud Mail folder while keeping its messages: non-empty folders first move all mail to Trash, then the empty folder is removed.
Instructions
Delete a mail folder without deleting any mail: its messages move to Trash first, then the empty folder is removed.
Use when: the owner asks to remove a folder they no longer need. Not for deleting messages while keeping the folder (use mail_delete_messages or mail_run_bulk_action), or for renaming (use mail_update_folder). Parameters:
name is a name from mail_list_folders (case-insensitive match accepted).
Omit confirm_token on the first call. Pass the preview's confirm_token only after the owner has seen the count and sample and said yes.
The token is valid for 10 minutes and only while the folder's message count and uidvalidity stay the same. Behavior:
An empty folder is removed at once, with no token.
A folder with mail returns a preview and changes nothing; with a valid token every message moves to Trash (recoverable there), then the folder goes.
If moving stops partway or new mail arrives meanwhile, the folder is kept and the error says how many already moved.
Refused: INBOX, Notes, the system folders (Sent, Drafts, Trash, Junk, Archive and their usual names) and folders with subfolders.
Not repeatable: a deleted folder is gone. Returns:
preview: {deleted: false, folder, messages, sample (subjects of the 3 most recently added), confirm_token, next, safety_warnings when a subject reads like instructions}.
done: {deleted: true, folder, messages_moved_to_trash}. Errors: 'There is no folder', 'has subfolders', or a stale or mismatched token (call again without it for a new preview).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The folder to delete (exact name from mail_list_folders). | |
| confirm_token | No | From the preview; needed when the folder holds mail. |