Delete Memory

Delete memories from MemOS, supporting batch deletion of memories for multiple users.
Go directly to API Docs

This article focuses on functional explanation. For detailed interface fields and limits, please click the link above.

1. Key Parameters

  • Memory ID List (memory_ids): This parameter accepts a list of memory IDs and is used to delete one or more specific memories.
How to obtain memory IDs for deletion

When retrieving memories via search/memory or get/memory, each memory item in the returned result contains a unique id field, which serves as the unique identifier for that memory.
If a memory is found to be expired or does not meet expectations, you can directly take this id and pass it as the memory_ids[] parameter when calling the delete/memory API to delete the corresponding memory entry.

2. Working Principle

  • Delete Memory: Delete the memory content matching the specified users based on the provided memory IDs.

3. Quick Start

import os
import requests
import json

# Replace with your MemOS API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"

data = {
    "memory_ids":["4a50618f-797d-4c3b-b914-94d7d1246c8d"]  # Replace with real memory IDs
  }
headers = {
  "Content-Type": "application/json",
  "Authorization": f"Token {os.environ['MEMOS_API_KEY']}"
}
url = f"{os.environ['MEMOS_BASE_URL']}/delete/memory"

res = requests.post(url=url, headers=headers, data=json.dumps(data))

print(f"result: {res.json()}")
 Want to know if the deletion was successful? Copy the above code and run it, then Search Memory again to see if the memory has been successfully deleted.