---
title: "Update Memory"
method: PATCH
path: "/v1/memories/{memory_id}"
tags: ["v1"]
---

# Update Memory

`PATCH /v1/memories/{memory_id}`

## Request

- Base URL: `https://api.korely.ai`
- URL: `https://api.korely.ai/v1/memories/{memory_id}`
- Auth: HTTP bearer

Replace a memory's text.

Its facts are extracted again from the new text and go through the same
contradiction check as a new write: a value that changed supersedes the
fact the old text stated, which stays in history (`as_of` before the edit
still returns it). Like a new write, the reply says `processing` with
`facts: []` until the extraction has run.

`expected_updated_at` makes the edit conditional on the version you read:
409 `stale_write`, and nothing changes, when the memory moved since; 422
when it is not an instant (an empty string included).

## Path parameters

- `memory_id` string, required

## Request body

- UpdateBody
  - `content` string, required
  - `expected_updated_at` string, nullable: Optimistic concurrency: the `updated_at` you read (`created_at` while `updated_at` is null), sent back as the API returned it. The edit is written only if the memory is still at that version, to the microsecond, when it is written; otherwise 409 `stale_write` and nothing changes. A value that is not an ISO 8601 instant, the empty string included, is a 422 and nothing changes; leave the field out for an edit without the check.

## Response `200`

Successful Response

- MemoryWithFacts
  - `id` string, required
  - `content` string, required
  - `user_id` string, nullable, required
  - `agent_id` string, nullable, required
  - `run_id` string, nullable, required
  - `client` string, nullable: The tool that wrote it: the X-Korely-Client header of the write, or the name an MCP client gave when it connected. A label, not a namespace: no read is scoped by it and the agent cap does not count it.
  - `kind` string: `note`, or `session` for the log of a work session (`kind` of the write).
  - `metadata` object, required
  - `status` string: Whether this memory's typed facts are queryable yet: 'processing', 'ready', or 'error'. Extraction runs after the write returns, so a read taken immediately can legitimately find no facts. Poll GET /v1/events or read the memory again: no webhook says that extraction finished (`memory.created` is sent when the memory is stored, before its facts).
  - `created_at` string, nullable, required
  - `updated_at` string, nullable, required
  - `facts` object[]

## Other responses

- `401`: `invalid_key`: the `Authorization: Bearer` key is missing, unknown, revoked or expired.
- `403`: `forbidden`: the key lacks the scope this operation needs; `message` names it.
- `404`: `not_found`: nothing with that id is reachable with this key.
- `409`: `stale_write`: `expected_updated_at` does not match the current record.
- `413`: `payload_too_large`: the body is larger than 2,097,152 bytes, the most this route takes. Refused before it is read; nothing was done.
- `422`: `invalid_request`: the body, a query parameter or a path parameter is malformed (`detail` is the list of fields that failed, `message` names the first), or the endpoint refuses a value (an empty content, an unreadable timestamp; `detail` is a sentence or `{code, message}`).
- `429`: `rate_limit_exceeded`: past the request ceiling, the per-minute one set on this install (`RATE_LIMIT_PER_MINUTE`) or, on the hosted service, the plan's minute, hour or day; `message` names the window and `Retry-After` the seconds until it resets. On this service also `quota_exceeded`: the plan's writes of the month are spent (`limit`, `used`, `resets_at`, and no `Retry-After`: a retry fails until `resets_at`, a top-up or a bigger plan).
- `500`: `internal_error`: the server failed on this request; `message` holds no detail of it.
- `503`: A dependency did not answer: the database while the key was checked (`unavailable`, see `Retry-After`), or the one `code` names. Nothing was written; retry.

---

[API](https://skmtc.dev/korely/apis/korely-agents-api.md) · [All operations](https://skmtc.dev/korely/apis/korely-agents-api/llms.txt) · [OpenAPI document](https://skmtc.dev/korely/apis/korely-agents-api/revisions/8a40bf09eca1?raw)
