> ## 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.

# update_document_by_filename_metadata

> Update a document's metadata using filename to identify the document

> [tab] Sync
>
> ```python theme={null}
> def update_document_by_filename_metadata(
>     filename: str,
>     metadata: Dict[str, Any],
>     new_filename: Optional[str] = None,
> ) -> Document
> ```

> [tab] Async
>
> ```python theme={null}
> async def update_document_by_filename_metadata(
>     filename: str,
>     metadata: Dict[str, Any],
>     new_filename: Optional[str] = None,
> ) -> Document
> ```

## Parameters

* `filename` (str): Filename of the document to update
* `metadata` (Dict\[str, Any]): Metadata to update
* `new_filename` (str, optional): Optional new filename to assign to the document

## Returns

* `Document`: Updated document metadata

## Examples

> [tab] Sync
>
> ```python theme={null}
> from morphik import Morphik
>
> db = Morphik()
>
> # Update just the metadata of a document identified by filename
> updated_doc = db.update_document_by_filename_metadata(
>     filename="report.pdf",
>     metadata={"status": "reviewed", "reviewer": "Jane Smith"},
>     new_filename="reviewed_report.pdf"  # Optional: rename the file
> )
> print(f"Updated metadata: {updated_doc.metadata}")
> ```

> [tab] Async
>
> ```python theme={null}
> from morphik import AsyncMorphik
>
> async with AsyncMorphik() as db:
>     # Update just the metadata of a document identified by filename
>     updated_doc = await db.update_document_by_filename_metadata(
>         filename="report.pdf",
>         metadata={"status": "reviewed", "reviewer": "Jane Smith"},
>         new_filename="reviewed_report.pdf"  # Optional: rename the file
>     )
>     print(f"Updated metadata: {updated_doc.metadata}")
> ```


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