Workspace API
Knowledge Files
Upload, read, download, convert again and remove knowledge files with the /workspace/knowledge/files routes.
A knowledge file is attached to a page. Its text is converted to markdown after upload and becomes searchable. Every route costs 0 credits. Reads and downloads require knowledge:read; uploads, retry and remove require knowledge:write. Pass workspace_id as a query parameter when authenticating with a user JWT; API keys infer it.
The file object
| Field | Type | Description |
|---|---|---|
id, page_id | string | The file, and the page it is attached to. |
name, kind, mime_type, bytes, sha256 | The upload as received. kind is docx, pptx, xlsx, csv, pdf, text (Markdown or plain text) or image. | |
status | pending | ready | no_text | failed | pending while it converts. no_text means nothing was readable (a scanned PDF, for example). An image is stored, not read: it is ready with no text. |
error | string | null | Why the last conversion failed. |
truncated | boolean | The file was longer than conversion reads; the start is searchable. |
imported | boolean | Its markdown became the page body, so it has no sections of its own. |
parser_version | string | null | The converter that produced the text. |
markdown_chars | integer | Length of the converted text. |
created_by, created_at, updated_at | Who uploaded it, and when. |
Upload a File
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/filesMultipart form fields:
| Field | Required | Description |
|---|---|---|
file | Yes | DOCX, PPTX, XLSX, CSV, PDF, Markdown, plain text or an image; 20 MB at most. The request needs a Content-Length. |
page | No | Attach to this page (id or folder/Title). Without it, a new page is made, titled after the file. |
path | No | The folder for the new page. |
title | No | The new page’s title, instead of the file name. Ignored with page. |
A Word, Markdown or text file becomes the body of a page that has none (imported: true); any other file stays attached and is searchable as its own sections. The response comes back pending; read the file until its status settles.
curl -X POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files \ -H "Authorization: Bearer pcl_your_api_key" \ -F "path=Go-to-market"const form = new FormData();form.append('file', fileInput.files[0]);form.append('path', 'Go-to-market');
const response = await fetch( 'https://api.parcelengineering.com/api/v1/workspace/knowledge/files', { method: 'POST', headers: { 'Authorization': 'Bearer pcl_your_api_key' }, body: form, });
const { data } = await response.json(); // { file, page }Errors: 409 page_archived (restore the page first), 409 path_title_taken, 411 without a Content-Length, 413 over 20 MB, 400 for a file whose contents do not match its type.
Batch upload
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/batchMultipart files (1-10, 20 MB in total) and an optional path. Each file makes its own page. Results come back in input order; a successful item’s record is { file, page }.
Read a File
GET https://api.parcelengineering.com/api/v1/workspace/knowledge/files/{id}The converted markdown, paged by characters: offset (default 0) and limit (1-50,000, default 12,000). The response is { file, text, offset, next_offset, total_chars }; pass next_offset as offset until it is null. The text is empty until the first conversion is ready. While a retry runs, or after one fails, it is the last good conversion.
Download a File
GET https://api.parcelengineering.com/api/v1/workspace/knowledge/files/{id}/downloadThe bytes exactly as uploaded, as an attachment. 409 file_missing if the stored object is gone.
Convert Again
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/retryPOST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/retry/batchBody { "file": "<id>" }, or { "ids": [...] } (1-100) for the batch. Reads the stored file again, for one that failed or to pick up a newer converter. The file returns to pending. 409 file_busy while it is still converting. A batch converts 5 files a call; the rest answer try_later, so send them again.
Remove a File
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/removePOST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/remove/batchBody { "file": "<id>" }, or { "ids": [...] } (1-100) for the batch. Deletes the file, its sections and the stored object; the page and its body stay. The response is { "file": { "id": "<id>" } }.