Index documents, read their content, and organize your library using your configured client.
- Index a document — upload a file and get its
doc_id. - Read a document — check status, retrieve the tree, or read pages.
- Manage documents — list or delete documents.
- Metadata (cloud) — attach your own tags.
- Folders (cloud) — organize and browse documents by folder.
Operations work in both index modes unless marked (cloud).
Index a document
Index a document and get back a doc_id used by every other operation.
result = client.submit_document("./2023-annual-report.pdf")
doc_id = result["doc_id"]Example Response
{
"doc_id": "pi-abc123def456",
"name": "2023-annual-report.pdf"
}name is the stored document name. A name already in use gains a numeric suffix (name_1 … name_99) and a UserWarning is emitted.
Cloud
Cloud accepts PDF, PPTX, and Word. Uploads process asynchronously — either block with wait=True, or submit many documents and poll afterwards.
# Block until ready
doc_id = client.submit_document("./report.pdf", wait=True)["doc_id"]
# Or poll yourself
doc_id = client.submit_document("./report.pdf")["doc_id"]
if client.get_document(doc_id)["status"] == "completed":
print("Document processing completed")submit_document() parameters
submit_document() parameters| Name | Type | Required | Description | Default |
|---|---|---|---|---|
| file_path | string | yes | Local path to the file. Cloud accepts PDF, PPTX, and Word; local mode accepts PDF only. | - |
| mode | string | no | Processing mode. Local uses Flash indexing. Cloud modes are passed through (e.g. "mcp"). | None |
| metadata | dict | no | Your own tags on the document — see Metadata. | None |
| wait | boolean | no | Return only once the document is ready. Cloud: polls until "completed". Local: indexing is already synchronous. | False |
| folder_id | string | no | Cloud-only — folder ID. | None |
Read a document
If you have a document name, use get_document_id() to look up its ID before reading it:
doc_id = client.get_document_id("report.pdf")
doc_id = client.get_document_id("Research/Papers/report.pdf") # a path works tooA path is accepted as well as a bare name: the folder part is stripped, because document names are unique across a library. This raises PageIndexAPIError if no document with that name exists.
Document info
meta = client.get_document(doc_id)
print(f"{meta['name']}: {meta['status']}, {meta['pageNum']} pages")get_document() response fields
get_document() response fields| Field | Type | Description |
|---|---|---|
| id | string | Document ID |
| name | string | Document filename |
| description | string | Document description (if available) |
| status | string | "queued", "processing", "completed", or "failed" |
| createdAt | string | Creation timestamp, UTC with no timezone marker |
| pageNum | int | Number of pages |
| folderId | string | Folder the document belongs to (always None in local mode) |
Display creation time in your timezone
To display createdAt in the user’s timezone:
from datetime import datetime, timezone
datetime.fromisoformat(meta["createdAt"]).replace(tzinfo=timezone.utc).astimezone()Read a block (cloud)
One layout block with its bounding box — the block behind a block="…" citation. Cloud documents indexed since September 13, 2026 carry blocks; a document without them returns 404 here until it is re-indexed.
block = client.get_block(doc_id, "p3_text_5")Example Response
{
"doc_id": "pi-abc123def456",
"page": 3,
"block_id": "p3_text_5",
"bbox": [78, 24, 293, 44],
"block_type": "text",
"text": "..."
}bbox is [x0, y0, x1, y1] in thousandths of the page’s width and height, origin top-left.
Manage documents
List
Paginated list of indexed documents, newest first.
Returns: an object with documents (array of document metadata), total, limit, and offset.
Each document includes id, name, description, status, createdAt, pageNum, folderId, metadata, features, and path (the folder chain as "Parent/Child", or null when the document is unfiled or in local mode).
result = client.list_documents(limit=10)For the next page, pass offset=10:
result = client.list_documents(limit=10, offset=10)list_documents() parameters
list_documents() parameters| Name | Type | Description | Default |
|---|---|---|---|
| limit | int | Maximum documents to return (1–10,000) | 50 |
| offset | int | Number of documents to skip | 0 |
| folder_id | string | Cloud-only — filter by folder | None |
| recursive | bool | Cloud-only — also include documents in that folder’s subfolders, flattened into one list | False |
Metadata (cloud)
Your own JSON-serializable tags for the document, returned in get_tree responses and list_documents entries. In PageIndex Cloud, metadata could be used for document-level search in the PageIndex File System .
doc_id = client.submit_document(
"./report.pdf", wait=True, metadata={"source": "web", "year": 2024}
)["doc_id"]
client.get_tree(doc_id)["metadata"]
# {'source': 'web', 'year': 2024}Metadata rules
- Flat dict of
str,int,float, orboolvalues — no nested objects or lists. - Keys match
^[a-zA-Z][a-zA-Z0-9_]*$. - Serialized size is at most 8 KB.
- If the workspace has a metadata schema, every key must be declared in it with a matching type.
Folders (cloud)
Organize documents into folders and nested subfolders. Folders created without a parent and documents uploaded without a folder are placed at the root.
Create
result = client.create_folder("Research Papers", description="2024 research collection")
folder_id = result["folder"]["id"]With no parent_folder_id, the folder is created at the root — that is why the
response below has "parent_folder_id": null.
With Parent Folder (nested)
result = client.create_folder("Q1 Reports", parent_folder_id="my-folder-id")Example Response
{
"folder": {
"id": "my-folder-id",
"name": "Research Papers",
"description": "2024 research collection",
"parent_folder_id": null,
"created_at": "2024-06-15 10:30:00",
"file_count": 0,
"children_count": 0
}
}create_folder() parameters
create_folder() parameters| Name | Type | Required | Description | Default |
|---|---|---|---|---|
| name | string | yes | Folder name | - |
| description | string | no | Folder description | None |
| parent_folder_id | string | no | Parent folder ID for nesting. Omit to create at the root. | None |