TrekMail TrekMail

Drive Bulk File Operations via API/MCP

This guide explains Move, trash, restore, or purge many Drive files and folders safely with REST API endpoints or MCP tools. so you can complete the TrekMail task with confidence.

Article details

Type, difficulty, plans, and last updated info.

Type
Reference
Difficulty
Intermediate
Plans
Starter · Pro · Agency · + Drive Add-on
Last updated
May 9, 2026

Bulk operations let an integration act on many Drive files and folders in one request. They are useful for archiving old folders, restoring a mistaken cleanup, moving generated reports, or clearing reviewed trash.

Because bulk actions can touch a lot of data, design them with conservative scopes, previews, and audit review.

What bulk operations can do

Drive supports bulk actions for:

  • Trash files and folders.
  • Restore files and folders from Trash.
  • Move files and folders to a target folder.
  • Permanently purge trashed files and folders.

Bulk requests can include up to 5,000 selected IDs. For larger cleanups, run multiple reviewed batches rather than one unbounded job.

Selecting IDs

Use browse, folder tree, search, or select-all helpers to build a list of IDs. MCP includes drive_select_all_ids for workflows that need "everything in this folder" without forcing the agent to paginate manually.

Before executing a destructive batch, have the agent summarize the planned action:

  • Target Drive space.
  • Number of files and folders.
  • Destination folder, if moving.
  • Whether the operation is recoverable.
  • Required scope and MCP safety gate.

REST endpoints

POST /api/v1/drive/spaces/{space}/bulk:trash
POST /api/v1/drive/spaces/{space}/bulk:restore
POST /api/v1/drive/spaces/{space}/bulk:move
POST /api/v1/drive/spaces/{space}/bulk:purge

Use an Idempotency-Key header for every bulk request. If a retry happens, TrekMail can return the original result instead of repeating the batch.

MCP tools

drive_bulk_trash
drive_bulk_restore
drive_bulk_move
drive_bulk_purge

drive_bulk_purge is permanent and requires the matching purge scope. In MCP it should also be protected by TREKMAIL_ALLOW_DESTRUCTIVE=true.

Safe cleanup pattern

For most automations, use a two-step cleanup:

  1. Move old files to an Archive folder or Trash.
  2. Wait for human review or a separate scheduled maintenance job before purge.

This keeps the daily agent useful while preserving recovery options.

Permission design

Operation Scope level Recoverable?
Bulk move write Yes
Bulk trash write Yes, until purged/retention ends
Bulk restore write Yes
Bulk purge purge No

Keep purge in a separate token. If a workflow only archives files, it does not need purge at all.

Related articles

Jump to nearby guides that continue the workflow.

We use cookies for essential functionality. No ads, no ad tracking.

or
or

Reset email sent

If an account exists for this email, we've sent password reset instructions.

By continuing, you agree to TrekMail's Terms and Privacy Policy.