Leni developers
Context
Search notes, list folders, access files, and write saved knowledge in the API-key owner’s authorized Personal or Organization Context.
Why the API still says memory
memory, user_memory, and organisation_memory for backward compatibility. Send those identifiers exactly as documented: they map to Personal Context and Organization Context.POST/users/get-user-memory
Legacy compatibility route for the existing Personal Context response shape. JSON body is optional. modelType and modelId select an authorized scope; an empty {} uses defaults. New integrations should use the normalized search route below.
{ "modelType": "leniq-pro", "modelId": null }POST/users/memory/search
| Field | Requirement | Behavior |
|---|---|---|
| scope | Required | user for Personal Context, or organization for eligible Organization Context. |
| modelType / modelId | Optional | Defaults to leniq-pro; modelId selects an authorized custom analyst. |
| page / pageSize | Optional | Defaults to 1 / 20. pageSize is capped at 100. |
| search | Optional | Case-insensitive title/content search, up to 500 characters. |
The response includes normalized notes and safe attachment metadata such as file name, MIME type, and size. It never returns storage keys or download URLs.
{
"scope": "organization",
"modelType": "leniq-pro",
"search": "loan",
"page": 1,
"pageSize": 20
}{
"memories": [{
"id": "<memory-id>",
"title": "Loan terms",
"content": "...",
"scope": "organization",
"modelType": "leniq-pro",
"canEdit": true,
"attachments": [{
"filename": "loan-agreement.pdf",
"contentType": "application/pdf",
"sizeBytes": 48120
}],
"createdAt": "<ISO-8601 timestamp>",
"folderId": "<folder-id>",
"folderName": "Financing"
}],
"total": 1,
"page": 1,
"pageSize": 20
}Organization Context eligibility
PAID_FEATURE_REQUIRED. A 404 from a note or file route intentionally does not distinguish a missing resource from one outside the caller’s authorized partition.POST/users/memory/folders
Send scope plus optional modelType and modelId. Each returned folder contains only note IDs visible in that exact user or organization/model partition.
{ "scope": "user", "modelType": "leniq-pro" }POST/users/memory/:memoryId/files
Resolves one bounded page of files on an exact authorized note after rechecking the API-key owner, organization, and model partition. The response contains five-minute HTTPS bearer links. It never accepts a raw attachment ID and never exposes an S3 bucket or object key.
| Field | Requirement | Behavior |
|---|---|---|
| page | Optional | One-based page number; defaults to 1. |
| pageSize | Optional | Defaults to 20 and is capped at 25. |
{
"scope": "organization",
"modelType": "leniq-pro",
"page": 1,
"pageSize": 20
}The response includes total, hasMore, and partial. FollowhasMore page by page. Retry the same page when partial is true.
Use links immediately
POST/users/add-to-memory
| Field | Requirement | Behavior |
|---|---|---|
| memoryType | Required | Non-empty Context store, normally user_memory or organisation_memory. |
| noteTitle / noteContext | Optional | Readable title and note content. |
| modelType / modelId | Optional | Authorized model scope. modelType is required whenever modelId is sent. |
| folderId / folderName | Optional | Folder placement metadata. |
| files / filesBase64 | Optional | Shared base64 file contract; multipart parts named files are supported. |
{
"memoryType": "user_memory",
"modelType": "leniq-pro",
"noteTitle": "Building hours",
"noteContext": "Lobby desk staffed 9–5 weekdays."
}POST/users/update-memory
| Field | Requirement | Behavior |
|---|---|---|
| memory | Required | Existing Context object, including its owned identifier and changed fields. |
| memoryType | Required | Non-empty store matching the record. |
| modelType | Required with modelId | Authorized model type for scoped Organization Context. |
| modelId | Optional | Authorized custom model scope. |
| files / filesBase64 | Optional | New attachments using the shared file contract. |
{
"memoryType": "user_memory",
"memory": {
"id": "<memory-id>",
"noteTitle": "Updated title",
"noteContext": "Updated body"
},
"modelType": "leniq-pro"
}Updates are scoped writes