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

# get_document_by_filename

> Get document metadata by filename

<Tabs>
  <Tab title="Sync">
    ```python theme={null}
    def get_document_by_filename(filename: str) -> Document
    ```
  </Tab>

  <Tab title="Async">
    ```python theme={null}
    async def get_document_by_filename(filename: str) -> Document
    ```
  </Tab>
</Tabs>

## Parameters

* `filename` (str): Filename of the document to retrieve

## Returns

* `Document`: Document metadata

## Examples

<Tabs>
  <Tab title="Sync">
    ```python theme={null}
    from morphik import Morphik

    db = Morphik()

    doc = db.get_document_by_filename("report.pdf")
    print(f"Document ID: {doc.external_id}")
    print(f"Content Type: {doc.content_type}")
    print(f"Metadata: {doc.metadata}")
    ```
  </Tab>

  <Tab title="Async">
    ```python theme={null}
    from morphik import AsyncMorphik

    async with AsyncMorphik() as db:
        doc = await db.get_document_by_filename("report.pdf")
        print(f"Document ID: {doc.external_id}")
        print(f"Content Type: {doc.content_type}")
        print(f"Metadata: {doc.metadata}")
    ```
  </Tab>
</Tabs>

## Document Properties

The `Document` object returned by this method has the following properties:

* `external_id` (str): Unique document identifier
* `content_type` (str): Content type of the document
* `filename` (Optional\[str]): Original filename if available
* `metadata` (Dict\[str, Any]): User-defined metadata
* `storage_info` (Dict\[str, str]): Storage-related information
* `system_metadata` (Dict\[str, Any]): System-managed metadata
* `chunk_ids` (List\[str]): IDs of document chunks

## Document Methods

The `Document` object also provides the following methods:

<Tabs>
  <Tab title="Sync">
    * `update_with_text()`: Update the document with new text content
    * `update_with_file()`: Update the document with content from a file
    * `update_metadata()`: Update the document's metadata only
  </Tab>

  <Tab title="Async">
    * `update_with_text()`: Update the document with new text content (use with `await`)
    * `update_with_file()`: Update the document with content from a file (use with `await`)
    * `update_metadata()`: Update the document's metadata only (use with `await`)
  </Tab>
</Tabs>
