Data

#Knowledge base API

Use this API to feed documents into an AI Studio knowledge base from your own systems. You can upload files, check how ingestion is going, retry failures, download and delete documents, and keep the knowledge base in step with a cloud folder.

{BASE_URL} = https://studio.scaletechsolutions.ai/api/v1

#Authentication

Every request to {BASE_URL}/public/kb/... needs a knowledge base API key.

#One key, one knowledge base

A key is bound to exactly one knowledge base when it is created. The knowledge base always comes from the key, never from the URL, which is why no path contains a knowledge base id. A key can never read or change any other knowledge base. Every request runs as the user who created the key; for folder sync, the drive is read with that user's connected account.

Authorization: Bearer ai_labs_kb_3f9c0d1e2a4b5c6d7e8f9a0b1c2d3e4f

Keys start with ai_labs_kb_ followed by 32 hexadecimal characters.

#Creating, listing and revoking keys

Create, view and revoke keys in the AI Studio app, on the knowledge base's page. There is no public API for this. A key is shown in full only once, when you create it.

#When a key is refused

StatusdetailCause
401"Not authenticated"No Authorization header, or it is not Bearer <key>.
401"Invalid or revoked API key"The key is unknown or revoked, or the user who created it was deactivated. These cases return the same answer on purpose.
404"Knowledge base not found"The key is valid but its knowledge base has been deleted.

#Keeping keys safe

  • Keys do not expire. Treat them like passwords, and keep them on your server.
  • Store keys in a secret manager or environment variable, not in code.
  • Create one key per system, with a clear name, so you can revoke one without breaking the others.
  • Check last_used_at to find keys nobody uses any more, and revoke them.

#Documents

#Document lifecycle

Ingestion runs in the background. A document moves through these status values:

pendingstored, queued processingextract, chunk, embed completedsearchable errorerror_message set reingest: resets attempts, clears error, back to pending Note Earlier chunks staysearchable while areingest runs, andare kept if it fails.
Poll the status summary until in_progress is false.
StatusMeaning
pendingStored and waiting to be processed.
processingText is being extracted, split into chunks and embedded.
completedDone. The document is searchable. chunk_count says how many chunks it produced.
errorIngestion failed. error_message says why.

Upload returns as soon as the file is stored, usually with status: "pending". A document is searchable only once it is completed.

Automatic retries. For documents that came from a folder sync, each sync retries a failed document, up to 3 attempts in total. After that, retries_exhausted becomes true and the document is left alone until you reingest it yourself. A document where no text could be found at all is marked exhausted at once. Documents you upload directly are not retried automatically; use reingest.

#Supported files and limits

Accepted file extensions (checked on the file name, case-insensitive):

KindExtensions
Documents.pdf .docx .doc .pptx .ppt
Spreadsheets.xlsx .xls .csv .tsv
Text and markup.txt .md .html .htm .xml .json
Notebooks.ipynb
Images (text is read with OCR).jpg .jpeg .png .gif .bmp .tiff .webp
Archives.zip
CAD.step
LimitValueApplies to
Per-file size200 MBFiles from a folder sync. Larger files are skipped. Direct uploads have no per-file limit set by the API.
Files per folder source5,000Folder sync. Files beyond this are skipped.
Text indexed per documentfirst 40,000 charactersDocuments, text files, notebooks, images and archives.
OCR pagesfirst 80 pagesScanned PDFs with no text layer.
Archive expansion500 MB uncompressed, 20,000 entries.zip and Office files. Larger archives fail with an error.

Password-protected files cannot be read and end in error. If the knowledge base owner has personal-data masking turned on, personal data in the text is masked before it is indexed.

#The document object

Returned by upload, list and single reingest.

