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

<Tabs>
  <Tab title="Sync">
    ```python theme={null}
    def update_document_by_filename_metadata(
        filename: str,
        metadata: Dict[str, Any],
        new_filename: Optional[str] = None,
    ) -> Document
    ```
  </Tab>

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

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

<Tabs>
  <Tab title="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>

  <Tab title="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}")
    ```
  </Tab>
</Tabs>
