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

# ingest_file

> Ingest a file document into Morphik

> [tab] Sync
>
> ```python theme={null}
> def ingest_file(
>     file: Union[str, bytes, BinaryIO, Path],
>     filename: Optional[str] = None,
>     metadata: Optional[Dict[str, Any]] = None,
>     use_colpali: bool = True,
> ) -> Document
> ```

> [tab] Async
>
> ```python theme={null}
> async def ingest_file(
>     file: Union[str, bytes, BinaryIO, Path],
>     filename: Optional[str] = None,
>     metadata: Optional[Dict[str, Any]] = None,
>     use_colpali: bool = True,
> ) -> Document
> ```

## Parameters

* `file` (Union\[str, bytes, BinaryIO, Path]): File to ingest (path string, bytes, file object, or Path)
* `filename` (str, optional): Name of the file
* `metadata` (Dict\[str, Any], optional): Optional metadata dictionary
* `use_colpali` (bool, optional): Whether to use ColPali-style embedding model to ingest the file (slower, but significantly better retrieval accuracy for images). Defaults to True.

### Typed Metadata

Use Python-native values (e.g., `datetime`, `date`, `Decimal`) in the `metadata` dict. The SDK serializes them and adds the corresponding `metadata_types`, so you can run the advanced filters documented in [Metadata Filtering](https://morphik.ai/docs/concepts/metadata-filtering.md).

## Returns

* `Document`: Metadata of the ingested document

## Examples

> [tab] Sync
>
> ```python theme={null}
> from morphik import Morphik
>
> db = Morphik()
>
> doc = db.ingest_file(
>     "document.pdf",
>     filename="document.pdf",
>     metadata={"category": "research", "owner": "alice"},
>     use_colpali=True,
> )
> ```

> [tab] Async
>
> ```python theme={null}
> from morphik import AsyncMorphik
>
> async with AsyncMorphik() as db:
>     doc = await db.ingest_file(
>         "document.pdf",
>         filename="document.pdf",
>         metadata={"category": "research", "owner": "alice"},
>         use_colpali=True,
>     )
> ```

## Async Processing

Document ingestion is processed asynchronously. The returned `Document` object contains an `external_id` that you can use to track the document's processing status:

* Use [`get_document_status`](./get_document_status) to check if processing is complete
* The document won't appear in retrieval results until processing completes

```python theme={null}
# Check processing status
doc = db.ingest_file("document.pdf")
status = db.get_document_status(doc.external_id)
print(f"Status: {status.get('status')}")  # "processing", "completed", or "failed"
```


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