Skip to content

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

FieldTypeDescription
id, page_idstringThe file, and the page it is attached to.
name, kind, mime_type, bytes, sha256The upload as received. kind is docx, pptx, xlsx, csv, pdf, text (Markdown or plain text) or image.
statuspending | ready | no_text | failedpending 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.
errorstring | nullWhy the last conversion failed.
truncatedbooleanThe file was longer than conversion reads; the start is searchable.
importedbooleanIts markdown became the page body, so it has no sections of its own.
parser_versionstring | nullThe converter that produced the text.
markdown_charsintegerLength of the converted text.
created_by, created_at, updated_atWho uploaded it, and when.

Upload a File

Endpoint
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files

Multipart form fields:

FieldRequiredDescription
fileYesDOCX, PPTX, XLSX, CSV, PDF, Markdown, plain text or an image; 20 MB at most. The request needs a Content-Length.
pageNoAttach to this page (id or folder/Title). Without it, a new page is made, titled after the file.
pathNoThe folder for the new page.
titleNoThe 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.

Upload a playbook into a folder
curl -X POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files \
-H "Authorization: Bearer pcl_your_api_key" \
-F "file=@sales-playbook.docx" \
-F "path=Go-to-market"

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

Endpoint
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/batch

Multipart 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

Endpoint
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

Endpoint
GET https://api.parcelengineering.com/api/v1/workspace/knowledge/files/{id}/download

The bytes exactly as uploaded, as an attachment. 409 file_missing if the stored object is gone.

Convert Again

Endpoint
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/retry
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/retry/batch

Body { "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

Endpoint
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/remove
POST https://api.parcelengineering.com/api/v1/workspace/knowledge/files/remove/batch

Body { "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>" } }.