> ## Documentation Index
> Fetch the complete documentation index at: https://morphik.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# delete_document

> Delete a document and all its associated data

## Usage

> [tab] Sync
>
> ```python theme={null}
> from morphik import Morphik
>
> db = Morphik()
>
> # Delete a document by its ID
> result = db.delete_document("doc_123456")
> print(result["message"])  # "Document doc_123456 deleted successfully"
> ```

> [tab] Async
>
> ```python theme={null}
> from morphik import AsyncMorphik
>
> async with AsyncMorphik() as db:
>     # Delete a document by its ID
>     result = await db.delete_document("doc_123456")
>     print(result["message"])  # "Document doc_123456 deleted successfully"
> ```

## Parameters

* `document_id` (str): ID of the document to delete

## Returns

A dictionary containing information about the deletion operation:

* `message` (str): A success message indicating the document was deleted
* `document_id` (str): The ID of the deleted document
* Additional fields may be present with more details about the operation

## Description

This method deletes a document and all its associated data, including:

* Document metadata in the database
* Document content in storage
* Document chunks and embeddings in the vector store

This operation is permanent and cannot be undone.

## Finding Document IDs

If you don't know the document ID, you can use other methods to find it:

> [tab] Sync
>
> ```python theme={null}
> # List documents to find IDs
> docs = db.list_documents(limit=10)
> for doc in docs:
>     print(f"ID: {doc.external_id}, Filename: {doc.filename}")
>
> # Or get document by filename
> doc = db.get_document_by_filename("report.pdf")
> document_id = doc.external_id
>
> # Then delete it
> result = db.delete_document(document_id)
> ```

> [tab] Async
>
> ```python theme={null}
> # List documents to find IDs
> docs = await db.list_documents(limit=10)
> for doc in docs:
>     print(f"ID: {doc.external_id}, Filename: {doc.filename}")
>
> # Or get document by filename
> doc = await db.get_document_by_filename("report.pdf")
> document_id = doc.external_id
>
> # Then delete it
> result = await db.delete_document(document_id)
> ```

## Notes

* For convenience, you can also use the [delete\_document\_by\_filename](https://morphik.ai/docs/python-sdk/delete_document_by_filename.md) method if you know the filename but not the ID.
* This operation requires appropriate permissions for the document.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.