Skip to content

Commit 421d414

Browse files
authored
Enhance documentation for folder management and nested folder support across SDK methods. Update parameters to include folder_name and folder_depth for scoping in various document and graph operations. (#21)
1 parent ad9fa73 commit 421d414

26 files changed

+282
-59
lines changed

python-sdk/add_document_to_folder.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ description: "Add an existing document to a folder"
2424

2525
## Parameters
2626

27-
- `folder_id_or_name` (str): Folder identifier. Accepts either the folder's UUID or its name.
27+
- `folder_id_or_name` (str): Folder identifier. Accepts the folder's UUID, name, or canonical path (e.g., `/projects/alpha/specs`; leading slash optional).
2828
- `document_id` (str): Identifier of the document to move into the folder.
2929

3030
## Returns
@@ -42,7 +42,7 @@ description: "Add an existing document to a folder"
4242
folder = db.get_folder("marketing_docs")
4343

4444
db.add_document_to_folder(folder.id, "doc_123")
45-
db.add_document_to_folder("marketing_docs", "doc_456")
45+
db.add_document_to_folder("/projects/alpha/specs", "doc_456")
4646
```
4747
</Tab>
4848
<Tab title="Async">
@@ -53,7 +53,7 @@ description: "Add an existing document to a folder"
5353
folder = await db.get_folder("marketing_docs")
5454

5555
await db.add_document_to_folder(folder.id, "doc_123")
56-
await db.add_document_to_folder("marketing_docs", "doc_456")
56+
await db.add_document_to_folder("/projects/alpha/specs", "doc_456")
5757
```
5858
</Tab>
5959
</Tabs>

python-sdk/batch_get_chunks.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ description: "Retrieve specific chunks by their document ID and chunk number"
2929
## Parameters
3030

3131
- `sources` (List[Union[ChunkSource, Dict[str, Any]]]): List of ChunkSource objects or dictionaries with document_id and chunk_number
32-
- `folder_name` (str | List[str], optional): Optional folder scope. Accepts a single folder name or a list of folder names.
32+
- `folder_name` (str | List[str], optional): Optional folder scope. Accepts canonical paths or a list of paths/names.
3333
- `use_colpali` (bool, optional): Whether to request multimodal chunks when available. Defaults to True.
3434
- `output_format` (str, optional): Controls how image chunks are returned. Set to `"url"` to receive presigned URLs; omit or set to `"base64"` (default) to receive base64 content.
3535

@@ -100,4 +100,4 @@ Each `FinalChunkResult` object in the returned list has the following properties
100100
- `metadata` (Dict[str, Any]): Document metadata
101101
- `content_type` (str): Content type
102102
- `filename` (Optional[str]): Original filename
103-
- `download_url` (Optional[str]): URL to download full document
103+
- `download_url` (Optional[str]): URL to download full document

python-sdk/batch_get_documents.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ description: "Retrieve multiple documents by their IDs in a single batch operati
2525
## Parameters
2626

2727
- `document_ids` (List[str]): List of document IDs to retrieve
28-
- `folder_name` (str | List[str], optional): Optional folder scope. Accepts a single folder name or a list of folder names.
28+
- `folder_name` (str | List[str], optional): Optional folder scope. Accepts canonical paths or a list of paths/names.
2929

3030
## Returns
3131

@@ -67,4 +67,5 @@ Each `Document` object in the returned list has the following properties:
6767
- `metadata` (Dict[str, Any]): User-defined metadata
6868
- `storage_info` (Dict[str, str]): Storage-related information
6969
- `system_metadata` (Dict[str, Any]): System-managed metadata
70-
- `chunk_ids` (List[str]): IDs of document chunks
70+
- `chunk_ids` (List[str]): IDs of document chunks
71+
- `folder_path` (Optional[str]): Canonical folder path (includes nested parents when scoped)

python-sdk/create_folder.mdx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ description: "Create a new folder for organizing documents"
99
def create_folder(
1010
name: str,
1111
description: Optional[str] = None,
12+
full_path: Optional[str] = None,
13+
parent_id: Optional[str] = None,
1214
) -> Folder
1315
```
1416
</Tab>
@@ -17,17 +19,19 @@ description: "Create a new folder for organizing documents"
1719
async def create_folder(
1820
name: str,
1921
description: Optional[str] = None,
22+
full_path: Optional[str] = None,
23+
parent_id: Optional[str] = None,
2024
) -> Folder
2125
```
2226
</Tab>
2327
</Tabs>
2428

2529
## Parameters
2630

27-
- `name` (str): Folder name. Must be unique per app and cannot contain `/`.
31+
- `name` (str): Folder name (leaf segment when using nested paths). If `full_path` is omitted, this becomes the canonical path.
2832
- `description` (str, optional): Optional description of the folder.
29-
30-
> ⚠️ Nested folders are not supported. Use underscores (`_`) to mimic hierarchy (e.g., `team_reports_q1`).
33+
- `full_path` (str, optional): Canonical folder path (e.g., `"/projects/alpha/specs"`). Leading slash is optional; parents are created automatically.
34+
- `parent_id` (str, optional): Explicit parent folder ID. Usually not needed—`full_path` handles hierarchy creation.
3135

3236
## Returns
3337

@@ -39,9 +43,17 @@ description: "Create a new folder for organizing documents"
3943
<Tab title="Sync">
4044
```python
4145
from morphik import Morphik
42-
46+
4347
db = Morphik()
4448
folder = db.create_folder("marketing_docs", description="All marketing collateral")
49+
50+
# Create a nested folder (parents auto-created)
51+
nested = db.create_folder(
52+
name="specs",
53+
full_path="/projects/alpha/specs",
54+
description="All project specs",
55+
)
56+
print(nested.full_path) # "/projects/alpha/specs"
4557
```
4658
</Tab>
4759
<Tab title="Async">
@@ -50,6 +62,13 @@ description: "Create a new folder for organizing documents"
5062

5163
async with AsyncMorphik() as db:
5264
folder = await db.create_folder("marketing_docs", description="All marketing collateral")
65+
66+
nested = await db.create_folder(
67+
name="specs",
68+
full_path="/projects/alpha/specs",
69+
description="All project specs",
70+
)
71+
print(nested.full_path) # "/projects/alpha/specs"
5372
```
5473
</Tab>
5574
</Tabs>

python-sdk/create_graph.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: "Create a graph from documents"
1111
filters: Optional[Dict[str, Any]] = None,
1212
documents: Optional[List[str]] = None,
1313
prompt_overrides: Optional[Union[GraphPromptOverrides, Dict[str, Any]]] = None,
14+
folder_name: Optional[Union[str, List[str]]] = None,
15+
end_user_id: Optional[str] = None,
1416
) -> Graph
1517
```
1618
</Tab>
@@ -21,6 +23,8 @@ description: "Create a graph from documents"
2123
filters: Optional[Dict[str, Any]] = None,
2224
documents: Optional[List[str]] = None,
2325
prompt_overrides: Optional[Union[GraphPromptOverrides, Dict[str, Any]]] = None,
26+
folder_name: Optional[Union[str, List[str]]] = None,
27+
end_user_id: Optional[str] = None,
2428
) -> Graph
2529
```
2630
</Tab>
@@ -32,6 +36,8 @@ description: "Create a graph from documents"
3236
- `filters` (Dict[str, Any], optional): Optional metadata filters to determine which documents to include
3337
- `documents` (List[str], optional): Optional list of specific document IDs to include
3438
- `prompt_overrides` (GraphPromptOverrides | Dict[str, Any], optional): Optional customizations for entity extraction and resolution prompts
39+
- `folder_name` (str | List[str], optional): Optional folder scope (canonical path or list of paths/names)
40+
- `end_user_id` (str, optional): Optional end-user scope
3541

3642
## Returns
3743

@@ -57,6 +63,7 @@ graph is done, or poll `graph.is_processing` / `graph.is_completed`.
5763
graph = db.create_graph(
5864
name="research_graph",
5965
filters={"category": "research"},
66+
folder_name="/projects/alpha",
6067
)
6168

6269
# Option 1: Block until finished
@@ -127,6 +134,7 @@ graph is done, or poll `graph.is_processing` / `graph.is_completed`.
127134
graph = await db.create_graph(
128135
name="research_graph",
129136
filters={"category": "research"},
137+
folder_name="/projects/alpha",
130138
)
131139

132140
# Wait for completion
@@ -206,3 +214,4 @@ The returned `Graph` object has the following properties:
206214
- `created_at` (datetime): Creation timestamp
207215
- `updated_at` (datetime): Last update timestamp
208216
- `owner` (Dict[str, str]): Graph owner information
217+
- `folder_path` (Optional[str]): Canonical folder path for the graph (if scoped)

python-sdk/delete_folder.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ description: "Delete a folder and its documents"
2222

2323
## Parameters
2424

25-
- `folder_id_or_name` (str): Folder identifier. Accepts either the folder's UUID or its name.
25+
- `folder_id_or_name` (str): Folder identifier. Accepts the folder's UUID, name, or canonical path (e.g., `/projects/alpha/specs`; leading slash optional).
2626

2727
## Returns
2828

@@ -37,6 +37,7 @@ description: "Delete a folder and its documents"
3737

3838
db = Morphik()
3939
db.delete_folder("marketing_docs")
40+
db.delete_folder("/projects/alpha/specs")
4041
db.delete_folder("bfd74128-8539-4050-8938-542d6ee68be0")
4142
```
4243
</Tab>
@@ -46,6 +47,7 @@ description: "Delete a folder and its documents"
4647

