Skip to main content

Usage

from morphik import Morphik

# Without authentication
db = Morphik()

# With authentication
db = Morphik("morphik://owner_id:token@api.morphik.ai")

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

# 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")
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:

Constructor

Both clients share the same constructor parameters:
Morphik(
    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 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

Document Retrieval

Document Updates & Summaries

Document Management

Folder & User Scoping

Apps & Ops

Chat & Conversation

Client Management

Context Manager

Using the Morphik client as a context manager ensures that resources are properly closed when the context exits.
with Morphik() as db:
    doc = db.ingest_text("Sample content")