{
  "id": "c1b2b054-2be4-401f-b1d3-9f0516e43381",
  "kb_id": "3b5f69f3-945e-4d68-922d-00e30c66cfcb",
  "filename": "q3-report.pdf",
  "file_key": "kb/3b5f69f3-.../a779f8b7c0d84e0c9b1f2a3d4e5f6a7b_q3-report.pdf",
  "status": "completed",
  "chunk_count": 42,
  "error_message": null,
  "custom_metadata": {"team": "finance"},
  "created_at": "2026-11-27T11:23:46Z",
  "updated_at": "2026-11-27T11:24:02Z",
  "ingest_attempts": 0,
  "retries_exhausted": false,
  "origin": "manual",
  "source_folder": null,
  "source_site": null,
  "source_site_url": null,
  "web_url": null
}
FieldTypeMeaning
idUUIDThe document id. Use it in the per-document routes.
kb_idUUIDThe knowledge base (the one your key is bound to).
filenamestringThe original file name.
file_keystringInternal storage reference. Use the download route instead.
statusstringpending, processing, completed or error.
chunk_countintegerChunks produced by the last successful run.
error_messagestring or nullWhy ingestion failed, written for a person to read.
custom_metadataobject or nullThe metadata you sent on upload.
created_at, updated_atdatetimeISO 8601 timestamps.
ingest_attemptsintegerAutomatic extraction attempts so far. Reset to 0 when you reingest.
retries_exhaustedbooleantrue when automatic retries have stopped. Only meaningful when status is error.
originstringmanual for an uploaded file. For a synced file: google_drive, onedrive or sharepoint.
source_folderstring or nullName of the folder it was synced from.
source_site, source_site_urlstring or nullSharePoint site name and link.
web_urlstring or nullLink to the file at the provider. null for uploads.

#Upload a document

POST{BASE_URL}/public/kb/upload

Stores a file in the knowledge base and starts ingestion. Request type is multipart/form-data.

FieldTypeRequiredMeaning
filefileyesThe file. Its name must end in a supported extension.
custom_metadatastringnoA JSON object as a string, for example {"team":"finance"}. Returned in custom_metadata.
curl -X POST "{BASE_URL}/public/kb/upload" \
  -H "Authorization: Bearer $KB_API_KEY" \
  -F "file=@q3-report.pdf" \
  --form-string 'custom_metadata={"team":"finance"}'

Response 200 OK: a document object.

StatusdetailWhat to do
400"Unsupported file type. Supported formats: pdf, docx, ..."Use a supported extension.
404"Knowledge base not found"The key's knowledge base was deleted.
422validation listThe file field is missing.
500"Could not save file"Storage failed. Retry later.

#List documents

GET{BASE_URL}/public/kb/documents

Returns every document with full details, as an array of document objects. There is no pagination and the order is not guaranteed. On a large knowledge base this response can be big; if you only need progress, use Get ingestion status. Deleted documents are not listed.

#Get ingestion status

GET{BASE_URL}/public/kb/documents/status

A small summary of where every document stands. This is the route to poll after an upload or a sync.

{
  "total": 1346,
  "pending": 3,
  "processing": 1,
  "completed": 1317,
  "error": 25,
  "in_progress": true,
  "failures": [
    {
      "id": "788fda94-1b11-4bfa-9624-4f22426c151d",
      "filename": "logo.webp",
      "error_message": "No text could be extracted from 'logo.webp'. The file may contain only images, or no readable content.",
      "ingest_attempts": 3,
      "retries_exhausted": true,
      "web_url": null
    }
  ]
}
FieldTypeMeaning
totalintegerDocuments in the knowledge base.
pending, processing, completed, errorintegerCounts per status.
in_progressbooleantrue while any document is pending or processing.
failuresarrayEvery document in error, most recently updated first.

Common error_message values:

Message starts withMeaningWill a retry help?
No text could be extracted from '...'The file has no readable text.No.
'...' is password-protectedThe file is encrypted.Only after you remove the password and upload it again.
'...' expands to more than 500 MBThe archive is too large when unpacked.No.
Could not parse document: ...The file is damaged or could not be read.Sometimes.

#Reingest all failed documents

POST{BASE_URL}/public/kb/documents/reingest-failed

Processes again every document whose status is error. It re-reads each document from the copy AI Studio already stored (nothing is downloaded from the drive), resets ingest_attempts to 0, clears error_message and sets status to pending. Documents that are not in error are never touched. No request body.

{
  "failed": 25,
  "queued": 24,
  "unavailable": ["old-scan.pdf"]
}
FieldTypeMeaning
failedintegerDocuments that were in error.
queuedintegerDocuments now pending again.
unavailablearray of stringsFile names whose stored copy is missing. Upload them again.

#Reingest one document

POST{BASE_URL}/public/kb/documents/{document_id}/reingest

Processes one document again from its stored copy, whatever its status or attempt count. Returns the document object, usually pending.

StatusdetailWhat to do
404"Document not found"The id is wrong, deleted, or in another knowledge base.
404"Original file is no longer available"The stored copy is gone. Upload the file again.
422validation listdocument_id is not a UUID.

