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-memory

Request fields

FieldTypeRequiredDescription
memoryobject
Required
The memory record to update—typically the object returned from list or create routes, including its id and current fields.
memoryTypestring
Required
Same type you used when creating the record (for example user_memory or organisation_memory). Must be non-empty.
userobject | string
Optional
Optional JSON object or string whose model fields are merged with the API key owner before the request is sent to Leni.
modelTypestring
Optional
Top-level model type, merged into the outbound user. If you set modelId, you should also send modelType.
modelIdstring | null
Optional
Top-level model id, merged into the outbound user when you include it on the body.
noteTitlestring
Optional
Updated title. When you attach files, this is forwarded as an explicit form field alongside the memory JSON.
noteContextstring
Optional
Updated body text. When you attach files, this is forwarded as an explicit form field alongside the memory JSON.
files / filesBase64array
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 memory and related fields in a normal JSON body.
  • With file bytes: the API forwards multipart fields for noteTitle, noteContext, memory, and one or more files parts.
  • JSON base64: use files or filesBase64 with 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.