4748
async with AsyncMorphik() as db:
4849
await db.delete_folder("marketing_docs")
50+
await db.delete_folder("/projects/alpha/specs")
4951
await db.delete_folder("bfd74128-8539-4050-8938-542d6ee68be0")
5052
```
5153
</Tab>

python-sdk/folders.mdx

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: "Organize and isolate data into logical folder groups in Morphik"
77

88
Folders in Morphik provide a way to organize documents into logical groups. This is particularly useful for multi-project environments where you want to maintain separation between different contexts. Documents within a folder are isolated from those in other folders, allowing for clean organization and data separation.
99

10-
> ℹ️ All folder APIs accept **either the folder’s UUID or its name**. Use whichever identifier you already have—Morphik resolves it automatically.
10+
> ℹ️ All folder APIs accept **folder UUIDs, names, or canonical paths** (e.g., `"/projects/alpha/specs"`). Folder objects expose `full_path`, `parent_id`, `depth`, and `child_count`; documents and graphs expose `folder_path` to mirror server responses.
1111
1212
## Creating and Accessing Folders
1313

@@ -20,9 +20,12 @@ Folders in Morphik provide a way to organize documents into logical groups. This
2020

2121
# Create a new folder
2222
folder = db.create_folder("marketing_docs")
23+
24+
# Create a nested folder (parents created automatically)
25+
nested = db.create_folder(full_path="/projects/alpha/specs")
2326

24-
# Access an existing folder by name or UUID
25-
folder = db.get_folder("marketing_docs")
27+
# Access an existing folder by name/path or UUID
28+
folder = db.get_folder("/projects/alpha")
2629
folder_by_id = db.get_folder(folder.id)
2730
```
2831
</Tab>
@@ -32,10 +35,12 @@ Folders in Morphik provide a way to organize documents into logical groups. This
3235

