Korely

Core memory operations

Update a memory

Replace a memory's content. Korely re-runs fact extraction on the new text, changed values supersede prior facts, unchanged facts dedupe, so your typed knowledge stays in sync.

PATCH /v1/memories/{memory_id}

SDK: korely.update(memory_id, content=...). The update path re-runs the intelligence, embeddings and typed-fact extraction with bi-temporal contradiction checking, on the new content. Changed values supersede prior facts; unchanged facts are deduped. You never write supersede logic.

Authentication

HTTP header, required: Authorization: Bearer kor_live_....

Path parameter

ParameterTypeRequiredDescription
memory_idstringRequiredThe public memory id (mem_) to update. A malformed id returns 404.

Request body

FieldTypeRequiredDescription
contentstringRequiredNew content. 1-16,000 characters. Stripped and rejected if blank or whitespace-only (422).
expected_updated_atstringOptionalOptimistic concurrency token. If set and it doesn't match the record's current updated_at (or created_at) within a 1-second tolerance, the write is rejected with 409 stale_write. Defaults to null (no concurrency check).

Example request

Terminal window
curl -X PATCH https://api.korely.ai/v1/memories/mem_8f2c1a \
-H "Authorization: Bearer kor_live_..." \
-H "Content-Type: application/json" \
-d '{
"content": "Giulia now prefers in-person standups.",
"expected_updated_at": "2026-03-01T09:14:22+00:00"
}'

Response

200 OK. The updated memory, plus the typed facts freshly re-extracted from the new content.

{
"id": "mem_8f2c1a",
"content": "Giulia now prefers in-person standups.",
"user_id": "customer-giulia-4812",
"agent_id": "onboarding-bot",
"run_id": null,
"metadata": {"source": "slack"},
"created_at": "2026-03-01T09:14:22+00:00",
"updated_at": "2026-03-02T11:02:10+00:00",
"facts": [
{
"id": "fct_b2",
"subject": "Giulia",
"subject_type": "person",
"predicate": "prefers",
"predicate_raw": "prefers",
"object": "in-person standups",
"object_is_literal": true,
"predicate_family": "preference",
"confidence": 0.88,
"user_id": "customer-giulia-4812",
"agent_id": "onboarding-bot",
"valid_from": "2026-03-02T11:02:10+00:00",
"invalid_at": null,
"invalidated_by": null,
"source_memory_id": "mem_8f2c1a",
"created_at": "2026-03-02T11:02:11+00:00"
}
]
}
FieldTypeDescription
idstringThe public memory id (mem_).
contentstringThe updated content, echoed back.
user_idstring · nullThe end user this memory belongs to (null if not scoped).
agent_idstring · nullThe agent namespace (null if not scoped).
run_idstring · nullThe run namespace (null if not scoped).
metadataobjectThe metadata dict stored with the memory.
created_atstring · nullISO 8601 timestamp.
updated_atstring · nullISO 8601 timestamp.
factsarrayTyped (subject, predicate, object) facts freshly re-extracted from the new content. Changed values supersede prior facts via the contradiction pipeline; unchanged facts are deduped.

Errors

StatusCodeCause
401invalid_keyMissing or invalid kor_live_ key, Invalid or missing API key.
403forbiddenKey lacks the memories:write scope, API key missing required scope(s): memories:write.
404not_foundMalformed memory_id, or the memory doesn't exist (including when checked against expected_updated_at), Memory not found.
409stale_writeexpected_updated_at was provided but doesn't match the current record, expected_updated_at does not match the current record.
422invalid_requestcontent is empty or whitespace-only, or its length is outside 1-16,000 characters.
429rate_limit_exceededRate limit exceeded, returned with a Retry-After header.

Notes

  • It's a write. Update requires the memories:write scope and does not meter the read query quota.
  • Facts stay in sync. The PATCH re-runs fact extraction on the new content, changed values supersede prior facts (their invalid_at is set), and unchanged facts are deduped.
  • Optimistic concurrency. The expected_updated_at tolerance is 1 second. A missing or unparseable current timestamp is treated as stale, so the safe write is rejected rather than allowed to clobber.
  • No webhook. Updates do not emit a webhook event.

Related