Leni developers
File uploads
Run models, Context writes, and custom analyst Context can include supported attachments. Each decoded file is limited to 50 MB.
| Format | Contract |
|---|---|
| Multipart | Use multipart/form-data and one or more binary parts named files. Analyst Organization Context files use organisationMemoryFiles. |
| JSON base64 | Send a files or filesBase64 array. When both exist, filesBase64 is used for base64 entries. |
| File field | Required | Meaning |
|---|---|---|
| filename or name | Yes | Name presented to the upstream model. |
| contentBase64 or dataBase64 | Yes | Standard base64 file bytes; whitespace is accepted. |
| contentType or mimeType | No | MIME type; defaults to application/octet-stream. |
{
"files": [{
"filename": "policy.pdf",
"contentType": "application/pdf",
"contentBase64": "<base64>"
}]
}Validation
The 50 MB limit is measured after base64 decoding. Base64 increases request size, so keep the complete JSON body comfortably below transport limits. Reject invalid base64 and oversized files before sending. Do not place file bytes in URL parameters.
Multipart example
curl --fail-with-body --silent --show-error \
-X POST "https://api.prod.ca-central-1.leni.co/users/add-to-memory" \
-H "X-Api-Key: $LENI_API_KEY" \
-F 'memoryType=user_memory' \
-F 'modelType=leniq-pro' \
-F 'noteTitle=Insurance policy' \
-F 'noteContext=Current policy for portfolio reference' \
-F 'files=@policy.pdf;type=application/pdf'Do not set the multipart boundary manually; the HTTP client must generate it. For custom-analyst organization memory, use binary parts named organisationMemoryFiles instead.
Reading Context files
Use
POST /users/memory/:memoryId/files to obtain five-minute links for files on an authorized Context note. Results are paginated with at most 25 files per page. The caller selects a note, not a raw attachment or storage key.{
"files": [{
"filename": "policy.pdf",
"downloadUrl": "<five-minute HTTPS link>",
"expiresInSeconds": 300
}],
"total": 1,
"page": 1,
"pageSize": 20,
"hasMore": false,
"partial": false
}