Parameters
sourceIdstringrequiredFrom list(). Missing → the SDK throws.
Returns
{
ok: true,
message: "…",
sourceId: "…",
removedChunks: 12 // how many indexed fragments went with it
}{
"ok": True,
"message": "…",
"sourceId": "…",
"removedChunks": 12, # how many indexed fragments went with it
}removedChunks is the useful one: it tells you how much of the semantic index this file was, and 0 means it was never indexed — which is normal for anything that is not a document.
What goes
| After delete() | |
|---|---|
| The bytes | gone |
| The record | gone — get() answers 404 |
| Its indexed fragments | gone, so search stops returning it |
| The storage's remaining space | given back |
| A local copy you saved with path | untouched, on your disk |
Read it out first if it mattered — reading is free — or keep the local copy that save({ path }) can write for you at the same time.
const file = await api.files.get(sourceId);
await fs.writeFile(`./archive/${file.name}`, file.content);
await api.files.delete(sourceId);from pathlib import Path
file = api.files.get(source_id)
content = file.content.encode() if isinstance(file.content, str) else file.content
Path("archive", file.name).write_bytes(content)
api.files.delete(source_id)Errors
| Code | Status | When |
|---|---|---|
| — (thrown locally) | — | No sourceId passed. |
| file_not_found | 404 | No file of this account with that id — including one already deleted. |
So deleting twice answers 404 the second time. When the goal was simply that the file be gone, treat that as success.
import { IaGenifyError } from "iagenify";
async function ensureGone(api, sourceId) {
try {
await api.files.delete(sourceId);
return "deleted";
} catch (err) {
if (err instanceof IaGenifyError && err.status === 404) return "already gone";
throw err;
}
}from iagenify import IaGenifyError
def ensure_gone(api, source_id):
try:
api.files.delete(source_id)
return "deleted"
except IaGenifyError as error:
if error.status == 404:
return "already gone"
raiseDeleting is how you take something out of search
Updating a file does not re-index it, so a correction made with update() leaves the old text findable. When a document must stop being findable as it was, delete it and save the new version.