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

> Delete a document and everything Synap made from it. Restorable until its purge date unless you ask for a permanent delete.

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

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

Delete a document with every version and every memory Synap made from it. By default the delete is soft: the document and its memories disappear from every read at once, and you can bring them back with [`documents.restore`](https://docs.maximem.ai/sdk-reference/documents/restore) until the purge date, the end of the instance's deletion period. After that they are removed for good. With `permanent=True` (`permanent: true` in TypeScript) they are removed at once, with no restore.

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

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

**permanent** `boolean` (default: false)

Remove it now, with no restore period. Needs a management-level key. A key without it raises `MissingScopeError`.

### Returns

**document\_key** `string`

The document's address.

**status** `string`

`pending_purge` for a soft delete (hidden now, restorable until `purge_at`), or `deleted` for a permanent one.

**purge\_at** `datetime | None`

For a soft delete: when the document is removed for good. `None` (`null` in TypeScript) for a permanent delete.

**versions** `integer`

How many versions were deleted.

**memories\_hidden** `integer`

Soft delete: how many memories made from the document are now hidden. A permanent delete returns `memories_removed` instead.

**already\_deleted** `boolean`

Soft delete: true when the document was already deleted, so nothing changed.

### Example

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

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

result = await sdk.documents.delete(document_id="msa-2026", customer_id="acme-corp")
print(result["status"], result["purge_at"])   # pending_purge, and the date it is purged
```

```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 result = await sdk.documents.delete({ document_id: 'msa-2026', customer_id: 'acme-corp' });
console.log(result.status, result.purge_at); // pending_purge, and the date it is purged
```

> [!WARNING]
>
> A soft delete can be undone with [`documents.restore`](https://docs.maximem.ai/sdk-reference/documents/restore) until `purge_at`. A permanent delete cannot be undone.

### Raises

* `MissingScopeError`: when the key is not allowed to delete documents, or `permanent=True` without a management-level key. Playground keys cannot delete documents.
* `ContextNotFoundError`: when the document does not exist or belongs to another instance.
* `AmbiguousDocumentError`: when a `document_id` names more than one document in the scope you gave.
* `InvalidInputError`: when `permanent` is not a boolean, or you pass both or neither of `document_key` and `document_id`.

### See also

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


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