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

# Delete Data by Scope

> Delete the data Synap holds for one user, one conversation or one customer, from your own code. Which key each scope needs, how to preview with dry_run, what the statuses mean, and what is not deleted.

> [!WARNING]
>
> **Memories are restorable for a period, then purged.** A delete hides the memories from every read at once. Until `purge_after`, the end of the instance's deletion period (0 to 30 days, 30 by default), [`data.restore`](https://docs.maximem.ai/sdk-reference/data/restore) brings them back; after it they are purged for good. Conversations, the profile and source text are removed at once and are not restorable. `permanent=True` (management-level key) removes the memories at once too, with no undo. Run it with `dry_run=True` first and read the counts.

## The deletion period

Each instance has a deletion period, 0 to 30 days, 30 by default. Set it when you create the instance, or change it in the dashboard or with the CLI (`maximem-synap instances update <id> --deletion-period-days 7`, which needs `update:instances`). A runtime key cannot change it, and every change is audited. The period in force when a memory is deleted is fixed on that memory, so a later change never shortens a restore window that is already running. Forget requests by a user get the same period and have no permanent option.

## What it does

You ask Synap to delete the data it holds about one thing, and you name that thing:

* **One user:** their memories, conversations with their turns and summaries, profile, and the search and graph entries built from them.
* **One conversation:** that conversation's turns and summaries only. Memories learned from it are kept.
* **One customer (B2B):** the customer's stored data, including every user under it.

You call it from code with the Synap API key you already use. It works like any other SDK method, with `scope` as a parameter. It needs Python SDK `maximem-synap` 0.6.9 or newer, or JS SDK `@maximem/synap-js-sdk` 0.6.5 or newer.

## The three scopes and the key each needs

| Scope | You send | Key that may call it |
| - | - | - |
| `user` | `user_id` (B2B: also `customer_id`) | A normal runtime key (`sdk:default`) |
| `conversation` | `conversation_id` and `user_id` (B2B: also `customer_id`) | A normal runtime key (`sdk:default`) |
| `customer` | `customer_id` | A management key only (`management:*` or `*`). A runtime key is refused with 403. |

* A B2C instance has no customer scope: `scope="customer"` is refused there. Use `scope="user"`.
* On B2B, `customer_id` is required for all three scopes. On B2C it is not accepted.
* Deleting a whole client is not supported through this call.
* Onboarding keys and read-only keys cannot delete.

> [!NOTE]
>
> The `scope` here is a plain string. It is not the rung-path dict that `memories.create` and the fetch methods take as `scope`; a dict is rejected.

## Preview first, then delete

A delete takes two steps so that what you remove is what you meant to remove.

**1. Preview with dry\_run**

`dry_run=True` counts what would be removed and changes nothing. It needs no `confirm`.

**2. Delete with confirm**

For a real delete, `confirm` is required and must equal the id being deleted: `user_id` for `"user"`, `conversation_id` for `"conversation"`, `customer_id` for `"customer"`. A mismatch is rejected before anything is changed.

`confirm` guards against typos. It does not replace key security: anyone holding a runtime key can delete any user or conversation in that key's instance, so keep keys secret and rotate a leaked one at once.

## Python

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

async def main():
    sdk = MaximemSynapSDK()
    await sdk.initialize()
    try:
        # 1. See what would go. Nothing changes.
        preview = await sdk.data.delete(scope="user", user_id="user-123", dry_run=True)
        print(preview.counts)

        # 2. Delete. B2B: also pass customer_id="acme".
        result = await sdk.data.delete(
            scope="user",
            user_id="user-123",
            confirm="user-123",
        )

        # 3. Check the result before telling anyone their data is gone.
        if result.fully_removed:
            print("Deleted:", result.counts)
        else:
            print("Status:", result.status, "still present in:", result.still_present_in)
    finally:
        await sdk.shutdown()

asyncio.run(main())
```

The full signature:

```python theme={null}
await sdk.data.delete(
    scope,                    # "user" | "conversation" | "customer"
    user_id=None,
    customer_id=None,
    conversation_id=None,
    dry_run=False,
    confirm=None,             # required unless dry_run
    wait=True,
) -> DeleteDataResult

await sdk.data.status(deletion_id) -> DeleteDataResult
```

## TypeScript

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

const sdk = new SynapClient();
await sdk.initialize();
try {
  // 1. See what would go. Nothing changes.
  const preview = await sdk.data.delete({ scope: 'user', userId: 'user-123', dryRun: true });
  console.log(preview.counts);

  // 2. Delete. B2B: also pass customerId: 'acme'.
  const result = await sdk.data.delete({
    scope: 'user',
    userId: 'user-123',
    confirm: 'user-123',
  });

  // 3. Check the result before telling anyone their data is gone.
  if (result.fully_removed) {
    console.log('Deleted:', result.counts);
  } else {
    console.log('Status:', result.status, 'still present in:', result.still_present_in);
  }
} finally {
  await sdk.shutdown();
}
```

The options are `scope`, `userId`, `customerId`, `conversationId`, `dryRun`, `confirm` and `wait`. Result fields keep the server's names (`fully_removed`, `still_present_in`, `deletion_id`).

## Large deletes: `wait`

