Skip to main content

Documents API

Upload, manage, and process documents in your workspace.

Endpoints​

MethodPathDescription
POST/workspaces/:id/documentsUpload document
GET/workspaces/:id/documentsList documents
GET/workspaces/:id/documents/:docIdGet document
PUT/workspaces/:id/documents/:docIdUpdate metadata
PATCH/workspaces/:id/documents/:docIdAuto-save content
DELETE/workspaces/:id/documents/:docIdDelete document
POST/workspaces/:id/documents/:docId/processReprocess document

Upload document​

POST /workspaces/:id/documents
Content-Type: multipart/form-data

Upload a new document for processing.

Request (multipart/form-data)​

FieldTypeRequiredDescription
fileFileYesThe document file
titleStringNoCustom title (defaults to filename)
purposeStringNoKNOWLEDGE or INSTRUCTION
tagsString[]NoTag IDs to apply

Supported formats​

  • PDF (.pdf)
  • Microsoft Word (.docx, .doc)
  • Plain text (.txt)
  • Markdown (.md)

Response​

{
"id": "doc_xyz789",
"title": "My Document",
"filename": "document.pdf",
"mimeType": "application/pdf",
"size": 1024000,
"purpose": "KNOWLEDGE",
"uploadStatus": "COMPLETED",
"processingStatus": "PROCESSING",
"createdAt": "2025-01-01T12:00:00Z"
}

Example​

curl -X POST "https://api.synjar.com/v1/workspaces/ws_abc123/documents" \
-H "Authorization: Bearer $API_KEY" \
-F "file=@document.pdf" \
-F "title=My Document" \
-F "purpose=KNOWLEDGE"

List documents​

GET /workspaces/:id/documents

List all documents in a workspace.

Query parameters​

ParameterTypeDescription
pageNumberPage number (default: 1)
limitNumberItems per page (default: 20, max: 100)
statusStringFilter by processing status
purposeStringFilter by purpose
tagsStringComma-separated tag IDs
searchStringFull-text search in titles

Response​

{
"data": [
{
"id": "doc_xyz789",
"title": "My Document",
"purpose": "KNOWLEDGE",
"processingStatus": "VERIFIED",
"tags": ["tag_abc"],
"createdAt": "2025-01-01T12:00:00Z",
"updatedAt": "2025-01-01T12:05:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 42,
"pages": 3
}
}

Get document​

GET /workspaces/:id/documents/:docId

Get full document details including content chunks.

Response​

{
"id": "doc_xyz789",
"title": "My Document",
"filename": "document.pdf",
"mimeType": "application/pdf",
"size": 1024000,
"purpose": "KNOWLEDGE",
"uploadStatus": "COMPLETED",
"processingStatus": "VERIFIED",
"tags": [
{
"id": "tag_abc",
"name": "Important",
"color": "#FF5733"
}
],
"chunkCount": 15,
"tokenCount": 4500,
"createdAt": "2025-01-01T12:00:00Z",
"updatedAt": "2025-01-01T12:05:00Z"
}

Update metadata​

PUT /workspaces/:id/documents/:docId

Update document title, purpose, or tags.

Request​

{
"title": "Updated Title",
"purpose": "INSTRUCTION",
"tags": ["tag_abc", "tag_def"]
}

Auto-save content​

PATCH /workspaces/:id/documents/:docId

Auto-save document content (for text/markdown documents).

Request​

{
"content": "# Updated content\n\nThis is the new document content."
}
note

After updating content, document will be re-processed. Status will change to PROCESSING.

Delete document​

DELETE /workspaces/:id/documents/:docId

Permanently delete a document.

warning

This action cannot be undone. The document will be removed from all instruction sets and search results.

Reprocess document​

POST /workspaces/:id/documents/:docId/process

Trigger reprocessing of a document. Useful after content updates or if processing failed.

Response​

{
"id": "doc_xyz789",
"processingStatus": "PROCESSING",
"message": "Document queued for reprocessing"
}

Processing status​

Documents go through these statuses:

StatusDescription
PENDINGUpload received, waiting for processing
PROCESSINGExtracting text and generating embeddings
VERIFIEDProcessing complete, document is searchable
FAILEDProcessing failed (check error message)

Document purpose​

PurposeDescription
KNOWLEDGESearchable via RAG (returns relevant chunks)
INSTRUCTIONFull document available in instruction sets

Error responses​

StatusCodeDescription
400INVALID_FILE_TYPEUnsupported file format
400FILE_TOO_LARGEFile exceeds size limit
401UNAUTHORIZEDMissing or invalid token
403FORBIDDENInsufficient permissions
404DOCUMENT_NOT_FOUNDDocument doesn't exist
409DOCUMENT_LOCKEDDocument is locked by another user

See also​