# Memory deletion

Choose the recoverable forget path or an explicitly authorized destructive mode with an auditable tombstone.

- Canonical: https://docs.xmemo.dev/docs/concepts/memory-deletion
- Locale: en-US
- Content-Locale: en-US
- Canonical-Content-Digest: 376e4e4ecb3e1fc0955b2cd5176a16a92431ecba87f15d1ded32d8ee3f15f1fd
- Edition-Digest: 804e44571a711b528653777065e7a4e8181a1b812056416414093c43503bf617
- Source-Revision: sha256:ae05ed5a78af519bbe1b86561e36ef07d4758d3bcae57a6df91b7e53e4f5cfff

## Soft deletion is the public default

DELETE /v1/memories/{memory_id} defaults to mode=soft_delete. POST /v1/memories/{memory_id}/forget accepts the same MemoryForgetRequest family with mode, reason, replacement_content, and metadata. A soft delete creates a tombstone and a version snapshot, changes the memory status to deleted, and can be followed by restore.

```http
DELETE /v1/memories/<memory-id>?mode=soft_delete&reason=user-requested
X-API-Key: <your-assigned-api-key>
```

## Forget, redact, and hard-delete are different modes

The persistence engine accepts soft_delete, redact, and hard_delete. Redact replaces content with [REDACTED] (or supplied replacement content), clears metadata and embeddings, and records safe redaction provenance. Hard delete is irreversible and is protected by the stronger memory:hard_delete authorization path; do not choose it as a routine correction.

- soft_delete — recoverable deletion with a tombstone and version snapshot.
- redact — retain a non-content tombstone/result while removing the original content and embedding.
- hard_delete — permanent removal path requiring the stronger delete capability.

## Restore only a soft-deleted memory

POST /v1/memories/{memory_id}/restore accepts MemoryRestoreRequest with an optional reason and metadata. The persistence path restores status=active and increments the version; a redacted memory cannot be restored because its original content is no longer available.

```http
POST /v1/memories/<memory-id>/restore
X-API-Key: <your-assigned-api-key>
Content-Type: application/json

{
  "reason": "owner-confirmed recovery"
}
```

## Deletion is authorized and audited

The REST mutation path checks the mode-specific memory scope and owner-scoped key before resolving the target. It writes memory tombstone/audit evidence with the requested mode, reason presence, and target references without exposing the forgotten content.

## ChatGPT user

Give ChatGPT durable access to your XMemo preferences, project facts, decisions, and TODOs without pasting bearer tokens into a chat.

Connect the hosted XMemo MCP server through the ChatGPT/OpenAI app OAuth flow, then approve the memory:read and memory:write grant for your XMemo account.

Save a synthetic preference or project note, start a new chat, then ask ChatGPT to recall it through XMemo before continuing work.

If OAuth fails or tools do not appear, sign out of the MCP server in the host app, reconnect the XMemo server URL, and retry before creating direct tokens.

## Copilot / Codex developer

Carry repo decisions, coding conventions, bug-fix notes, and task history between IDE and CLI agents.

Use OAuth for VS Code / GitHub Copilot and Gemini CLI when available. For Copilot CLI, Codex, Cursor, or other direct MCP clients, keep XMEMO_KEY in the local environment or secret store and set a stable XMEMO_AGENT_INSTANCE_ID.

Record a codebase decision or bug fix, then ask the next IDE or CLI agent to recall the relevant XMemo context before editing.

If recalls are empty, verify the selected MCP config path, the XMEMO_KEY environment variable for direct clients, and any stale OAuth credential in the host app.

## Team / enterprise pilot owner

Evaluate shared memory with account controls, source attribution, export/delete workflows, and reviewer-safe setup evidence.

Create or enter the protected XMemo workspace, invite approved users, then connect each client through OAuth or a scoped direct credential according to the readiness badges.

Have a pilot member save a synthetic team memory, confirm source attribution in XMemo, then review delete/export and support paths.

If a member cannot connect, check role permissions, OAuth approval, client readiness status, and support guidance before issuing a new token.

## Autonomous agent operator

Let headless or scheduled agents record progress, retrieve prior decisions, and keep a stable non-secret instance identity.

Fetch /api/v1/mcp/config/autonomous-agent. Prefer auth_modes.oauth when the runner supports OAuth + custom headers; use auth_modes.xmemo_key with XMEMO_KEY from a secret store only for fully headless runners.

Run one synthetic task that writes progress to XMemo, restart the runner, and confirm it recalls that progress using the same XMEMO_AGENT_INSTANCE_ID.

If attribution changes or recalls split across instances, persist XMEMO_AGENT_INSTANCE_ID outside git and verify the runner is not regenerating it on every start.
