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

# Morphik

> Main client for document operations in Morphik

## Usage

> [tab] Sync
>
> ```python theme={null}
> from morphik import Morphik
>
> # Without authentication
> db = Morphik()
>
> # With authentication
> db = Morphik("morphik://owner_id:token@api.morphik.ai")
> ```

> [tab] Async
>
> ```python theme={null}
> from morphik import AsyncMorphik
>
> # Without authentication
> async with AsyncMorphik() as db:
>     doc = await db.ingest_text("Sample content")
>
> # With authentication
> async with AsyncMorphik("morphik://owner_id:token@api.morphik.ai") as db:
>     doc = await db.ingest_text("Sample content")
> ```

## User and Folder Scoping

Morphik supports organizing and isolating data by user and folder. This provides a way to build multi-tenant applications and organize documents across projects.

### Quick Overview

> [tab] Sync
>
> ```python theme={null}
> # Folder scoping - organize by project or category
> folder = db.create_folder("project_x")
> doc = folder.ingest_text("This document belongs to Project X")
>
> # User scoping - isolate data by end user
> user_scope = db.signin("user123")
> doc = user_scope.ingest_text("This belongs to user123 only")
>
> # Combined scoping - organize by both user and folder
> user_folder_scope = folder.signin("user123")
> doc = user_folder_scope.ingest_text("This belongs to user123 in project_x")
> ```

> [tab] Async
>
> ```python theme={null}
> # Folder scoping - organize by project or category
> folder = db.create_folder("project_x")
> doc = await folder.ingest_text("This document belongs to Project X")
>
> # User scoping - isolate data by end user
> user_scope = db.signin("user123")
> doc = await user_scope.ingest_text("This belongs to user123 only")
>
> # Combined scoping - organize by both user and folder
> user_folder_scope = folder.signin("user123")
> doc = await user_folder_scope.ingest_text("This belongs to user123 in project_x")
> ```

Nested folders are supported across the SDK. Use canonical paths (e.g., `"/projects/alpha/specs"`) when creating or scoping folders, and pass `folder_depth` on retrieval/list helpers to include descendant folders.

For detailed documentation and examples:

