See Stacksync in action with a solution architect. Book a demo ↗
Knowledge basesDocuments

Knowledge base documents

Add a knowledge base document

POST
/v1/workspaces/{workspace_id}/knowledge-bases/{knowledge_base_id}/documents

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

Authorizationstringheaderrequired

Bearer <key>, where <key> is a workspace API key or a user API key. See Authentication.

Path Parameters

workspace_id*integer

The workspace. List the ones your key can reach with GET /v1/workspaces.

knowledge_base_id*string

The knowledge base.

Formatuuid

Query Parameters

region*Regions

Region of the resource: besg (Europe) or usnv (United States), as GET /v1/regions lists them

Value in"besg""usnv"

Header Parameters

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.

Defaultnull

Request Body

application/json
  1. body
file_id*File Id

Id of a file of the workspace (GET /files), added as the document

Formatuuid
validate_only?Validate Only

Run every check of the write and answer 204 without writing: a refused write answers the error the write would

Defaultfalse

Response Body

Created

application/json
  1. response

A document of a knowledge base, and how far its processing got

document_id*Document Id
knowledge_base_id*Knowledge Base Id
title*Title
mime_type*Mime Type
file_id*File Id
processing_status*string|null
processing_error*string|null
chunk_count*integer|null
created_time*Created Time
Formatdate-time
Add a knowledge base document
curl -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"}