Parameters
targetstringrequiredThe file or folder to delete. The workspace root is refused.
await pc.files.remove("Launch plan/draft.md");
// { ok: true }
// A folder goes with its contents, at every depth
await pc.files.remove("Archive/2026");pc.files.remove("Launch plan/draft.md")
# {"ok": True}
# A folder goes with its contents, at every depth
pc.files.remove("Archive/2026")There is no refusal on a folder that is not empty, and no listing of what went. If you want to know, list it first; if you want it back, move it aside instead.
The workspace itself is refused
remove("") raises invalid_path. Emptying the workspace is not an operation this class offers — it holds the files of every application on that machine, not only yours.
The recoverable version
Prefer a move into a hidden folder whenever the path came from a model, from a form, or from anything you did not compute yourself. It costs the same and it is reversible.
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
// Reversible
await pc.files.move(path, `.trash/${stamp}/${path}`);
// Final
await pc.files.remove(path);# Reversible: trash() moves it under .trash/<stamp>/
pc.files.trash(path)
# Final
pc.files.remove(path)Errors
| Code | Status | When |
|---|---|---|
| path_not_found | 404 | Nothing at that path. Deleting twice raises this the second time. |
| invalid_path | 400 | Absolute, outside the workspace, or the root. |
| local_files_require_node | 400 | The runtime has no filesystem. |
| storage_not_on_this_machine | 409 | Another computer's storage. |
import { IaGenifyError } from "iagenify";
async function removeIfThere(files, path) {
try {
await files.remove(path);
return true;
} catch (err) {
if (err instanceof IaGenifyError && err.code === "path_not_found") return false;
throw err;
}
}def remove_if_there(files, path):
if not (files.root / path).exists():
return False
files.remove(path)
return True