Add to memory

Adds content to user or organisation memory. With no files, send JSON including memoryType, merged user identifiers, optional notes, and optional modelType / modelId. With files, use multipart/form-data and/or JSON base64 arrays per File uploads; the API forwards fields and one or more files parts as needed.

POST/users/add-to-memory

Request fields

FieldTypeRequiredDescription
memoryTypestring
Required
Which memory store to write to. Must be non-empty. Typically user_memory for personal notes or organisation_memory for shared org knowledge.
modelTypestring
Optional
Convenience field at the top level of the body. When provided, it is merged into the outbound user object sent to Leni.
modelIdstring | null
Optional
Convenience field at the top level of the body. When present, it is merged into the outbound user object sent to Leni.
noteTitlestring
Optional
Title of the memory note. Included in both JSON-only and multipart requests when you provide it.
noteContextstring
Optional
Main text of the memory note. Included in both JSON-only and multipart requests when you provide it.
folderIdstring
Optional
Id of the folder to place this memory in. Used when forwarding multipart form data to Leni.
folderNamestring
Optional
Name of the folder to associate with this memory. Used when forwarding multipart form data to Leni.

Optional files

  • No file bytes: body is sent as JSON with user, memoryType, note fields, and related ids.
  • With file bytes: use multipart parts and/or JSON base64 arrays using the same shape as File uploads.

Example: JSON only

JSON
{
  "memoryType": "user_memory",
  "modelType": "leniq-pro",
  "modelId": null,
  "noteTitle": "Building hours",
  "noteContext": "Lobby desk staffed 9–5 weekdays."
}

Example: JSON with base64 file

JSON
{
  "memoryType": "user_memory",
  "modelType": "leniq-pro",
  "noteTitle": "Policy",
  "noteContext": "Document uploaded",
  "files": [
    {
      "filename": "policy.pdf",
      "contentType": "application/pdf",
      "contentBase64": "<base64-here>"
    }
  ]
}

Code examples

const res = await fetch(`${process.env.API_BASE}/users/add-to-memory`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": process.env.LENI_API_KEY!,
  },
  body: JSON.stringify({
    memoryType: "user_memory",
    modelType: "leniq-pro",
    modelId: null,
    noteTitle: "Building hours",
    noteContext: "Lobby desk staffed 9–5 weekdays.",
  }),
});