Update memory
Updates an existing memory row. Without uploads, send JSON with memory, memoryType, and optional model fields as below. When uploads are present, the endpoint forwards multipart form data similar to Add to memory.
POST
/users/update-memoryRequest fields
| Field | Type | Required | Description |
|---|---|---|---|
| memory | object | Required | The memory record to update—typically the object returned from list or create routes, including its id and current fields. |
| memoryType | string | Required | Same type you used when creating the record (for example user_memory or organisation_memory). Must be non-empty. |
| user | object | string | Optional | Optional JSON object or string whose model fields are merged with the API key owner before the request is sent to Leni. |
| modelType | string | Optional | Top-level model type, merged into the outbound user. If you set modelId, you should also send modelType. |
| modelId | string | null | Optional | Top-level model id, merged into the outbound user when you include it on the body. |
| noteTitle | string | Optional | Updated title. When you attach files, this is forwarded as an explicit form field alongside the memory JSON. |
| noteContext | string | Optional | Updated body text. When you attach files, this is forwarded as an explicit form field alongside the memory JSON. |
| files / filesBase64 | array | Optional | Optional file attachments using the same base64 object shape as run-models and add-to-memory (see File uploads). When present, the service forwards multipart form data to Leni. |
Example
JSON
{
"memoryType": "user_memory",
"memory": {
"id": "memory-row-id",
"noteTitle": "Updated title",
"noteContext": "Updated body…"
},
"modelType": "leniq-pro"
}Optional uploads
- JSON only: send
memoryand related fields in a normal JSON body. - With file bytes: the API forwards multipart fields for
noteTitle,noteContext,memory, and one or morefilesparts. - JSON base64: use
filesorfilesBase64with the shared structure described in File uploads.
Example with attachment metadata
JSON
{
"memoryType": "user_memory",
"memory": {
"id": "memory-row-id",
"noteTitle": "Updated title",
"noteContext": "See the attached policy."
},
"modelType": "leniq-pro",
"noteTitle": "Updated title",
"noteContext": "See the attached policy.",
"files": [
{
"filename": "policy.pdf",
"contentType": "application/pdf",
"contentBase64": "<base64-here>"
}
]
}Code examples
const res = await fetch(`${process.env.API_BASE}/users/update-memory`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Api-Key": process.env.LENI_API_KEY!,
},
body: JSON.stringify({
memoryType: "user_memory",
memory: {
id: "memory-row-id",
noteTitle: "Updated title",
noteContext: "Updated body…",
},
modelType: "leniq-pro",
}),
});
await res.json();Pair with list to fetch ids first.