#Download a document

GET{BASE_URL}/public/kb/documents/{document_id}/download

Gives you the original file. Works for any status. Response is 307 Temporary Redirect; the Location header holds a signed URL valid for 5 minutes that needs no Authorization header. Don't store it; ask this route again each time.

curl -L -o q3-report.pdf \
  "{BASE_URL}/public/kb/documents/c1b2b054-2be4-401f-b1d3-9f0516e43381/download" \
  -H "Authorization: Bearer $KB_API_KEY"

curl -L follows the redirect and does not send your key to the storage host.

#Delete a document

DELETE{BASE_URL}/public/kb/documents/{document_id}

Removes a document. It disappears from every listing and count and is no longer searchable. It cannot be restored through the API. Returns 204 No Content.

#Folder sources

A folder source links the knowledge base to a folder in a cloud drive. AI Studio then adds new files, updates changed files and removes deleted files for you.

#How folder sync works

providerDrive
google_driveGoogle Drive
onedriveMicrosoft OneDrive
sharepointMicrosoft SharePoint document libraries

You need a connected account first. This API cannot connect a drive, because connecting needs a person to sign in and consent in a browser. The user who created your key must connect the drive once in the AI Studio app, under connectors. Browse and sync then read the drive with that user's account, so they only see folders that user can open.

Two ways to run a sync.

  • On a schedule. Set sync_interval_minutes (60 to 10080). The first sync starts right away, then repeats. Each run is spread by a few minutes.
  • On demand. Leave out the interval, then call Sync a source now.

Folder sync intervals

Allowed range for sync_interval_minutes, with common choices marked.

60 min3601440 (daily)10080 (weekly)
Sync startsschedule or "sync now" List folder fileswith the key owner's account Compare with KBprovider content marker New filedownload, ingest Changed filedownload, re-ingest Unchangedcounted, no work Skippedlisted with reason Removedleft the folder more than 5 ANDover half of source? yes needs_reviewnothing removed, syncs paused no remove documents, sync_status ok
The safety stop protects against a folder that was moved or emptied by mistake.
Change in the folderWhat happens in the knowledge base
New fileDownloaded and ingested.
Changed fileDownloaded and ingested again. Detected from the provider's content marker, so renaming or changing sharing does not reprocess it.
Unchanged fileNothing. Counted in unchanged.
File removed from the folderThe document is removed from the knowledge base.
File that cannot be taken (unsupported type, over 200 MB, over the 5,000-file limit, a lock file such as ~$report.docx)Skipped and listed in last_result.skipped with a reason. If it was ingested before, the existing document is kept.
Document whose ingestion failedRetried, up to 3 attempts in total.

Google Docs, Sheets and Slides are converted to .docx, .xlsx and .pptx and ingested. Other Google-native types are skipped. With recursive: true, files in subfolders are included too.

Only one sync per source runs at a time. A sync finishing means files were fetched and queued; each document still goes through the document lifecycle.

#The source object

{
  "id": "8d9e40bf-3706-4127-9b92-64d3cac3d437",
  "kb_id": "3b5f69f3-945e-4d68-922d-00e30c66cfcb",
  "user_id": "44e1b6a2-7c1d-4f0a-9e2b-1a2b3c4d5e6f",
  "provider": "onedrive",
  "external_folder_id": "01ABCDEFGHIJKLMNOP",
  "folder_name": "Reports",
  "folder_path": "Reports/2026",
  "folder_web_url": "https://onedrive.live.com/...",
  "site_name": null,
  "site_web_url": null,
  "recursive": true,
  "sync_interval_minutes": 1440,
  "next_sync_at": "2026-11-28T04:12:00Z",
  "sync_status": "ok",
  "last_synced_at": "2026-11-27T04:09:31Z",
  "last_error": null,
  "last_result": {
    "status": "ok",
    "added": 2, "updated": 1, "removed": 0, "unchanged": 37, "retried": 0,
    "skipped": [
      { "name": "walkthrough.mov", "reason": "unsupported file type (mov)", "external_id": "01QRSTUVWX", "web_url": "https://onedrive.live.com/..." }
    ]
  },
  "created_at": "2026-11-01T10:00:00Z",
  "updated_at": "2026-11-27T04:09:31Z"
}
FieldTypeMeaning
idUUIDThe source id. Store it; the other source routes need it.
user_idUUIDThe user whose drive account the sync uses.
providerstringgoogle_drive, onedrive or sharepoint.
external_folder_idstringThe provider's folder id. Renaming the folder does not break the source.
folder_name, folder_path, folder_web_urlstring or nullName, path and link.
site_name, site_web_urlstring or nullThe SharePoint site above the folder.
recursivebooleanWhether subfolders are included.
sync_interval_minutesinteger or nullSchedule. null means on demand only.
next_sync_atdatetime or nullWhen the next scheduled sync is due.
sync_statusstringSee below.
last_synced_atdatetime or nullWhen the last successful sync finished.
last_errorstring or nullWhy the last sync failed or stopped.
last_resultobject or nullWhat the last sync did. null before the first sync.

