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

# Update Memory

> Update an existing memory entry with new content, metadata, or category classification

Updates a specific memory entry by ID. You can modify the memory content, metadata, category, or memory type.

<RequestExample>
  ```bash cURL theme={null}
  curl -X PATCH 'https://api.memchat.io/memories/mem_123abc' \
    -H 'X-API-Key: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "content": "Updated: Had an amazing conversation with Sarah about machine learning applications in healthcare. She mentioned some innovative approaches to medical imaging.",
      "metadata": {
        "location": "Stanford Medical Center",
        "participants": ["Sarah Johnson", "Dr. Martinez"],
        "updated_at": "2024-01-15T16:30:00Z"
      },
      "category": "learning"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.memchat.io/memories/mem_123abc"
  headers = {
      "X-API-Key": "YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  data = {
      "content": "Updated: Had an amazing conversation with Sarah about machine learning applications in healthcare. She mentioned some innovative approaches to medical imaging.",
      "metadata": {
          "location": "Stanford Medical Center",
          "participants": ["Sarah Johnson", "Dr. Martinez"],
          "updated_at": "2024-01-15T16:30:00Z"
      },
      "category": "learning"
  }

  response = requests.patch(url, headers=headers, json=data)
  memory = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.memchat.io/memories/mem_123abc', {
    method: 'PATCH',
    headers: {
      'X-API-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      content: 'Updated: Had an amazing conversation with Sarah about machine learning applications in healthcare. She mentioned some innovative approaches to medical imaging.',
      metadata: {
        location: 'Stanford Medical Center',
        participants: ['Sarah Johnson', 'Dr. Martinez'],
        updated_at: '2024-01-15T16:30:00Z'
      },
      category: 'learning'
    }),
  });

  const memory = await response.json();
  ```
</RequestExample>

## Path Parameters

<ParamField path="memory_id" type="string" required>
  The unique identifier of the memory to update
</ParamField>

## Request Body

<ParamField body="content" type="string">
  Updated text content of the memory
</ParamField>

<ParamField body="metadata" type="object">
  Additional metadata to update for the memory

  <Expandable title="Metadata Properties">
    <ParamField body="location" type="string">
      Location where the memory occurred
    </ParamField>

    <ParamField body="participants" type="array">
      List of people involved in the memory
    </ParamField>

    <ParamField body="tags" type="array">
      Custom tags for the memory
    </ParamField>

    <ParamField body="source" type="string">
      Source of the memory (e.g., "conversation", "document", "social\_media")
    </ParamField>

    <ParamField body="confidence" type="number">
      Confidence score between 0.0 and 1.0
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="category" type="string">
  Updated memory category. One of: `identity`, `career`, `interests`, `relationships`, `health`, `finance`, `learning`, `travel`, `productivity`, `private`
</ParamField>

<ParamField body="memory_type" type="string">
  Updated memory type: `semantic` or `episodic`
</ParamField>

<ParamField body="importance" type="number">
  Updated importance score between 0.0 and 1.0
</ParamField>

## Response

<ResponseField name="memory_id" type="string">
  Unique identifier of the updated memory
</ResponseField>

<ResponseField name="content" type="string">
  Updated text content of the memory
</ResponseField>

<ResponseField name="category" type="string">
  Updated memory category
</ResponseField>

<ResponseField name="memory_type" type="string">
  Updated memory type (semantic or episodic)
</ResponseField>

<ResponseField name="importance" type="number">
  Updated importance score
</ResponseField>

<ResponseField name="metadata" type="object">
  Updated memory metadata
</ResponseField>

<ResponseField name="embeddings" type="array">
  Vector embeddings for the updated content (if content was modified)
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp when the memory was originally created
</ResponseField>

<ResponseField name="updated_at" type="string">
  ISO 8601 timestamp when the memory was last updated
</ResponseField>

<ResponseExample>
  ```json Response theme={null}
  {
    "memory_id": "mem_123abc",
    "content": "Updated: Had an amazing conversation with Sarah about machine learning applications in healthcare. She mentioned some innovative approaches to medical imaging.",
    "category": "learning",
    "memory_type": "episodic",
    "importance": 0.85,
    "metadata": {
      "location": "Stanford Medical Center",
      "participants": ["Sarah Johnson", "Dr. Martinez"],
      "source": "conversation",
      "updated_at": "2024-01-15T16:30:00Z"
    },
    "embeddings": [0.123, -0.456, 0.789, ...],
    "created_at": "2024-01-15T14:30:00Z",
    "updated_at": "2024-01-15T16:30:00Z"
  }
  ```
</ResponseExample>

## Error Responses

<ResponseField name="404" type="object">
  Memory not found

  ```json theme={null}
  {
    "error": "Memory not found",
    "code": "MEMORY_NOT_FOUND",
    "memory_id": "mem_123abc"
  }
  ```
</ResponseField>

<ResponseField name="400" type="object">
  Invalid request data

  ```json theme={null}
  {
    "error": "Invalid category specified",
    "code": "INVALID_CATEGORY",
    "valid_categories": ["identity", "career", "interests", "relationships", "health", "finance", "learning", "travel", "productivity", "private"]
  }
  ```
</ResponseField>

<ResponseField name="401" type="object">
  Unauthorized access

  ```json theme={null}
  {
    "error": "Invalid or expired API key",
    "code": "UNAUTHORIZED"
  }
  ```
</ResponseField>

<ResponseField name="403" type="object">
  Access denied - memory belongs to another user

  ```json theme={null}
  {
    "error": "Access denied",
    "code": "FORBIDDEN"
  }
  ```
</ResponseField>

## Notes

* Only the fields provided in the request body will be updated
* If content is updated, new embeddings will be automatically generated
* Category changes may trigger re-classification and profile updates
* Memory type changes will affect how the memory is retrieved in searches
* All updates are versioned internally for audit purposes