3336
async with AsyncMorphik() as db:
3437
# Create a new folder
35-
folder = db.create_folder("marketing_docs")
38+
folder = await db.create_folder("marketing_docs")
39+
40+
nested = await db.create_folder(full_path="/projects/alpha/specs")
3641

37-
# Access an existing folder by name or UUID
38-
folder = await db.get_folder("marketing_docs")
42+
# Access an existing folder by name/path or UUID
43+
folder = await db.get_folder("/projects/alpha")
3944
folder_by_id = await db.get_folder(folder.id)
4045
```
4146
</Tab>
@@ -88,6 +93,23 @@ Once you have a folder object, all operations performed on it are scoped to that
8893
</Tab>
8994
</Tabs>
9095

96+
## Nested Folders and Scope Depth
97+
98+
Folders can be nested arbitrarily. Use canonical paths (leading slash optional) to address them, and include descendant folders in retrieval/listing by setting `folder_depth`:
99+
100+
```python
101+
folder = db.create_folder(full_path="/projects/alpha/specs")
102+
103+
# Query across /projects/alpha and all children
104+
chunks = db.retrieve_chunks(
105+
query="design notes",
106+
folder_name="/projects/alpha",
107+
folder_depth=-1, # -1: all descendants, 0/None: exact only, n>0: include up to n levels
108+
)
109+
```
110+
111+
Folder-scoped helpers inherit the path automatically, so `folder.retrieve_chunks(..., folder_depth=-1)` will include its children.
112+
91113
## Folder Methods
92114

93115
All the core document operations available on the main Morphik client are also available on folder objects, but they are automatically scoped to the specific folder:
@@ -108,7 +130,7 @@ All the core document operations available on the main Morphik client are also a
108130

109131
## Managing Existing Documents and Folders
110132

111-
You can move previously ingested documents into a folder, remove them, or delete the entire folder. The SDK methods accept a folder name or UUID.
133+
You can move previously ingested documents into a folder, remove them, or delete the entire folder. The SDK methods accept a folder UUID, name, or canonical path.
112134

113135
<Tabs>
114136
<Tab title="Sync">
@@ -120,9 +142,9 @@ You can move previously ingested documents into a folder, remove them, or delete
120142

121143
document_id = "doc_123"
122144

123-
# Add an existing document to the folder (name or UUID works)
145+
# Add an existing document to the folder (name/path or UUID works)
124146
db.add_document_to_folder(folder.id, document_id)
125-
db.add_document_to_folder("marketing_docs", document_id)
147+
db.add_document_to_folder("/projects/alpha/specs", document_id)
126148

127149
# Remove the document from the folder
128150
db.remove_document_from_folder("marketing_docs", document_id)
@@ -140,7 +162,7 @@ You can move previously ingested documents into a folder, remove them, or delete
140162
document_id = "doc_123"
141163

142164
await db.add_document_to_folder(folder.id, document_id)
143-
await db.add_document_to_folder("marketing_docs", document_id)
165+
await db.add_document_to_folder("/projects/alpha/specs", document_id)
144166

145167
await db.remove_document_from_folder("marketing_docs", document_id)
146168

python-sdk/get_folder.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "get_folder"
3-
description: "Retrieve a folder by name or UUID"
3+
description: "Retrieve a folder by name, canonical path, or UUID"
44
---
55

66
<Tabs>
@@ -22,12 +22,14 @@ description: "Retrieve a folder by name or UUID"
2222

2323
## Parameters
2424

25-
- `folder_id_or_name` (str): Folder identifier. Accepts either the folder's UUID or its name.
25+
- `folder_id_or_name` (str): Folder identifier. Accepts the folder's UUID, name, or canonical path (e.g., `/projects/alpha/specs`; leading slash optional).
2626

2727
## Returns
2828

2929
- `Folder`: Folder object that can be used to scope operations (ingest, query, etc.).
3030

31+
Folder objects include hierarchy metadata such as `full_path`, `parent_id`, `depth`, and `child_count`, mirroring the server response.
32+
3133
## Examples
3234

3335
<Tabs>

python-sdk/get_folders_details.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ description: "Get detailed information about folders with optional document stat
4040

4141
## Parameters
4242

43-
- `identifiers` (List[str], optional): List of folder IDs or names. If None, returns all accessible folders.
43+
- `identifiers` (List[str], optional): List of folder IDs, names, or canonical paths (e.g., `/projects/alpha/specs`). If None, returns all accessible folders.
4444
- `include_document_count` (bool, optional): Include total document count. Defaults to True.
4545
- `include_status_counts` (bool, optional): Include document counts grouped by processing status. Defaults to False.
4646
- `include_documents` (bool, optional): Include paginated document list. Defaults to False.
@@ -79,7 +79,7 @@ Filters follow the same JSON syntax across the API. See the [Metadata Filtering
7979

8080
# Get specific folders with status counts
8181
response = db.get_folders_details(
82-
identifiers=["reports", "invoices"],
82+
identifiers=["/projects/reports", "invoices"],
8383
include_status_counts=True,
8484
)
8585
for folder_detail in response.folders:
@@ -176,6 +176,8 @@ Filters follow the same JSON syntax across the API. See the [Metadata Filtering
176176
- `folder` (FolderInfo): Folder information
177177
- `document_info` (FolderDocumentInfo | None): Document statistics and list
178178

179+
`FolderInfo` includes hierarchy fields: `full_path`, `parent_id`, `depth`, and `child_count`, plus description/name metadata.
180+
179181
### FolderDocumentInfo
180182

181183
- `total_count` (int | None): Total document count (when `include_document_count=True`)

python-sdk/get_folders_summary.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ The `FolderSummary` objects have the following properties:
7878

7979
- `id` (str): Unique folder identifier
8080
- `name` (str): Folder name
81+
- `full_path` (str | None): Canonical folder path (e.g., `/projects/alpha/specs`)
82+
- `parent_id` (str | None): Parent folder ID
83+
- `depth` (int | None): Depth in the hierarchy (root = 1)
8184
- `description` (str | None): Folder description
8285
- `doc_count` (int): Number of documents in the folder
8386
- `updated_at` (str | None): Last update timestamp

0 commit comments

Comments
 (0)