A large delete is done in capped steps. With `wait=True` (the default) the SDK repeats the call while the server says `continue`, up to 50 calls. With `wait=False` it returns after one call and you call again with the same arguments. Repeating the same request is safe.

## Statuses

| `status` | Meaning |
| - | - |
| `dry_run` | A preview. Nothing was changed. |
| `pending_purge` | Done, the default. The memories are hidden from every read and restorable with `data.restore(deletion_id=...)` until `purge_after`, then purged. `fully_removed` is false until then. |
| `complete` | Done, with nothing left to purge: a permanent delete, or `scope="conversation"` (which keeps memories). If `found` is false, nothing existed for that id; the call still succeeds. |
| `partial` | Part of the data was deleted, and `still_present_in` names what remains. |
| `in_progress` | The size cap stopped the call (`continue` is true). Call again with the same arguments, or use `wait=True`. |

**Partial is a result, not an error.** No exception is raised. Read `fully_removed` and `still_present_in`, and do not tell an end user their data is gone unless `fully_removed` is true. A partial result lists what remains, and you can run the same delete again.

### Why a store is skipped

A store that cannot be cleared safely is skipped, named in `still_present_in`, and `stores` gives the reason:

| Reason in `stores` | What happened |
| - | - |
| `skipped: shared_with_other_instance` | A delete only removes data in your key's instance. A few stores (the profile, graph entities, and protected values written without an instance) cannot be scoped by instance. If the same user or customer also has data in another instance of your client, those stores are skipped. Delete from the other instance too, or contact support. |
| `skipped: shared_with_other_customer` | On B2B, the same user id also has data under another customer, so the shared graph entries and identity row are left alone. Only the customer you named loses its rows. |
| `skipped: provider_unavailable` | The search index or graph could not be reached. |
| `skipped: redis_unavailable` | The turn buffer or cache could not be reached. |
| `rows_may_remain: no_tenant_column` | Memory-fetch records (`fetch outcomes`) keep the user id and conversation id for 30 days and cannot yet be tied to one customer, so the delete does not remove them. If any exist for the user, the result is `partial` with `fetch outcomes` in `still_present_in`. They expire on their own after 30 days. |

If something was written for the target while the delete ran, the response says `may_have_new_data` and the status is `partial`. Stop writing for that person first, delete, then delete again.

## Audit record

Every real delete leaves a record with its status, counts and `still_present_in`. It holds no content and no raw user, customer or conversation ids. Read it with `data.status`:

```python theme={null}
record = await sdk.data.status(result.deletion_id)
```

```typescript theme={null}
const record = await sdk.data.status(result.deletion_id);
```

`data.status` is instance-bound: it returns records of your key's instance only. Dry runs write no record.

## What is not deleted

Kept on every scope:

* Memory-fetch records (the hit rate of anticipation) for up to 30 days. A delete for a user whose records still exist reports `partial` with `fetch outcomes`.
* Working tables of entity resolution and review (names and context text kept for matching, consolidation runs, held mentions and the quarantine for sensitive values). This call does not remove them yet. Contact support if you need them removed.
* Billing and usage counters (ids and amounts, no content).
* The content-free audit record of the delete itself.
* The identity mapping from your external id to Synap's internal id, with names, descriptions and context on it blanked.
* Request logs that carry no user or customer id. They expire on their own.
* Client-wide knowledge, and other customers' data.
* Source text that another memory still rests on.
* Backups taken before the delete, until they expire.
* Anything still queued for extraction when you call delete can land afterwards. Stop writing first, delete, then delete again.

The SDK also clears its own cached copies on the machine it runs on (`local_cleared`). Files your own app keeps are yours to remove.

## It is instance-bound

A key can only delete inside its own instance and client. A runtime key cannot reach another instance, another client or (without a management key) a whole customer. If the same user lives in two of your instances, delete from each.

Limits per key: 10 delete calls per minute and 100 per hour, plus 60 dry runs per minute. Over a limit you get 429; wait and repeat the same call. A delete works even when your credit balance is empty.

## How it differs from `memories.delete`

| | `data.delete` | [`memories.delete`](https://docs.maximem.ai/sdk-reference/memories/delete) |
| - | - | - |
| Removes | A user's, a conversation's or a customer's stored data | One memory, by its id |
| Needs | A scope id and `confirm` | The memory id |
| Result | Counts per store, `status`, `still_present_in` | A confirmation |
| Preview | `dry_run=True` | None |

`memories.delete` follows the same rule: hidden at once, restorable until `purge_after`, then purged; `permanent=True` removes it now. To remove what was learned from one conversation, delete the user or the individual memories, because `scope="conversation"` keeps them.

## Errors

* `InvalidInputError`: bad arguments, caught before any request, or HTTP 400 (for example `scope="customer"` on B2C).
* `AuthenticationError`: HTTP 401, or 403 when the key is not allowed to delete, or belongs to another instance.
* `ConflictError`: HTTP 409, when the id belongs to a different customer, or the same delete is already running.
* `RateLimitError`: HTTP 429.

## See also

* [`data.delete` reference](https://docs.maximem.ai/sdk-reference/data/delete)
* [memories.delete](https://docs.maximem.ai/sdk-reference/memories/delete.md)
* [Erasing a person](https://docs.maximem.ai/guides/erasure.md)
* [Instance visibility](https://docs.maximem.ai/guides/instance-visibility.md)


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