Skip to main content
GET
/
v1
/
memories
/
{memory_id}
/
history
/
Python
# To use the Python SDK, install the package:
# pip install mem0ai

from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key")

# Add some message to create history
messages = [{"role": "user", "content": "<user-message>"}]
client.add(messages, user_id="<user-id>")

# Add second message to update history
messages.append({"role": "user", "content": "<user-message>"})
client.add(messages, user_id="<user-id>")

# Get history of how memory changed over time
memory_id = "<memory-id-here>"
history = client.history(memory_id)
// To use the JavaScript SDK, install the package:
// npm i mem0ai

import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });

// Get history of how memory changed over time
client.history("<memory_id>")
.then(result => console.log(result))
.catch(error => console.error(error));
curl --request GET \
--url https://api.mem0.ai/v1/memories/{memory_id}/history/ \
--header 'Authorization: Token <api-key>'
package main

import (
"fmt"
"net/http"
"io/ioutil"
)

func main() {

url := "https://api.mem0.ai/v1/memories/{memory_id}/history/"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Token <api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
fmt.Println(string(body))

}
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mem0.ai/v1/memories/{memory_id}/history/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Token <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.get("https://api.mem0.ai/v1/memories/{memory_id}/history/")
.header("Authorization", "Token <api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.mem0.ai/v1/memories/{memory_id}/history/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'

response = http.request(request)
puts response.read_body
[
  {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "memory_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "input": [
      {
        "content": "<string>"
      }
    ],
    "new_memory": "<string>",
    "user_id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z",
    "old_memory": "<string>",
    "metadata": {}
  }
]

Authorizations

Authorization
string
header
required

API key authentication. Prefix your Mem0 API key with 'Token '. Example: 'Token your_api_key'

Path Parameters

memory_id
string<uuid>
required

The unique identifier of the memory to retrieve.

Response

200 - application/json

Successfully retrieved the memory history.

id
string<uuid>
required

Unique identifier for the history entry.

memory_id
string<uuid>
required

Unique identifier of the associated memory.

input
object[]
required

The conversation input that led to this memory change

new_memory
string
required

The new or updated state of the memory

user_id
string
required

The identifier of the user associated with this memory

event
enum<string>
required

The type of event that occurred

Available options:
ADD,
UPDATE,
DELETE
created_at
string<date-time>
required

The timestamp when this history entry was created.

updated_at
string<date-time>
required

The timestamp when this history entry was last updated.

old_memory
string | null

The previous state of the memory, if applicable

metadata
object | null

Additional metadata associated with the memory change