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

# Update Memories

> Update the content of an existing Cognis memory record by its ID.

The `update` method replaces the content of a stored memory record. Use it to correct a fact, refine a preference, or reflect a change in user context.

## Method signature

```python theme={null}
cog.update(
    memory_id: str,
    content: str,
    owner_id: str | None = None,
) -> CognisMemoryRecord
```

## Parameters

| Parameter   | Type  | Required | Description                                     |
| ----------- | ----- | -------- | ----------------------------------------------- |
| `memory_id` | `str` | Yes      | The ID of the memory record to update.          |
| `content`   | `str` | Yes      | The new content to replace the existing memory. |
| `owner_id`  | `str` | No       | Owner identifier for additional scoping.        |

## Response

Returns the updated `CognisMemoryRecord`.

| Field        | Type           | Description                           |
| ------------ | -------------- | ------------------------------------- |
| `id`         | `str`          | Memory record ID.                     |
| `content`    | `str`          | The updated memory content.           |
| `version`    | `int \| None`  | Incremented version number.           |
| `is_current` | `bool \| None` | Always `true` for the updated record. |
| `updated_at` | `str \| None`  | Timestamp of the update.              |

## Basic usage

<Tabs>
  <Tab title="Hosted (lyzr-adk)">
    ```python theme={null}
    from lyzr import Cognis

    cog = Cognis(api_key="sk-your-api-key")

    updated = cog.update(
        memory_id="mem_abc123",
        content="Alice is now based in London.",
        owner_id="user_alice",
    )
    print(updated.content)
    # "Alice is now based in London."
    ```
  </Tab>

  <Tab title="Open Source (lyzr-cognis)">
    ```python theme={null}
    from cognis import Cognis

    m = Cognis(owner_id="user_alice")

    result = m.update(
        memory_id="mem_abc123",
        content="Alice is now based in London.",
    )
    print(result)

    m.close()
    ```
  </Tab>
</Tabs>

## Async usage

```python theme={null}
import asyncio
from lyzr import Cognis

async def main():
    async with Cognis(api_key="sk-your-api-key") as cog:
        updated = await cog.aupdate(
            memory_id="mem_abc123",
            content="Alice prefers Python over JavaScript.",
        )
        print(updated.content)

asyncio.run(main())
```

To find the `memory_id` for a specific record, use [Get Memories](./get-memories) or [Search Memories](./search-memories) first, then pass the returned ID to `update`. Previous versions of the memory are retained and accessible via `get()` with `include_historical=True`.
