Skip to main content
POST /openapi/memorylake/api/v1/projects/{id}/documents
Imports files from the user’s Library into a project. Each imported file becomes a project document and is queued for processing immediately. The operation is batch and supports partial success — the response tells you how many imports succeeded and how many failed. You can pass either file or directory IDs in drive_item_ids. Directories are recursively flattened to every descendant file before import, so importing a folder effectively imports its whole subtree in one call. Unsupported item types inside a directory are silently skipped. For convenience, drive_item_ids also accepts two aliases:
  • MY_SPACE — import every file under the user’s workspace root in one call.
  • ROOT — import every file the user has access to across the whole Library.
To add a file that is not yet in the Library, upload it first using the Library upload flow.

Path Parameters

id
string
required
Project ID.

Request Body

drive_item_ids
array
required
Library item IDs to import. Accepts file and directory IDs in any combination — directories are recursively flattened to all descendant files, and unsupported item types are silently skipped. The aliases MY_SPACE (your workspace root) and ROOT (the whole Library) are also accepted.
curl -X POST 'https://app.memorylake.ai/openapi/memorylake/api/v1/projects/proj-a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/documents' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "drive_item_ids": [
      "sc-5c6bf0f82d624a20a6fa4696997bdd46:7d8cf1e93f634b31b5",
      "sc-5c6bf0f82d624a20a6fa4696997bdd46:2a8cf1e93f634b31b7"
    ]
  }'

Response

data
object
{
  "success": true,
  "data": {
    "success_count": 2,
    "failure_count": 0
  }
}
After import, documents start out with status pending and transition through runningokay (or error). Poll List Documents or Get Document to observe progress.

Typical Flow

1

Put the file in the Library

Either upload it via the chunked upload flow, or locate an existing file with List Items.
2

Call Add Documents

Pass one or more item_ids inside drive_item_ids. You can mix files and directories — passing a directory imports every descendant file in one call. Batch in a single request when you can; it is faster than looping.
3

Track processing status

Poll List Documents until the new documents reach okay.