last_result has status, added, updated, removed, unchanged, retried, skipped (each with name, reason, external_id, web_url) and error when the sync failed or stopped. Typical skip reasons: unsupported file type (mov), larger than 200 MB, folder exceeds 5000 files, download failed.

#sync_status values

ValueMeaningWhat to do
pendingConnected, no sync has run yet.Wait, or trigger a sync.
syncingA sync is running.Keep polling.
okThe last sync succeeded.Nothing.
errorThe last sync failed. Read last_error.Often the drive connection needs reconnecting, or the folder was deleted.
needs_reviewThe safety stop fired. Nothing was removed.Check that the folder holds what you expect.
disabledSyncing is switched off for this source.None through this API.

#Browse folders

GET{BASE_URL}/public/kb/sources/browse

Lists one level of folders in a connected drive, so you can find a folder id.

NameTypeRequiredMeaning
providerstringyesgoogle_drive, onedrive or sharepoint.
folder_idstringnoList the folders inside this folder.
folder_pathstringnoList the folders inside this path, for example Reports/2026.
curl -G "{BASE_URL}/public/kb/sources/browse" \
  -H "Authorization: Bearer $KB_API_KEY" \
  --data-urlencode "provider=onedrive" \
  --data-urlencode "folder_path=Reports/2026"

Response is { "folder": {...}, "folders": [...] }. Each folder has id, name, web_url, path, shared, owner, kind (folder, or for SharePoint also site and library) and selectable. selectable: false means you can open the entry but not connect it, such as a SharePoint site.

StatusdetailWhat to do
400"Connector '<provider>' is not configured. ..."The key's user has not connected this drive. Connect it in the app.
400"Your <Drive> connection has expired. ..." with X-Reconnect-Required: trueSee Reconnect required.
404provider messageThe folder was not found.
422validation listprovider is missing.

#List sources

GET{BASE_URL}/public/kb/sources

Returns every folder source, oldest first, as an array of source objects. Poll this after you trigger a sync.

#Connect a folder

POST{BASE_URL}/public/kb/sources

Links a folder to the knowledge base. The folder is looked up during this request, so a wrong path or missing connection fails now, not later in the background.

FieldTypeRequiredMeaning
providerstringyesgoogle_drive, onedrive or sharepoint.
folder_idstringone of the twoThe provider's folder id. Most exact.
folder_pathstringone of the twoA path such as Reports/2026.
recursivebooleannoInclude files in subfolders. Default false.
sync_interval_minutesintegerno60 to 10080. Leave it out for on-demand only.
curl -X POST "{BASE_URL}/public/kb/sources" \
  -H "Authorization: Bearer $KB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"provider": "onedrive", "folder_path": "Reports/2026", "recursive": true, "sync_interval_minutes": 1440}'

Response 201 Created: the new source, with sync_status: "pending". With sync_interval_minutes set the first sync starts right away; poll List sources instead of calling sync.

StatusdetailWhat to do
400"'<name>' cannot be connected directly. Open it and choose a document library, or a folder inside one."You picked an entry with selectable: false.
404provider messageThe folder was not found.
409"'<name>' is already connected to this knowledge base."Use the existing source.
422validation listNeither folder_id nor folder_path, unsupported provider, or interval outside 60 to 10080.

#Change a source

PATCH{BASE_URL}/public/kb/sources/{source_id}
FieldTypeMeaning
recursivebooleanInclude or stop including subfolders. Takes effect on the next sync.
sync_interval_minutesintegerNew schedule, 60 to 10080. The next run is rescheduled from now.
manual_onlybooleantrue removes the schedule. The source stays and can still be synced on demand.

Response 200 OK: the updated source.

#Remove a source

DELETE{BASE_URL}/public/kb/sources/{source_id}

