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

# PATCH /memories/{memory_id} — Update Memory Content

> Replace the content of an existing memory and re-embed it for accurate future retrieval. The memory ID and all other fields remain unchanged.

When a fact about a user changes, you should update the existing memory rather than storing a new one alongside the old. Keeping a single authoritative record prevents your agent from encountering conflicting facts during retrieval. For example, if a user says "I moved from Lagos to Abuja," find the location memory and patch it — the memory ID is preserved, but the content and its embedding are refreshed so every future search reflects the new truth.

<Note>
  **Endpoint:** `PATCH https://api.remem.online/memories/{memory_id}`
</Note>

## Request Headers

| Name           | Required | Description        |
| -------------- | -------- | ------------------ |
| `X-API-Key`    | Yes      | Your Remem API key |
| `Content-Type` | Yes      | `application/json` |

## Path Parameters

<ParamField path="memory_id" type="string" required>
  UUID of the memory you want to update. Obtain this from a previous store, search, or list response.
</ParamField>

## Query Parameters

<ParamField query="user_id" type="string" required>
  Must match the `user_id` that owns this memory.
</ParamField>

<ParamField query="agent_id" type="string" required>
  Must match the `agent_id` that stored this memory.
</ParamField>

## Request Body

<ParamField body="content" type="string" required>
  The replacement text for this memory. Remem re-embeds the new content automatically so future semantic searches return accurate results.
</ParamField>

## Examples

<CodeGroup>
  ```bash curl theme={null}
  curl -X PATCH \
    "https://api.remem.online/memories/775263ee-73af-4416-9804-1f274048ae08?user_id=user_123&agent_id=support_bot" \
    -H "X-API-Key: rm_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "content": "User moved from Lagos to Abuja, Nigeria"
    }'
  ```

  ```python Python SDK theme={null}
  from remem import RememClient

  client = RememClient(api_key="rm_live_xxx")

  updated = client.update(
      memory_id="775263ee-73af-4416-9804-1f274048ae08",
      user_id="user_123",
      agent_id="support_bot",
      content="User moved from Lagos to Abuja, Nigeria",
  )

  print(updated.id)       # same UUID as before
  print(updated.content)  # "User moved from Lagos to Abuja, Nigeria"
  ```
</CodeGroup>

## Response

### 200 — Success

Returns the full updated Memory object.

```json theme={null}
{
  "id":          "775263ee-73af-4416-9804-1f274048ae08",
  "content":     "User moved from Lagos to Abuja, Nigeria",
  "user_id":     "user_123",
  "agent_id":    "support_bot",
  "memory_type": "semantic",
  "importance":  0.95,
  "metadata":    {},
  "created_at":  "2026-06-01T10:00:00Z",
  "last_accessed": "2026-06-07T09:00:00Z",
  "expires_at":  null
}
```

### 404 — Not Found

```json theme={null}
{
  "detail": "Memory '775263ee...' not found for user=user_123 agent=support_bot"
}
```

The `memory_id` doesn't exist, or it belongs to a different `user_id` or `agent_id`.

## Error Responses

| Code  | Meaning                    | Fix                                                                            |
| ----- | -------------------------- | ------------------------------------------------------------------------------ |
| `401` | Invalid or missing API key | Verify your key is passed in the `X-API-Key` header                            |
| `404` | Memory not found           | Check the `memory_id`, `user_id`, and `agent_id` all match the original record |
| `422` | Validation error           | `content` is required in the request body                                      |

<Note>
  Remem re-embeds the updated content immediately, so future semantic searches will reflect the change. The memory ID remains unchanged — any references you've stored to that ID continue to work.
</Note>
