> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Maximem Synap is a managed memory layer for AI agents: it ingests conversations and documents, extracts structured memory, and returns scoped context to the agent at retrieval time.
> The Python and JavaScript/TypeScript SDKs are the supported way to use Synap. Write integration code with SDK calls, not raw HTTP requests.
> Start with the Quickstart: https://docs.maximem.ai/getting-started/quickstart.md. Every SDK method is documented in the SDK reference: https://docs.maximem.ai/sdk-reference/overview.md.
> For requests about adding Vity memory to OpenClaw, Hermes, an MCP client, or a browser, start with the Vity Quickstart: https://docs.maximem.ai/vity/quickstart.md.

# documents.index

> Open a document's outline: title, summary and the section tree with page ranges.

```python Python theme={null}
await sdk.documents.index(document_key=None, version=None, document_id=None, user_id=None, customer_id=None, scope=None)
```

```typescript TypeScript theme={null}
await sdk.documents.index(address: string | IndexOptions)  // a string is the document_key
```

REST One HTTPS request, or two when you address the document by `document_id`.

> [!NOTE]
>
> Added in Python SDK 0.9.0 and JavaScript and TypeScript SDK 0.9.0. In TypeScript, pass the `document_key` as a string, or an options object; every option is accepted in snake\_case or camelCase (`documentId` or `document_id`). The result is returned as the server sends it, with snake\_case fields, typed as `Record<string, unknown>`.

Open a document's outline before you read it. You get its title, a summary and the tree of sections, each with a `section_key`, heading and page range, so an agent can decide what to read and then call [`documents.read`](https://docs.maximem.ai/sdk-reference/documents/read) with a `section_key`. It is also how you check what a citation points at.

> [!WARNING]
>
> Enabled per instance, and needs a Pro plan or above. Where it is not enabled the call raises `ContextNotFoundError`, the same error as for a document that does not exist. A plan without it raises `FeatureNotInPlanError`. Each successful call uses credits.

### Parameters

Address the document one way: pass **either** `document_key` **or** `document_id`.

**document\_key** `string`

The document's address, from `memories.create`, a citation, or a [`knowledge.query`](https://docs.maximem.ai/sdk-reference/knowledge/query) result.

**document\_id** `string`

The id you gave the document at creation, with the scope it was created in.

**version** `integer`

Open the outline of this version instead of the current one. List versions with [`documents.versions`](https://docs.maximem.ai/sdk-reference/documents/versions).

**user\_id** `string`

The user you read the document as. Pass the same `user_id`, `customer_id` and `scope` you use with `context.fetch`, also when you hold a `document_key`.

**customer\_id** `string`

The customer you read the document as. A customer's document opens only for a call that names that customer. Not accepted on B2C.

**scope** `dict[str, str]`

The deeper scope level you read at, as level name to id.

### Returns

**title** `string`

The document's title.

**summary** `string | None`

A short summary of the whole document. Left out while any part of the document has been removed by a forget request.

**page\_count** `integer | None`

The number of pages, when the document has pages.

**sections** `list[dict]`

The sections in reading order. Each has `section_key` (what you pass to `read`), `heading`, `level`, `parent_key` (the enclosing section), `section_path` (the headings from the top down), `page_start`, `page_end` and a one-line `summary`. Empty while the document is still being processed. Sections removed by a forget request are not listed.

The result also repeats `document_key`, `document_id`, `version`, `is_current`, `document_type` and `processing_stage`.

### Example

```python Python theme={null}
from maximem_synap import MaximemSynapSDK

sdk = MaximemSynapSDK()  # reads SYNAP_API_KEY from your environment
await sdk.initialize()

tree = await sdk.documents.index(document_key, customer_id="acme-corp")
print(tree["title"], tree["page_count"])
for s in tree["sections"]:
    print("  " * (s["level"] or 0), s["heading"], s["page_start"], s["section_key"])
```

```typescript TypeScript theme={null}
import { SynapClient } from '@maximem/synap-js-sdk';

const sdk = new SynapClient(); // reads SYNAP_API_KEY from your environment
await sdk.initialize();

const tree = await sdk.documents.index({ document_key: documentKey, customer_id: 'acme-corp' });
console.log(tree.title, tree.page_count);
for (const s of tree.sections as Array<Record<string, unknown>>) {
  console.log('  '.repeat((s.level as number) ?? 0), s.heading, s.page_start, s.section_key);
}
```

### Raises

* `ContextNotFoundError`: when the document does not exist or you cannot see it (another customer's or user's, outside your instance's visibility, or deleted); these look the same on purpose. Also when the feature is not enabled on your instance.
* `FeatureNotInPlanError`: when your plan does not include document navigation.
* `InvalidInputError`: when `version` is not a positive integer, or you pass both or neither of `document_key` and `document_id`.
* `CustomerIdNotAcceptedError`: when `customer_id` is passed on a B2C instance.

### See also

* [documents.read](https://docs.maximem.ai/sdk-reference/documents/read.md)
* [Query and navigate documents as an agent](https://docs.maximem.ai/guides/agent-query-and-navigation)


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