Drive Bulk File Operations via API/MCP

Move, trash, restore, or purge many TrekMail Drive files and folders safely with REST API endpoints or MCP bulk tools — built for AI agent workflows.

Article details

Type, difficulty, plans, and last updated info.

Type
Reference
Difficulty
Intermediate
Plans
Starter · Pro · Agency · + Drive Add-on
Last updated
Sep 10, 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 a locally hosted MCP server, its administrator can also require TREKMAIL_ALLOW_DESTRUCTIVE=true before it is available.

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 necessary technologies to operate and secure TrekMail. Selecting Okay also allows limited analytics and advertising measurement described in our Cookie Policy.

Sign in to TrekMail

Access your dashboard, mailboxes and DNS.

or

12 characters passwords match

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.