> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mem0.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory History

> Retrieve the full change history of a specific memory to track how it has evolved over time.



## OpenAPI

````yaml get /v1/memories/{memory_id}/history/
openapi: 3.0.1
info:
  title: Mem0 API Docs
  description: mem0.ai API Docs
  contact:
    email: support@mem0.ai
  license:
    name: Apache 2.0
  version: v1
servers:
  - url: https://api.mem0.ai/
security:
  - ApiKeyAuth: []
paths:
  /v1/memories/{memory_id}/history/:
    get:
      tags:
        - memories
      description: Retrieve the history of a memory.
      operationId: memories_history_list
      parameters:
        - name: memory_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: The unique identifier of the memory to retrieve.
      responses:
        '200':
          description: Successfully retrieved the memory history.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                      format: uuid
                      description: Unique identifier for the history entry.
                    memory_id:
                      type: string
                      format: uuid
                      description: Unique identifier of the associated memory.
                    input:
                      type: array
                      items:
                        type: object
                        properties:
                          role:
                            type: string
                            enum:
                              - user
                              - assistant
                            description: The role of the speaker in the conversation
                          content:
                            type: string
                            description: The content of the message
                        required:
                          - role
                          - content
                      description: The conversation input that led to this memory change
                    old_memory:
                      type: string
                      nullable: true
                      description: The previous state of the memory, if applicable
                    new_memory:
                      type: string
                      description: The new or updated state of the memory
                    user_id:
                      type: string
                      description: The identifier of the user associated with this memory
                    event:
                      type: string
                      enum:
                        - ADD
                        - UPDATE
                        - DELETE
                      description: The type of event that occurred
                    metadata:
                      type: object
                      nullable: true
                      description: Additional metadata associated with the memory change
                    created_at:
                      type: string
                      format: date-time
                      description: The timestamp when this history entry was created.
                    updated_at:
                      type: string
                      format: date-time
                      description: The timestamp when this history entry was last updated.
                  required:
                    - id
                    - memory_id
                    - input
                    - new_memory
                    - user_id
                    - event
                    - created_at
                    - updated_at
      x-code-samples:
        - lang: Python
          source: |-
            # 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)
        - lang: JavaScript
          source: |-
            // 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));
        - lang: cURL
          source: |-
            curl --request GET \
              --url https://api.mem0.ai/v1/memories/{memory_id}/history/ \
              --header 'Authorization: Token <api-key>'
        - lang: Go
          source: "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v1/memories/{memory_id}/history/\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
        - lang: PHP
          source: |-
            <?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;
            }
        - lang: Java
          source: >-
            HttpResponse<String> response =
            Unirest.get("https://api.mem0.ai/v1/memories/{memory_id}/history/")
              .header("Authorization", "Token <api-key>")
              .asString();
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Prefix your Mem0 API key with 'Token '. Example:
        'Token your_api_key'

````