Skip to main content

documents.delete_files

Deletes one or more files by name from a text namespace (storage-backed uploads, for example after documents.upload_file). The backend removes the file and associated derived content from the namespace. This is not the same as documents.delete, which removes indexed text documents by ID.

Parameters

str
required
The name of the target text namespace.
list[str]
required
Non-empty list of file names to delete (same names as returned by documents.list_files or used at upload).
Returns: Dict[str, Any] - A dictionary confirming the deletion request. Common response fields include success, message, namespace, and results (each item: file_name, status, message). Keys are snake_case after SDK normalization. Raises: NamespaceNotFound, InvalidInputError, AuthenticationError, APIError, MoorchehError.

Example

Delete Files Example

Async Example

Delete Files Async Example

Complete Example

Complete Delete Files Workflow

Important Notes

Per-file results: Check results for each file_name; statuses can differ when some files exist and others do not.
Multi-status (207): The API may return 207 when some deletions succeed and others do not; the SDK treats 200 and 207 as success responses.
Irreversible for storage objects: Deleting by file name removes that object from the namespace’s file storage workflow; confirm names before calling.

Best Practices

  • Delete only names you intend to remove; prefer listing (documents.list_files) to confirm names first
  • Inspect results and handle not_found (or similar statuses) without treating the whole call as a hard failure
  • Batch related removals in one call when the API allows your list size
  • Use documents.delete when you need to remove documents by ID from the text pipeline, not raw file names