Skip to Content
Introducing PageIndex Flash
Python SDKDocument

PageIndex Document Processing

Index documents, read their content, and organize your library using your configured client.

  1. Index a document — upload a file and get its doc_id.
  2. Read a document — check status, retrieve the tree, or read pages.
  3. Manage documents — list or delete documents.
  4. Metadata (cloud) — attach your own tags.
  5. 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 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

NameTypeRequiredDescriptionDefault
file_pathstringyesLocal path to the file. Cloud accepts PDF, PPTX, and Word; local mode accepts PDF only.-
modestringnoProcessing mode. Local uses Flash indexing. Cloud modes are passed through (e.g. "mcp").None
metadatadictnoYour own tags on the document — see Metadata.None
waitbooleannoReturn only once the document is ready. Cloud: polls until "completed". Local: indexing is already synchronous.False
folder_idstringnoCloud-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 too

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

meta = client.get_document(doc_id) print(f"{meta['name']}: {meta['status']}, {meta['pageNum']} pages")

get_document() response fields

FieldTypeDescription
idstringDocument ID
namestringDocument filename
descriptionstringDocument description (if available)
statusstring"queued", "processing", "completed", or "failed"
createdAtstringCreation timestamp, UTC with no timezone marker
pageNumintNumber of pages
folderIdstringFolder 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

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

NameTypeDescriptionDefault
limitintMaximum documents to return (1–10,000)50
offsetintNumber of documents to skip0
folder_idstringCloud-only — filter by folderNone
recursiveboolCloud-only — also include documents in that folder’s subfolders, flattened into one listFalse

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, or bool values — 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.

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

NameTypeRequiredDescriptionDefault
namestringyesFolder name-
descriptionstringnoFolder descriptionNone
parent_folder_idstringnoParent folder ID for nesting. Omit to create at the root.None
Last updated on