* [Folder Management](https://morphik.ai/docs/python-sdk/folders.md) - Organizing documents by logical groups
* [User Management](https://morphik.ai/docs/python-sdk/users.md) - Multi-tenant isolation and user-level data management

## Constructor

Both clients share the same constructor parameters:

> [tab] Sync
>
> ```python theme={null}
> Morphik(
>     uri: Optional[str] = None,
>     timeout: int = 30,
>     is_local: bool = False,
>     http2: Optional[bool] = None,
>     http2_fallback: bool = True,
> )
> ```

> [tab] Async
>
> ```python theme={null}
> AsyncMorphik(
>     uri: Optional[str] = None,
>     timeout: int = 30,
>     is_local: bool = False,
>     http2: Optional[bool] = None,
>     http2_fallback: bool = True,
> )
> ```

### Parameters

* `uri` (str, optional): Morphik URI in format "morphik://\<owner\_id>:\<token>@\<host>". If not provided, connects to [http://localhost:8000](http://localhost:8000) without authentication.
* `timeout` (int, optional): Request timeout in seconds. Defaults to 30.
* `is_local` (bool, optional): Whether connecting to local development server. Defaults to False.
* `http2` (bool, optional): Enable HTTP/2 when possible. Defaults to None (auto-disabled for local).
* `http2_fallback` (bool, optional): Fall back to HTTP/1.1 if HTTP/2 fails. Defaults to True.

## Methods

Morphik provides the following methods. Each method page includes both synchronous and asynchronous versions.

### Document Ingestion

* [ingest\_text](https://morphik.ai/docs/python-sdk/ingest_text.md)
* [ingest\_file](https://morphik.ai/docs/python-sdk/ingest_file.md)
* [ingest\_files](https://morphik.ai/docs/python-sdk/ingest_files.md)
* [ingest\_directory](https://morphik.ai/docs/python-sdk/ingest_directory.md)
* [query\_document](https://morphik.ai/docs/python-sdk/query_document.md)

### Document Retrieval

* [retrieve\_chunks](https://morphik.ai/docs/python-sdk/retrieve_chunks.md)
* [retrieve\_chunks\_grouped](https://morphik.ai/docs/python-sdk/retrieve_chunks_grouped.md)
* [retrieve\_docs](https://morphik.ai/docs/python-sdk/retrieve_docs.md)
* [query](https://morphik.ai/docs/python-sdk/query.md)
* [list\_documents](https://morphik.ai/docs/python-sdk/list_documents.md)
* [search\_documents](https://morphik.ai/docs/python-sdk/search_documents.md)
* [get\_document](https://morphik.ai/docs/python-sdk/get_document.md)
* [get\_document\_by\_filename](https://morphik.ai/docs/python-sdk/get_document_by_filename.md)

### Document Updates & Summaries

* [update\_document\_with\_text](https://morphik.ai/docs/python-sdk/update_document_with_text.md)
* [update\_document\_with\_file](https://morphik.ai/docs/python-sdk/update_document_with_file.md)
* [update\_document\_metadata](https://morphik.ai/docs/python-sdk/update_document_metadata.md)
* [update\_document\_by\_filename\_with\_text](https://morphik.ai/docs/python-sdk/update_document_by_filename_with_text.md)
* [update\_document\_by\_filename\_with\_file](https://morphik.ai/docs/python-sdk/update_document_by_filename_with_file.md)
* [update\_document\_by\_filename\_metadata](https://morphik.ai/docs/python-sdk/update_document_by_filename_metadata.md)
* [get\_document\_summary](https://morphik.ai/docs/python-sdk/get_document_summary.md)
* [upsert\_document\_summary](https://morphik.ai/docs/python-sdk/upsert_document_summary.md)
* [get\_document\_status](https://morphik.ai/docs/python-sdk/get_document_status.md)
* [wait\_for\_document\_completion](https://morphik.ai/docs/python-sdk/wait_for_document_completion.md)

### Document Management

* [get\_document\_file](https://morphik.ai/docs/python-sdk/get_document_file.md)
* [extract\_document\_pages](https://morphik.ai/docs/python-sdk/extract_document_pages.md)
* [get\_document\_download\_url](https://morphik.ai/docs/python-sdk/get_document_download_url.md)
* [delete\_document](https://morphik.ai/docs/python-sdk/delete_document.md)
* [delete\_document\_by\_filename](https://morphik.ai/docs/python-sdk/delete_document_by_filename.md)
* [batch\_get\_documents](https://morphik.ai/docs/python-sdk/batch_get_documents.md)
* [batch\_get\_chunks](https://morphik.ai/docs/python-sdk/batch_get_chunks.md)

### Folder & User Scoping

* [folders](https://morphik.ai/docs/python-sdk/folders.md)
* [create\_folder](https://morphik.ai/docs/python-sdk/create_folder.md)
* [list\_folders](https://morphik.ai/docs/python-sdk/list_folders.md)
* [get\_folder](https://morphik.ai/docs/python-sdk/get_folder.md)
* [get\_folder\_by\_name](https://morphik.ai/docs/python-sdk/get_folder_by_name.md)
* [get\_folder\_summary](https://morphik.ai/docs/python-sdk/get_folder_summary.md)
* [upsert\_folder\_summary](https://morphik.ai/docs/python-sdk/upsert_folder_summary.md)
* [get\_folders\_summary](https://morphik.ai/docs/python-sdk/get_folders_summary.md)
* [get\_folders\_details](https://morphik.ai/docs/python-sdk/get_folders_details.md)
* [add\_document\_to\_folder](https://morphik.ai/docs/python-sdk/add_document_to_folder.md)
* [remove\_document\_from\_folder](https://morphik.ai/docs/python-sdk/remove_document_from_folder.md)
* [delete\_folder](https://morphik.ai/docs/python-sdk/delete_folder.md)
* [users](https://morphik.ai/docs/python-sdk/users.md)

### Apps & Ops

* [list\_apps](https://morphik.ai/docs/python-sdk/list_apps.md)
* [create\_app](https://morphik.ai/docs/python-sdk/create_app.md)
* [generate\_cloud\_uri](https://morphik.ai/docs/python-sdk/generate_cloud_uri.md)
* [rename\_app](https://morphik.ai/docs/python-sdk/rename_app.md)
* [rotate\_app\_token](https://morphik.ai/docs/python-sdk/rotate_app_token.md)
* [delete\_app](https://morphik.ai/docs/python-sdk/delete_app.md)
* [requeue\_ingestion\_jobs](https://morphik.ai/docs/python-sdk/requeue_ingestion_jobs.md)
* [get\_logs](https://morphik.ai/docs/python-sdk/get_logs.md)
* [get\_health](https://morphik.ai/docs/python-sdk/get_health.md)
* [get\_app\_storage\_usage](https://morphik.ai/docs/python-sdk/get_app_storage_usage.md)
* [ping](https://morphik.ai/docs/python-sdk/ping.md)

### Chat & Conversation

* [list\_chat\_conversations](https://morphik.ai/docs/python-sdk/list_chat_conversations.md)
* [get\_chat\_history](https://morphik.ai/docs/python-sdk/get_chat_history.md)

### Client Management

* [close](https://morphik.ai/docs/python-sdk/close.md)

## Context Manager

Using the Morphik client as a context manager ensures that resources are properly closed when the context exits.

> [tab] Sync
>
> ```python theme={null}
> with Morphik() as db:
>     doc = db.ingest_text("Sample content")
> ```

> [tab] Async
>
> ```python theme={null}
> async with AsyncMorphik() as db:
>     doc = await db.ingest_text("Sample content")
> ```


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