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

> What a document is in Synap: the files and text you can send, how a document is identified, how re-uploads become versions, what provenance you can attach, who can read it, and how deletion works.

A conversation tells Synap what someone said. A **document** is reference material your agent should be able to look up and quote: a policy, a contract, a help article, an invoice, a report, a ticket. Synap keeps the original file, makes its text searchable, reads it for its main points and the people, organizations and things it mentions, and returns passages from it in a context fetch next to your conversation memories, each with a [citation](https://docs.maximem.ai/concepts/citations.md) that says where it came from.

You send a document with [`memories.create`](https://docs.maximem.ai/sdk-reference/memories/create), the same call you use for conversations. What changes is what you pass: a file, or text with a document type.

> [!NOTE]
>
> Documents are on for every Instance on Synap Cloud. Knowledge queries and document navigation (`documents.index` and `documents.read`) need the Pro plan or above.

## Send a document

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

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

result = await sdk.memories.create(
    document=FilePart(path="contracts/acme-msa.pdf"),
    document_id="acme-msa",
    document_type="contract",
    objective="record",
    customer_id="acme",
    source={"system": "contracts-portal", "url": "https://contracts.example.com/acme-msa"},
)

print(result.document_key, result.version, result.processing_stage)
```

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

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

const result = await sdk.memories.create({
  document: filePart({ path: 'contracts/acme-msa.pdf' }),
  document_id: 'acme-msa',
  objective: 'record',
  customer_id: 'acme',
});

console.log(result.document_key, result.version, result.processing_stage);
```

The call returns as soon as Synap has accepted the file. Processing continues in the background; see [how a document is processed](https://docs.maximem.ai/concepts/how-ingestion-works.md#documents).

## What you can send

| You send | Notes |
| - | - |
| A file | PDF, Word (`.docx`), Excel (`.xlsx`), PowerPoint (`.pptx`), plain text, Markdown, CSV, HTML, JSON, PNG, JPEG or WebP. Caption files (`.vtt`, `.srt`) are read as call transcripts. |
| A JSON Lines file | `.jsonl` or `.ndjson`. An export with one record per line becomes one document per record. See [JSON Lines](#json-lines). |
| A file by URL | `FilePart(url=...)`. Your process fetches it; Synap never fetches a URL you give it. |
| Text | `document` as a string with a `document_type` other than a conversation type. Text with no type is a conversation, as it always was. Pass `document_format` (`text`, `markdown`, `html`, `csv` or `json`) when the format cannot be seen from the text. |

Each file can be up to 10 MB, and one call takes up to 10 files. A file over the limit is refused. Each file in a call becomes its own document.

## Document type

Say what the document is, or leave it out and Synap detects it from the file.

| Type | For |
| - | - |
| `knowledge-article` | Help articles, FAQs, product docs, wikis |
| `policy` | Policies, handbooks, standard procedures |
| `contract` | Agreements, NDAs, leases |
| `financial-record` | Invoices, receipts, statements |
| `report` | Reports, analyses, decks |
| `ticket` | Support or issue tickets |
| `profile-record` | CRM or HR records, resumes, identity documents |
| `document` | Anything else; Synap works out the type |

Free text such as `"employee handbook"` is matched to the closest type. Conversation types (`call-transcript`, `team-chat` and the rest) are processed as conversations, even when sent as a file. Type affects how the document is split up, how deeply it is read (see [How deeply a document is read](#how-deeply-a-document-is-read)), and whether older versions stay searchable: by default policies and contracts keep their history, so a fetch can ask what applied on a given date. The full list is on [`memories.create`](https://docs.maximem.ai/sdk-reference/memories/create).

## Objective

`objective` says what you are sending the document for.

| Value | Use it for |
| - | - |
| `knowledge-base` | Reference material to be searched and quoted |
| `record` | A formal record: a contract, an invoice, a policy |
| `bootstrap` | Seeding an Instance with context before any conversation |
| `profile` | Stable facts about a user, customer or the client |
| `conversation` | What was said, and what it reveals |

Synap stores the objective with the document and uses it as a hint when it reads the file. It never changes who can see the document.

## How a document is identified

Every document gets a `document_key` when it is accepted. It is stable across versions and is what you pass to the [`documents`](https://docs.maximem.ai/sdk-reference/documents/get) methods and what a citation carries. Synap decides which document a call refers to in this order:

1. The `document_id` you passed. It is unique within a scope, not across your whole account.
2. The source item, when you pass `source` with both `system` and `external_id`.
3. The file's content, when you pass neither.

> [!WARNING]
>
> Pass a `document_id` for anything you will update. Without one, a document is identified by its exact content, so an edited file is a new, separate document, not a new version.

## Versions and re-uploads

Send a file again with the same `document_id`, in the same scope, and it becomes a new version of the same document.

* **Identical file:** nothing new is created or processed. The response says `version_status: "unchanged"`.
* **Changed file:** a new version is created. The create response says `pending`; the final status (`new_version`, `unchanged` or `stale`) is on [`documents.versions`](https://docs.maximem.ai/sdk-reference/documents/versions) once Synap has read the file. A version whose text turns out identical to the current one is `unchanged`; one that is older than the current version by the source's own clock (its revision or modified time) is `stale` and never becomes current.
* **Readers see one version at a time.** The previous version stays current until the new one is [searchable](https://docs.maximem.ai/concepts/how-ingestion-works.md#documents), then the new one takes over. A fetch reads the current version. For types that keep history, `as_of` reads the version that applied on a date.
* **Every version keeps its original file.** [`documents.original`](https://docs.maximem.ai/sdk-reference/documents/original) returns the file of any version.

## JSON Lines

Exports from other memory and knowledge tools usually ship one record per line. Send the file as a `FilePart` named `.jsonl` or `.ndjson` (or with a JSON Lines media type) and each record becomes its own document, so it can be found, cited, versioned and deleted on its own.

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

result = await sdk.memories.create(
    document=FilePart(path="exports/notes.jsonl"),
    document_id="notes-export",
    customer_id="acme",
)

for attachment in result.attachments or []:
    print(attachment.document_id, attachment.version_status)
```

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

const result = await sdk.memories.create({
  document: filePart({ path: 'exports/notes.jsonl' }),
  document_id: 'notes-export',
  customer_id: 'acme',
});

// The attachment type lists filename, media_type, status and error; the
// document fields below are on the object but not in the type.
for (const attachment of result.attachments ?? []) {
  const { document_id, version_status } = attachment as Record<string, unknown>;
  console.log(document_id, version_status);
}
```

Nothing is declared by you; Synap reads each line and picks the first field it finds, in this order:

| Of the record | Synap uses | Order |
| - | - | - |
| Text | The document's text | `content`, `text`, `body`, `markdown`, `page_content` (a string wins; an object or list there is kept as JSON) |
| Id | The document's `document_id` | `id`; then `source.id`, written `source.type:source.id` when the source has a type; then `_id`, `uuid`, `external_id`, `document_id` |
| Title | The document's title | `title`, at the top level or inside `metadata`; then `name` |
| Date | The document's date | `created_at`, `occurred_at`, `occurredAt`, `timestamp`, at the top level or inside `metadata`: an ISO 8601 string or a Unix time in seconds |

How it behaves:

* **Ids.** When the call or the `FilePart` has a `document_id`, each record's id is that id, a slash, then the record's id, for example `notes-export/notion:8812`. A record with no id is identified by its content. A date that cannot be read is left unset.
* **Versions.** Upload the export again and each record is matched by its id: a changed record is a new version, an identical one is `unchanged`. See [Versions and re-uploads](#versions-and-re-uploads).
* **Type.** A `document_type` you declare applies to every record.
* **Datasets stay whole.** When the first line has no text field, the file is not a record export and stays one document, read as JSON text.
* **Empty records.** A line whose text is empty is skipped.
* **Bad input refuses everything.** A line that is not JSON, not an object, or has no text field refuses the whole request with `UnsupportedFormatError` (HTTP 415), naming the line, and nothing is stored. The file must be UTF-8.
* **At most 1,000 documents per request.** A create, or a whole batch, that would produce more is refused with HTTP 413 (`FileTooLargeError`). Split the file by line and send the parts separately.
* **Originals.** [`documents.original`](https://docs.maximem.ai/sdk-reference/documents/original) returns that record's text, not the whole file.
* **One attachment per document.** The result's `attachments` lists one entry per document, in line order, each with its own `document_key`, `document_id` and `version_status`. The top-level fields of the result describe the first document only.

In [`memories.batch_create`](https://docs.maximem.ai/sdk-reference/memories/batch-create), a refused JSON Lines item fails on its own and the other items go ahead.

> [!NOTE]
>
> The TypeScript SDK sends a `.jsonl` file as it would any file, with no media type of its own for it, and the server recognises it by its extension, so keep the extension, or pass `media_type: 'application/x-ndjson'`.

## How deeply a document is read

Every document is read for its main points, key fields, dates and the entities it mentions. What differs by type is whether Synap also extracts individual memories from it at upload.

| Types | Read at upload |
| - | - |
| `contract`, `financial-record`, `ticket`, `profile-record` | In detail: obligations, deadlines, amounts and other specifics are extracted into memories, so a fetch can answer from them without reading the document. |
| Every other document type | Lightly: no memories are extracted at upload. The document is still searchable and citable. (Conversation types are read as conversations.) |

Reading in detail costs more credits, and the estimate shown before a document is stored includes it. You can change the default for a type in these ways, from lowest to highest priority:

1. **A read frequency you state.** `utility={"read_frequency": "frequent"}` (`utility: { read_frequency: 'frequent' }` in TypeScript), or `"constant"`, on a document that does not change often raises it to detailed. A frequency Synap only infers does not.
2. **Your instance's settings.** The document settings Synap generates for your instance (see [Configuring memory](https://docs.maximem.ai/guides/configuring-memory.md#how-deeply-each-type-is-read)) can set the depth per type: none, light or detailed. You review them before they take effect.
3. **A per-call plan.** `plan={"extraction": "detailed"}` on [`memories.create`](https://docs.maximem.ai/sdk-reference/memories/create) (`plan: { extraction: 'detailed' }` in TypeScript) overrides everything above for that call.

A change reaches documents and versions uploaded after it. Documents already stored are not re-read.

## Provenance

`source` records where the document came from. Every field is optional.

| Field | What it does |
| - | - |
| `system` | The system it came from, for example `contracts-portal`. |
| `external_id` | Its id there. With `system`, this identifies the document when you pass no `document_id`. |
| `url` | A link to the source. A citation uses it as its link when the document is visible to the reader. |
| `container` | The folder, space or channel it lives in. |
| `fetched_at` | When you copied it. |
| `source_revision`, `source_modified_at` | The source's own clock. Synap uses these to order versions, so a late-arriving old revision does not replace a newer one. |

`document_created_at` sets the document's own date, and is used to label passages when no better date exists. For a file that is a conversation, `participants` maps each speaker label to a `user_id`, a `customer_id` or a role. [`documents.get`](https://docs.maximem.ai/sdk-reference/documents/get) returns the source and the document date.

## Who can read a document

A document is filed at the level your ids name, as memories are:

| You pass | The document is visible to |
| - | - |
| `user_id` and `customer_id` | That user only |
| `customer_id` only | Everyone under that customer |
| Neither | Everyone in your client |

`scope` names a deeper level of your [scope ladder](https://docs.maximem.ai/concepts/scope-ladder.md). A user's fetch reads that user's documents, their customer's and the client-wide ones; a customer's fetch reads the customer's and the client-wide ones. See [Identifiers and scopes](https://docs.maximem.ai/concepts/memory-scopes.md). On a B2C Instance, pass `user_id` alone.

A document belongs to the Instance it was sent to. Instances under the same client read each other's documents by default; an [Instance visibility](https://docs.maximem.ai/guides/instance-visibility.md) policy limits that. A reader who is not allowed to see the document gets neither it nor a way to open its original.

## Delete and restore

`documents.delete` hides a document at once: every version, and the memories that came only from it. It stays restorable until the end of the Instance's deletion period, the same period memories use (0 to 30 days), after which it is purged from every store. `documents.restore` undoes a delete before then. It fails if a newer document has taken the same `document_id`, or once the period has passed. `permanent=True` (`permanent: true` in TypeScript) removes the document immediately with no undo and needs a management-level key. Both calls need a key that is allowed to delete data.

```python Python theme={null}
await sdk.documents.delete(document_id="acme-msa", customer_id="acme")
await sdk.documents.restore(document_id="acme-msa", customer_id="acme")
```

```typescript TypeScript theme={null}
await sdk.documents.delete({ document_id: 'acme-msa', customer_id: 'acme' });
await sdk.documents.restore({ document_id: 'acme-msa', customer_id: 'acme' });
```

The documents namespace is Python 0.9.0 and later and JavaScript 0.9.0 and later: see [`documents.delete`](https://docs.maximem.ai/sdk-reference/documents/delete) and [`documents.restore`](https://docs.maximem.ai/sdk-reference/documents/restore). The soft-delete model is the one described on [`memories.delete`](https://docs.maximem.ai/sdk-reference/memories/delete) and [`data.restore`](https://docs.maximem.ai/sdk-reference/data/restore).

## Next steps

> [card] [Citations](https://docs.maximem.ai/concepts/citations.md)
>
> What each fetch result carries, and how to open the source.

> [card] [How ingestion works](https://docs.maximem.ai/concepts/how-ingestion-works.md#documents)
>
> When a document becomes searchable and when it is fully processed.

> [card] [Retrieval modes](https://docs.maximem.ai/concepts/retrieval-modes.md#documents-in-a-fetch)
>
> How documents take part in a fetch.

> [card] [Query and navigate documents](https://docs.maximem.ai/guides/agent-query-and-navigation)
>
> Let an agent list and read documents, not just fetch.


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