Get an API key
run · write

dropCollection

storage.run({ action: "dropCollection", collection })

Removes a collection and everything in it. It tells you how many documents went.

document databasefreenot reversible
Using Python?

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

await storage.run({ action: "dropCollection", collection: "temp_import" });
// { ok: true, dropped: "temp_import", documents: 48211 }
storage.run(action="dropCollection", collection="temp_import")
# {"ok": True, "dropped": "temp_import", "documents": 48211}
documents is how many you just destroyed

It comes back after the fact, not before. Read the count yourself first if the number would have changed your mind — that call is free.

const { count } = await storage.run({ action: "count", collection });
if (count > 0) throw new Error(`${collection} still holds ${count} documents`);

await storage.run({ action: "dropCollection", collection });
count = storage.run(action="count", collection=collection)["count"]
if count > 0:
    raise RuntimeError(f"{collection} still holds {count} documents")

storage.run(action="dropCollection", collection=collection)

A collection that is not there is refused

Rather than answering « done » for something that never existed — which would hide a typo in a name, at the exact moment a typo matters most.

const existing = await storage.run({ action: "collections" });
if (!existing.some((c) => c.name === collection)) {
  // Nothing to drop. A misspelling here would otherwise look like success.
}
existing = storage.run(action="collections")
if not any(c["name"] == collection for c in existing):
    pass  # Nothing to drop. A misspelling here would otherwise look like success.

It works even when the storage is full

Like delete, dropping is allowed past the quota: it is how you make room, so refusing it would leave a storage that cannot be emptied.

What an agent may do with it

The most open mode is the only one that lets this through unasked

In the planning mode it is refused outright. Everywhere else it is asked for. If an agent of yours should never drop anything, say so in its instructions and answer the prompt — the mode alone is a blunt instrument.