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

> Undo a soft delete of a document before its purge date.

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

```typescript TypeScript theme={null}
await sdk.documents.restore(address: string | DocumentAddress)  // 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>`.

Bring back a document you soft-deleted with [`documents.delete`](https://docs.maximem.ai/sdk-reference/documents/delete): its versions and the memories made from it are visible to reads again. A version that was still processing when it was deleted is processed again. A permanent delete cannot be restored.

### Parameters

Address the document one way: pass **either** `document_key` **or** `document_id`, as in [`documents.get`](https://docs.maximem.ai/sdk-reference/documents/get). A deleted document is no longer found by `document_id`, so keep the `document_key` that `delete` returned.

**document\_key** `string`

The document's address. Do not combine it with `user_id`, `customer_id` or `scope`.

**document\_id** `string`

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

**user\_id** `string`

With `document_id`: the user the document was filed under.

**customer\_id** `string`

With `document_id`: the customer the document was filed under. Not accepted on B2C.

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

With `document_id`: the deeper scope level the document was filed at.

### Returns

**document\_key** `string`

The document's address.

**status** `string`

`restored`.

**versions** `integer`

How many versions were restored.

**memories\_restored** `integer`

How many memories made from the document are visible again.

### Example

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

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

deleted = await sdk.documents.delete(document_id="msa-2026", customer_id="acme-corp")
restored = await sdk.documents.restore(deleted["document_key"])
print(restored["status"], restored["memories_restored"])
```

```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 deleted = await sdk.documents.delete({ document_id: 'msa-2026', customer_id: 'acme-corp' });
const restored = await sdk.documents.restore(deleted.document_key as string);
console.log(restored.status, restored.memories_restored);
```

### Raises

* `ContextNotFoundError`: when the document does not exist, belongs to another instance, or was purged after its purge date.
* `DocumentIdInUseError`: when a newer document now holds the same `document_id` in that scope, so this one cannot come back.
* `MissingScopeError`: when the key is not allowed to restore documents. Playground keys cannot.
* `InvalidInputError`: when you pass both or neither of `document_key` and `document_id`.

### See also

* [documents.delete](https://docs.maximem.ai/sdk-reference/documents/delete.md)
* [data.restore](https://docs.maximem.ai/sdk-reference/data/restore.md)


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