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

# wait_for_document_completion

> Block until a document finishes processing

> [tab] Sync
>
> ```python theme={null}
> def wait_for_document_completion(
>     document_id: str,
>     timeout_seconds: int = 300,
>     check_interval_seconds: int = 2,
>     progress_callback: Optional[Callable[[int, int, str, float], None]] = None,
> ) -> Document
> ```

> [tab] Async
>
> ```python theme={null}
> async def wait_for_document_completion(
>     document_id: str,
>     timeout_seconds: int = 300,
>     check_interval_seconds: int = 2,
>     progress_callback: Optional[Callable[[int, int, str, float], None]] = None,
> ) -> Document
> ```

## Parameters

* `document_id` (str): ID of the document to wait for
* `timeout_seconds` (int, optional): Maximum time to wait for completion. Defaults to 300.
* `check_interval_seconds` (int, optional): Delay between status checks. Defaults to 2.
* `progress_callback` (callable, optional): Receives progress updates as `(current_step, total_steps, step_name, percentage)`

## Returns

* `Document`: Updated document metadata once processing completes

## Examples

> [tab] Sync
>
> ```python theme={null}
> from morphik import Morphik
>
> db = Morphik()
> doc = db.ingest_text("Sample content")
> ready = db.wait_for_document_completion(doc.external_id)
> print(ready.status)
> ```

> [tab] Async
>
> ```python theme={null}
> from morphik import AsyncMorphik
>
> async with AsyncMorphik() as db:
>     doc = await db.ingest_text("Sample content")
>     ready = await db.wait_for_document_completion(doc.external_id)
>     print(ready.status)
> ```


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