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

# Manage Memories via API

> Search, review, update, and verify Humm memories using the public API.

Use this workflow when a business fact changed and you want to update the memories Humm uses in future conversations.

## Before You Begin

You will need:

* Your organization ID
* A Humm API token
* The Analyst API base URL, usually `https://analyst.heyhumm.ai`

<Note>
  Memories are best updated with a review step. Search first, inspect the current memory, then patch the specific content you want to change.
</Note>

## Recommended Flow

1. Search for relevant memories with a broad natural-language query
2. Pick the memory you want to change
3. Fetch the full current memory
4. Draft the updated content locally
5. Review the diff
6. Apply the `PATCH`
7. Re-fetch the memory and verify the result

## 1. Search Memories

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request GET \
  --url "https://analyst.heyhumm.ai/memories/search/semantic?organization_id=$ORG_ID&query=support%20SLA%2024%20hours&limit=5&similarity_threshold=0.3" \
  --header "Authorization: Bearer $HUMM_PAT"
```

## 2. Fetch the Current Memory

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request GET \
  --url "https://analyst.heyhumm.ai/memories/$MEMORY_ID?organization_id=$ORG_ID" \
  --header "Authorization: Bearer $HUMM_PAT"
```

Example response fields to keep:

* `id`
* `content`
* `tags`
* `status`
* `updated_at`

## 3. Apply the Update

Update only the fields you want to change.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request PATCH \
  --url "https://analyst.heyhumm.ai/memories/$MEMORY_ID?organization_id=$ORG_ID" \
  --header "Authorization: Bearer $HUMM_PAT" \
  --header "Content-Type: application/json" \
  --data '{
    "content": "The support SLA is 24 hours, not 48 hours.",
    "tags": ["support", "sla"]
  }'
```

## Python Example

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import difflib
import os
import requests

base_url = "https://analyst.heyhumm.ai"
headers = {"Authorization": f"Bearer {os.environ['HUMM_PAT']}"}
org_id = os.environ["ORG_ID"]
memory_id = os.environ["MEMORY_ID"]

current = requests.get(
    f"{base_url}/memories/{memory_id}",
    params={"organization_id": org_id},
    headers=headers,
    timeout=30,
)
current.raise_for_status()
memory = current.json()

old_content = memory["content"]
new_content = old_content.replace("48 hours", "24 hours")

print("\n".join(difflib.unified_diff(
    old_content.splitlines(),
    new_content.splitlines(),
    fromfile="before",
    tofile="after",
    lineterm="",
)))

approved = input("Apply update? [y/N] ").strip().lower() == "y"
if approved:
    updated = requests.patch(
        f"{base_url}/memories/{memory_id}",
        params={"organization_id": org_id},
        headers={**headers, "Content-Type": "application/json"},
        json={"content": new_content, "tags": memory.get("tags", [])},
        timeout=30,
    )
    updated.raise_for_status()
    print(updated.json()["updated_at"])
```

## TypeScript Example

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
const baseUrl = "https://analyst.heyhumm.ai";

async function updateMemory(orgId: string, memoryId: string, token: string) {
  const current = await fetch(
    `${baseUrl}/memories/${memoryId}?organization_id=${orgId}`,
    { headers: { Authorization: `Bearer ${token}` } },
  );

  if (!current.ok) throw new Error(`Fetch failed: ${current.status}`);
  const memory = await current.json();

  const newContent = String(memory.content).replace("48 hours", "24 hours");

  console.log("Preview only:");
  console.log({ before: memory.content, after: newContent });

  const res = await fetch(
    `${baseUrl}/memories/${memoryId}?organization_id=${orgId}`,
    {
      method: "PATCH",
      headers: {
        Authorization: `Bearer ${token}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        content: newContent,
        tags: memory.tags ?? [],
      }),
    },
  );

  if (!res.ok) throw new Error(`Update failed: ${res.status}`);
  return res.json();
}
```

## Prompt Your Assistant

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Use the Humm Analyst API to update a memory.

Organization:
- Use this organization ID: $ORG_ID

Change request:
- Update any memory that still says the support SLA is 48 hours so it correctly says 24 hours

Workflow:
1. Generate 3-5 search queries with different phrasings, not just one exact phrase
2. Search memories with a broad similarity threshold so you do not miss likely candidates
3. Deduplicate the results and show me the top candidates with:
   - memory ID
   - a short content preview
   - tags
   - which search query matched
4. Wait for me to choose which memory to update
5. Fetch the full selected memory and save the current content locally as a backup
6. Draft the proposed replacement content locally
7. Keep the edit surgical:
   - preserve structure and writing style
   - update only the fact that changed
   - preserve tags unless there is a clear reason to change them
8. Show me:
   - the full before/after diff
   - a short summary of what changed
   - whether you recommend changing any tags
9. Wait for explicit approval before calling PATCH
10. After the PATCH succeeds, re-fetch the memory and confirm:
   - content reflects the approved change
   - tags are correct
   - updated_at changed

Constraints:
- Do not patch a memory until I approve the diff
- If no good candidates are found, stop and show me the search results instead of guessing
- If the memory topic would fundamentally change, tell me to create a new memory instead of rewriting it
```

## Verification

After the update, fetch the memory again:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request GET \
  --url "https://analyst.heyhumm.ai/memories/$MEMORY_ID?organization_id=$ORG_ID" \
  --header "Authorization: Bearer $HUMM_PAT"
```

Confirm:

* The content matches the approved update
* Tags are still correct
* `updated_at` changed

## Notes

* Updating memory content through the API also refreshes the memory embeddings used for semantic search.
* Use a low similarity threshold when searching if you are not sure how the memory was originally phrased.
* If a fact is completely outdated, you can also reject or delete the memory instead of editing it.
