Core Operations

Delete Memory

Delete memories for a specified user or Agent. Supports precise deletion of individual memories, or deleting all memories for a user or Agent at once.

1. Choose a Deletion Method

MemOS Cloud currently supports the following three deletion methods. Choose one based on your scenario.

Deletion methodFieldUse case
Delete specific memoriesmemory_ids[]Delete one or more memories. The memory_id comes from the id field returned by search/memory or get/memory
Delete user memoriesuser_idClear all memories for a user in the current project
Delete Agent memoriesagent_idClear all memories for an Agent in the current project
Note
  • The three parameters are mutually exclusive. Only one deletion method can be used per call.
  • Deletion only applies within the project scope of the current API Key. Before deleting, make sure the API Key, project, and target memories belong to the same project.
  • Do not pass conversation_id, knowledgebase_id, or other IDs. Deletion by those dimensions is not supported.

2. Delete Specific Memories

Use specific-memory deletion when you need to remove a memory that was written incorrectly, is outdated, was assigned to the wrong user, or must be deleted at the user's request.


2.1 Find the Memory to Delete

When you call Search Memory or get memories and find a memory that should be deleted, copy the id of that memory. This value is the memory_id used for deletion.

{
  "memory_detail_list": [
    {
      "id": "e2a7c194-7062-4fa5-a6c0-bbe554d05d60",
      "memory_key": "User ice cream preference",
      "memory_value": "[user opinion] The user likes ice cream.",
      "memory_type": "WorkingMemory",
      "memory_time": null,
      "conversation_id": "0610",
      "status": "activated",
      "confidence": 0,
      "tags": [
        "food",
        "preference",
        "ice cream"
      ],
      "update_time": 1761315278665,
      "relativity": 0.7524414
    }
  ]
}

2.2 Call the Delete API

import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://memos.memtensor.cn/api/openmem/v1"

data = {
  "memory_ids": ["6b23b583-f4c4-4a8f-b345-58d0c48fea04"]
}

res = requests.post(
  f"{BASE_URL}/delete/memory",
  headers={"Authorization": f"Token {API_KEY}"},
  json=data
)

print(res.json())

2.3 Verify the Result

The API returns data.success: true when the delete request succeeds. After deletion, call Search Memory again to check whether the memory still appears.

{
  "code": 0,
  "data": {
    "success": true
  },
  "message": "ok"
}

3. Delete All Memories for a User

When you need to clear all memories for a user in the current project, pass user_id.

Before running this operation, make sure:
  • user_id is the end-user ID whose memories you want to clear.
  • The API Key belongs to the project this user belongs to.
  • You no longer need this user's fact, preference, Profile, Event Memory, skill, or tool memories in the current project.
import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://memos.memtensor.cn/api/openmem/v1"

data = {
  "user_id": "memos_user_123"
}

res = requests.post(
  f"{BASE_URL}/delete/memory",
  headers={"Authorization": f"Token {API_KEY}"},
  json=data
)

print(res.json())

After deleting all memories for a user, search again with the same user_id for that user's previous facts or preferences to confirm that old memories are no longer returned.


4. Delete All Memories for an Agent

When you need to clear all memories for an Agent in the current project, pass agent_id.

Before running this operation, make sure:
  • This Agent has Independent Memory enabled.
  • agent_id is the Agent ID whose memories you want to clear.
  • The API Key belongs to the project this Agent belongs to.
  • You no longer need this Agent's fact, preference, Profile, Event Memory, skill, or tool memories in the current project.
import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://memos.memtensor.cn/api/openmem/v1"

data = {
  "agent_id": "memos_agent"
}

res = requests.post(
  f"{BASE_URL}/delete/memory",
  headers={"Authorization": f"Token {API_KEY}"},
  json=data
)

print(res.json())

After deleting all memories for an Agent, search again with the same agent_id to confirm that old memories for that Agent are no longer returned.


5. Delete Memories in the Console

If you only need to delete one or a few memories temporarily, you can delete them directly in the console:

  1. Log in to the MemOS Console and make sure the current project is the one you want to operate on.
  2. Go to "Memory List" and use the search box, subject ID, subject type, or time range to find the target memory.
  3. Click "View Details" and check the memory ID and memory content. Make sure it is not a similar memory under the same user.
  4. Click "Delete" and confirm in the second confirmation dialog. To delete multiple memories, select multiple records first, then click "Batch Delete".
  5. Refresh the list after deletion, or search again with the same conditions to confirm that the memory no longer appears.
To delete memories automatically from your business system, or to batch-process memory_id values copied from logs or search results, call the delete/memory API instead.


6. Common Errors and Troubleshooting

Error codeCommon causeHow to fix
40000The request body is invalid, or unsupported fields are passed togetherPass only one of memory_ids, user_id, or agent_id (the three are mutually exclusive); memory_ids must be a non-empty string array
40002A required field is emptyCheck whether memory_ids / user_id / agent_id is missing, or whether you passed an empty string or empty array
40103 / 40132The API Key is invalid, expired, or cannot access the current projectGo back to Project Configuration and check whether the current project matches the API Key
40306Delete-memory authentication failedMake sure the memory belongs to the project of the current API Key and that you have permission to delete it
40307The memory_id does not existGet the latest id from search/memory or get/memory; do not use conversation_id, user_id, or a knowledge base ID
40308The user_id or agent_id does not existConfirm that this user/Agent has written memories in the current project. If passing agent_id, confirm that this Agent has independent memory enabled and has written memories

For more error code details, see Error Codes.

Need the complete field list, request format, and response format? See the Delete Memory API documentation.