diff --git a/docs/platform/quickstart.mdx b/docs/platform/quickstart.mdx index 472753f9..11632e22 100644 --- a/docs/platform/quickstart.mdx +++ b/docs/platform/quickstart.mdx @@ -639,6 +639,28 @@ curl -X DELETE "https://api.mem0.ai/v1/memories/?user_id=alex" \ ``` +Delete all users: + + + +```python Python +client.delete_users() +``` + +```javascript JavaScript +client.delete_users() + .then(users => console.log(users)) + .catch(error => console.error(error)); +``` + +```json Output +{'message': 'All users, agents, and sessions deleted.'} +``` + + + + + Fun fact: You can also delete the memory using the `add()` method by passing a natural language command: diff --git a/mem0/client/main.py b/mem0/client/main.py index 33fae583..5e584b7b 100644 --- a/mem0/client/main.py +++ b/mem0/client/main.py @@ -245,6 +245,17 @@ class MemoryClient: capture_client_event("client.users", self) return response.json() + @api_error_handler + def delete_users(self) -> Dict[str, Any]: + """Delete all users, agents, or sessions.""" + entities = self.users() + for entity in entities["results"]: + response = self.client.delete(f"/entities/{entity['type']}/{entity['id']}/") + response.raise_for_status() + + capture_client_event("client.delete_users", self) + return {"message": "All users, agents, and sessions deleted."} + def reset(self): """Reset the client. (Not implemented)