Knowledge base documents
Add a knowledge base document
Adds a file of the workspace (uploaded with the files API) to a knowledge base as a document, and processes it. The file must be a document Stacksync can read (PDF, Word, Excel, CSV, JSON, Markdown or plain text) and not already a document of the knowledge base. With validate_only, the checks run and 204 answers, nothing is added.
Authorization
AuthorizationstringheaderrequiredBearer <key>, where <key> is a workspace API key or a user API key. See Authentication.
workspace_id*integerThe workspace. List the ones your key can reach with GET /v1/workspaces.
knowledge_base_id*stringThe knowledge base.
uuidregion*RegionsRegion of the resource: besg (Europe) or usnv (United States), as GET /v1/regions lists them
"besg""usnv"Idempotency-Key?|Makes the create retry-safe for 24 hours: a retry with the same key answers the resource the first call created, with the Idempotent-Replayed: true header, and creates nothing. 1 to 255 visible ASCII characters. The same key with a different request answers 422; while the first call still runs, 409.
nullapplication/json- body
file_id*File IdId of a file of the workspace (GET /files), added as the document
uuidvalidate_only?Validate OnlyRun every check of the write and answer 204 without writing: a refused write answers the error the write would
falseCreated
application/json- response
A document of a knowledge base, and how far its processing got
document_id*Document Idknowledge_base_id*Knowledge Base Idtitle*Titlemime_type*Mime Typefile_id*File Idprocessing_status*string|nullprocessing_error*string|nullchunk_count*integer|nullcreated_time*Created Timedate-timecurl -X POST 'https://api.stacksync.com/v1/workspaces/0/knowledge-bases/497f6eca-6276-4993-bfeb-53cbbbba6f08/documents?region=besg' \ -H 'Content-Type: application/json' \ -d '{ "file_id": "3f6c1d2e-8a4b-4c7d-9e21-5b6f7a8c9d01"}'{ "document_id": "<document_id>", "knowledge_base_id": "<knowledge_base_id>", "title": "<title>", "mime_type": "<mime_type>", "file_id": "<file_id>", "processing_status": "<processing_status>", "processing_error": "<processing_error>", "chunk_count": 0, "created_time": "2027-01-15T09:00:00Z"}