> ## 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.read

> Read the text of one section or one page range of a document, with its citation.

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

```typescript TypeScript theme={null}
await sdk.documents.read(options: ReadOptions)  // exactly one of section_key and pages
```

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 one options object; every option is accepted in snake\_case or camelCase (`customer_id` or `customerId`). The result is returned as the server sends it, with snake\_case fields, typed as `Record<string, unknown>`.

Read the document itself, not a ranked excerpt: one section by its `section_key`, or a range of pages. Use it to check what a cited section says, or to read around a passage that `context.fetch` returned. The call always reads the current version.

> [!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; a refused call is not charged.

### Parameters

Address the document one way: pass **either** `document_key` **or** `document_id`. Then pass **exactly one** of `section_key` or `pages`.

**document\_key** `string`

The document's address, from 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.

**section\_key** `string`

A `section_key` from [`documents.index`](https://docs.maximem.ai/sdk-reference/documents/document-index).

**pages** `string | tuple[int, int]`

A page range, `"3-5"` or `(3, 5)` (`[3, 5]` in TypeScript): whole page numbers from 1, with the end not before the start. A read returns at most 20 pages.

**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

**text** `string`

The text of the section or pages.

**token\_count** `integer`

The size of `text` in tokens.

**citation** `dict`

Where the text came from: `document_key`, `document_id`, `version`, `section_key` and `section_path` (for a section read), `page` and `page_end`, `url` and `anchor` when the source has a link, and `added_at`. `source_disconnected` is true when the document came from a connected source that has since been disconnected.

The result also repeats `document_key` and `version`, and carries `section_key` or `pages` as you asked.

### 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")
section = tree["sections"][3]["section_key"]

part = await sdk.documents.read(document_key, section_key=section, customer_id="acme-corp")
print(part["text"], part["citation"]["page"])

pages = await sdk.documents.read(document_key, pages="3-5", customer_id="acme-corp")
```

```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' });
const sections = tree.sections as Array<Record<string, unknown>>;

const part = await sdk.documents.read({
  document_key: documentKey,
  section_key: sections[3].section_key as string,
  customer_id: 'acme-corp',
});
console.log(part.text, (part.citation as Record<string, unknown>).page);

const pages = await sdk.documents.read({ document_key: documentKey, pages: '3-5', customer_id: 'acme-corp' });
```

### Raises

* `InvalidInputError`: when you pass both or neither of `section_key` and `pages`, `pages` is malformed, or the request is too large (more than 20 pages, or more text than one call returns; ask for a smaller section or range). Also when the page range holds no text, for example past the last page. Check `code` (`serverCode` in TypeScript), `read_too_large` or `invalid_read_request`, to tell them apart. None of these is charged.
* `ContextNotFoundError`: when the document or section does not exist or you cannot see it; these look the same on purpose. With `code == "document_not_ready"` (`serverCode` in TypeScript) the document is still being processed: try again shortly. Also when the feature is not enabled on your instance.
* `FeatureNotInPlanError`: when your plan does not include document navigation.
* `CustomerIdNotAcceptedError`: when `customer_id` is passed on a B2C instance.

### See also

* [documents.index](https://docs.maximem.ai/sdk-reference/documents/document-index.md)
* [documents.original](https://docs.maximem.ai/sdk-reference/documents/original.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.