---
title: "Clear all memories for a user+agent pair or a shared namespace"
description: "Permanently delete all memory data for one scope.\n\nUser-initiated deletion is a HARD delete: edges, entity nodes, and\nepisodic content are removed from both the graph database and the\nsearch overlay — nothing is retained. (System-side fact invalidation\nremains a soft ``expired_at``; that history powers contradiction\nresolution and is not user data retention.) The user path also\ninvalidates the context cache for the pair.\n\n``graph_id`` empties a shared namespace instead, service tokens only;\nthe response ``scope`` field names what was cleared."
---

> Documentation Index
> Fetch the complete documentation index at: https://truememory-docs.mvstg.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: AI Gateway API › Memory

`POST /memories/{agent_id}/clear`

Permanently delete all memory data for one scope.

User-initiated deletion is a HARD delete: edges, entity nodes, and
episodic content are removed from both the graph database and the
search overlay — nothing is retained. (System-side fact invalidation
remains a soft ``expired_at``; that history powers contradiction
resolution and is not user data retention.) The user path also
invalidates the context cache for the pair.

``graph_id`` empties a shared namespace instead, service tokens only;
the response ``scope`` field names what was cleared.

## Authentication

- `HTTPBearer`, http, header `Authorization`

## Path parameters

- `agent_id` (`clear_all_memories.path.agent_id`; string, required)

## Query parameters

- `graph_id` (`clear_all_memories.query.graph_id`; any of, optional) — Optional. Clear a shared namespace instead of the user's own memory. Requires a service token; the agent_id path segment is ignored.
  - any of: `string`, `null`

## Header parameters

- `X-On-Behalf-Of` (`clear_all_memories.header.X-On-Behalf-Of`; any of, optional)
  - any of: `string`, `null`
- `X-External-User-Id` (`clear_all_memories.header.X-External-User-Id`; any of, optional)
  - any of: `string`, `null`
- `X-App-Id` (`clear_all_memories.header.X-App-Id`; any of, optional)
  - any of: `string`, `null`

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://truememory-api.mvstg.com/memories/<agent_id>/clear' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://truememory-api.mvstg.com/memories/<agent_id>/clear';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://truememory-api.mvstg.com/memories/<agent_id>/clear"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
```

## Responses

### 200

Successful Response

#### Example

```json
{
  "status": "cleared",
  "scope": "user",
  "graph_id": "string",
  "deleted_count": 0,
  "expired_count": 0
}
```

- `scope` (`clear_all_memories.response.200.scope`; string, required)
  - one of `"user"`, `"graph"`
- `deleted_count` (`clear_all_memories.response.200.deleted_count`; integer, required)
- `expired_count` (`clear_all_memories.response.200.expired_count`; integer, required) — Same as deleted_count; kept for older clients.
- `status` (`clear_all_memories.response.200.status`; string, optional)
  - default `"cleared"`
- `graph_id` (`clear_all_memories.response.200.graph_id`; any of, optional) — Present only when scope is graph.
  - any of: `string`, `null`

### 422

Validation Error

#### Example

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

- `detail` (`clear_all_memories.response.422.detail`; array<object>, optional)
  - `loc` (`clear_all_memories.response.422.detail.loc`; array<any of>, required)
    - any of: `string`, `integer`
  - `msg` (`clear_all_memories.response.422.detail.msg`; string, required)
  - `type` (`clear_all_memories.response.422.detail.type`; string, required)
  - `input` (`clear_all_memories.response.422.detail.input`; unknown, optional)
  - `ctx` (`clear_all_memories.response.422.detail.ctx`; object, optional)


Source: https://truememory-docs.mvstg.com/api/memories/clear/index.md
