Get an API key
api.tools

deleteDocument

tools: { delete_document: api.tools.deleteDocument }

Lets a run remove a file or a folder from view on the caller's computer — into a recycle bin, not out of existence.

declaration onlyfreerecoverable
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

A declaration. And the one of the four that is not what its name suggests: nothing is destroyed.

What the model sends

pathstringrequired

The file or folder to remove, relative to the workspace.

// What the run reports back
{ path: "Launch plan/draft.md",
  trash: ".trash/2026-10-07T09-12-44-000Z/Launch plan/draft.md" }
# What the run reports back
{"path": "Launch plan/draft.md",
 "trash": ".trash/2026-10-07T09-12-44-000Z/Launch plan/draft.md"}

It is a move into .trash

The item goes to .trash/<timestamp>/<original path>. The timestamp is what keeps two deletions of the same path apart, and the original path is kept underneath so a restore is a move back.

// Restoring what a run removed
const trashed = ".trash/2026-10-07T09-12-44-000Z/Launch plan/draft.md";
await pc.files.move(trashed, "Launch plan/draft.md");
# Restoring what a run removed
trashed = ".trash/2026-10-07T09-12-44-000Z/Launch plan/draft.md"
pc.files.move(trashed, "Launch plan/draft.md")
Hidden folders stay out of a listing

A dotted name is skipped by files.list(), so the bin does not show up as work. Reading it is a matter of naming it — which is what makes the recovery possible without a second mechanism.

Why a run never deletes for real

An agent acts on text it has read — a page, a document, an instruction it was given. One mistaken step should not be final, and no model judgement is worth a file. So the destructive operation is not declared at all: what is declared is the reversible one.

Emptying the bin is yours to do

Nothing clears .trash on its own: deciding when something is really gone is the account holder's, not a run's.

for (const batch of await pc.files.list(".trash")) {
  if (Date.parse(batch.name.replace(/-(\d{3})Z$/, ".$1Z")) < Date.now() - 30 * 86_400_000) {
    await pc.files.remove(`.trash/${batch.name}`);
  }
}
import shutil, time

# Python's list() hides dot folders: walk .trash from the workspace root
month_ago = time.time() - 30 * 86_400
for batch in (pc.files.root / ".trash").iterdir():
    if batch.stat().st_mtime < month_ago:
        shutil.rmtree(batch)
It runs on the caller's computer, through the package

The server cannot reach a disk. When the agent calls this, the run asks the machine that holds the key to perform it, the package does the work there, and the answer goes back into the run. So it only works while your process is listening — and nothing of the file ever travels to be written.

Refusals the run reports

  • Nothing at that path.
  • A path outside the workspace, or an absolute one.
  • The workspace root.
  • A bin entry already holding the same path at the same instant.