Stops syncing the folder. By default, documents already ingested stay and show origin: "manual" from then on. Pass purge=true to remove them too. If you later connect the same folder again, kept documents are matched to their files. Returns 204 No Content.

curl -X DELETE "{BASE_URL}/public/kb/sources/8d9e40bf-3706-4127-9b92-64d3cac3d437?purge=true" \
  -H "Authorization: Bearer $KB_API_KEY"

#Sync a source now

POST{BASE_URL}/public/kb/sources/{source_id}/sync

Queues a sync and returns at once. A first sync of a large folder can take many minutes, so poll List sources for sync_status and last_result. If a sync is already running the extra one does nothing, and it is skipped while the source is needs_review.

{
  "source_id": "8d9e40bf-3706-4127-9b92-64d3cac3d437",
  "sync_status": "ok",
  "queued": true,
  "detail": "Sync queued. Poll GET /sources for the outcome."
}

sync_status here is the status before this sync runs. Drive problems (connection expired, folder deleted) show up later as sync_status: "error" and last_error.

#Errors

Errors are JSON with a detail field. Validation errors (422) carry a list; unexpected server errors (500) include a request_id to quote if you contact support. Every response also carries an X-Request-ID header.

StatusMeaning
200Success with a body.
201Created (a folder source, or a key).
202Accepted: a sync was queued.
204Success with no body (delete, revoke).
307Redirect to a signed download URL.
400Unsupported file type, drive not connected or expired, folder cannot be connected, or the provider refused.
401Missing, unknown or revoked API key, or its user is deactivated.
404Knowledge base, document, source or folder not found, or the stored file is gone.
409That folder is already connected.
422The request did not pass validation.
500Server error. Retry later; quote request_id.

#Reconnect required

When the drive connection of the key's user has expired or was revoked at the provider, browse and connect calls answer:

HTTP/1.1 400 Bad Request
X-Reconnect-Required: true
X-Reconnect-Provider: onedrive
X-Reconnect-Provider-Label: Microsoft OneDrive

{"detail": "Your Microsoft OneDrive connection has expired. Please reconnect Microsoft OneDrive in Settings → Connectors."}

Check the X-Reconnect-Required header, not the message text. Retrying will not help: the key's user must reconnect the drive in the AI Studio app. Scheduled syncs hit the same problem and report it as sync_status: "error".

#End-to-end example (Python)

Uploads a file, waits until ingestion is done, then lists the documents. Needs httpx.

import json
import os
import time

import httpx

BASE_URL = "https://studio.scaletechsolutions.ai/api/v1"
API_KEY = os.environ["AI_STUDIO_KB_API_KEY"]  # keep the key out of your code


def main() -> None:
    headers = {"Authorization": f"Bearer {API_KEY}"}
    with httpx.Client(base_url=BASE_URL, headers=headers, timeout=60) as client:
        # 1. Upload a file with some metadata.
        with open("q3-report.pdf", "rb") as f:
            response = client.post(
                "/public/kb/upload",
                files={"file": ("q3-report.pdf", f, "application/pdf")},
                data={"custom_metadata": json.dumps({"team": "finance"})},
            )
        response.raise_for_status()
        document = response.json()
        print(f"Uploaded {document['filename']} as {document['id']} ({document['status']})")

        # 2. Poll the status summary until nothing is pending or processing.
        deadline = time.monotonic() + 30 * 60  # give up after 30 minutes
        while True:
            response = client.get("/public/kb/documents/status")
            response.raise_for_status()
            status = response.json()
            if not status["in_progress"]:
                break
            if time.monotonic() > deadline:
                raise TimeoutError("Ingestion is still running after 30 minutes")
            print(f"pending={status['pending']} processing={status['processing']}")
            time.sleep(5)

        for failure in status["failures"]:
            print(f"Failed: {failure['filename']}: {failure['error_message']}")

        # 3. List the documents and find ours.
        response = client.get("/public/kb/documents")
        response.raise_for_status()
        for doc in response.json():
            marker = "  <- new" if doc["id"] == document["id"] else ""
            print(f"{doc['status']:<10} {doc['chunk_count']:>5} chunks  {doc['filename']}{marker}")


if __name__ == "__main__":
    main()

The status summary covers the whole knowledge base, so in_progress also waits for other documents still being processed, for example from a folder sync running at the same time.

AI Studio developer documentation. Times are UTC and IDs are opaque strings.