- Create the document. Semji creates it in
pendingstatus and returns the S3 form. - Send the file to S3 with that form. Processing starts by itself.
- Poll the document until it is
successorfailed.
Prerequisites
- An API key with access to the workspace. See Authentication.
- The workspace ID. Get it from
GET /v1/workspaces. - A user who is an owner or a member of the workspace, on a workspace with the V2 knowledge base and direct upload enabled. Guest writers cannot manage knowledge base files. Otherwise creating a file document returns a
403.
1. Create the document
CallPOST /v1/workspaces/{workspaceId}/knowledge-documents with the display name, the original file name (extension included) and the size in bytes. knowledgeFolderId and replaces are optional. Only PDF, CSV, TXT, XLSX and DOCX files are accepted: any other extension returns 400 with the knowledge_document_upload_type_not_allowed error code. An invalid replaces (a document that is not live, or from another workspace or page) returns 422 with knowledge_document_replacement_invalid.
cURL
201 Created:
201 Created
POST /v1/pages/{pageId}/knowledge-documents. It takes the same body without knowledgeFolderId.
Keep id: the next steps use it as {knowledgeDocumentId}.
2. Send the file to S3
Send amultipart/form-data POST to upload.url. The form is valid for 15 minutes and the file can weigh up to 50 MB.
cURL
--form-string for the fields: -F reads a value starting with @ or < as a file. This request goes to S3, not to Semji, so it carries no Authorization header. A success is an empty 2xx or 3xx response from S3.
Once S3 accepts the file, Semji starts processing it: there is nothing else to call.
If the 15 minutes elapse before the file arrives, the document ends up failed with upload_expired. Create the document again.
3. Poll until the document is ready
Processing is asynchronous. PollGET /v1/knowledge-documents/{knowledgeDocumentId} every few seconds until status is success or failed:
cURL
When processing fails
Afailed document carries a failureReason. To try again, create the document again and list the failed one in replaces, so it is removed once the new one is ready.
Add text and URL documents
Documents that are not files need no upload. Use the same route with exactly one ofcontent (text) or url (a web page that Semji crawls) instead of fileName and size:
cURL
pending and follows step 3 like a file. POST /v1/pages/{pageId}/knowledge-documents attaches it to a page.
Organize and review documents
Folders
Workspace documents can be filed in knowledge folders. List the folders of a workspace:cURL
200 OK
id as knowledgeFolderId when you create the document. Without it, the document goes to the General folder, which is not part of this list. Page documents have no folder.
Manage folders with these calls:
To file documents, send up to 100 IDs.
knowledgeFolderId: null files them in General. Page documents and unknown IDs are skipped.
cURL
Filter, sort and paginate the list
GET /v1/workspaces/{workspaceId}/knowledge-documents paginates at 25 documents by default (page, and limit up to 100). It accepts these filters and sort:
Filters, sort and pagination need the V2 knowledge base. Without it, the full list comes back and they are ignored.
The
nbCitations field is null for a document created before citations were counted (13 October 2026) and never cited since.
Review a document
A document becomesto_validate once it is 18 months old and has not been validated in the last 3 months. Mark a document as reviewed with POST /v1/knowledge-documents/{knowledgeDocumentId}/validation: its reviewStatus becomes up_to_date for 3 months. Only a processed document (status is success) can be validated, otherwise the call returns 409 with the conflict code. It needs the V2 knowledge base.
GET /v1/knowledge-documents/{knowledgeDocumentId} returns the document with its indexed content.
Preview a document
GET /v1/knowledge-documents/{knowledgeDocumentId}/preview returns the document as the app previews it: the original file for a file document, Markdown for a text or URL document. It needs the V2 knowledge base.
Update a document
PUT /v1/knowledge-documents/{knowledgeDocumentId} changes the name, the summary or, for a text document, its content. An update of a document that is still pending, or that is failed, returns 409 with the conflict code: wait for it to succeed, or replace a failed one by creating a new document with replaces.
Next steps
- Replace outdated documents by listing their IDs in
replaceswhen you create the new one. They must be live documents of the same workspace and page, otherwise the call returns422withknowledge_document_replacement_invalid. The new document does not inherit the folder of the one it replaces: pass itsknowledgeFolderIdto keep it there. - See Errors for the error format, including
error.errorCode. - Working from an AI assistant? The MCP tools add text and web page documents; files go through this API or the Semji app.