Skip to main content

REST API

All endpoints are under the /api prefix. Document processing runs asynchronously: digitization, rewriting, and embedding are background jobs. Upload or update a document, then poll document and knowledge-base status.

Authentication

Supply your API key in the X-API-Key header.

curl -X GET https://knowledge.hidoba.com/api/knowledgebases/my-partner \
-H "X-API-Key: YOUR_API_KEY"

Content Types

List Content Types

GET /api/content_types

Returns the available content types for rewriting. No authentication required.

Response

{
"content_types": [
{ "id": "auto", "name": "Auto (detect from source)" },
{ "id": "article", "name": "Article" },
{ "id": "youtube", "name": "YouTube" },
{ "id": "book", "name": "Book" }
]
}

Knowledge Bases

List Knowledge Bases

GET /api/knowledgebases/{partner}

Returns all knowledge bases for the partner, including aggregate embedding status.

Response

[
{
"name": "my-kb",
"embedding_status": "success",
"expert_name": "Ada Lovelace",
"user_email": "ada@example.com",
"deletion_requested_at": null
}
]

embedding_status is one of success, in_progress, fail, none, or delete_pending.

Create Knowledge Base

POST /api/knowledgebases/{partner}
Content-Type: multipart/form-data
curl -X POST https://knowledge.hidoba.com/api/knowledgebases/my-partner \
-H "X-API-Key: YOUR_API_KEY" \
-F "name=my-kb"
ParameterTypeDefaultDescription
nameStringKnowledge base name. Required.
expert_nameStringKnowledge base-level expert/author metadata.
user_emailStringKnowledge base-level user email metadata.

Delete Knowledge Base

DELETE /api/knowledgebases/{partner}/{kb}

Deletes the knowledge base immediately when possible. If documents or vector cleanup are still active, the response status is delete_pending and includes pending document/vector cleanup details.

Folders

List Folders

GET /api/folders/{partner}/{kb}

Response

{
"folders": ["chapter-1", "chapter-2"]
}

Create Folder

POST /api/folders/{partner}/{kb}
Content-Type: multipart/form-data
curl -X POST https://knowledge.hidoba.com/api/folders/my-partner/my-kb \
-H "X-API-Key: YOUR_API_KEY" \
-F "name=chapter-1"

Send name as a form parameter.

Delete Folder

DELETE /api/folders/{partner}/{kb}/{folder}

Deletes the folder immediately when possible. If documents or vector cleanup are still active, the response status is delete_pending.

Documents

List Documents

GET /api/documents/{partner}/{kb}

Returns the knowledge base with all documents and aggregate embedding info.

Get Combined Data

GET /api/kb-data/{partner}/{kb}

Returns documents, folders, pending folder deletions, and aggregate embedding info in a single call.

Get KB Statistics

GET /api/kb-stats/{partner}/{kb}

Response

{
"document_count": 42,
"digitized_count": 40,
"draft_rewrite_count": 38,
"final_rewrite_count": 35,
"total_digitized_chars": 250000,
"total_draft_rewrite_chars": 200000,
"total_final_rewrite_chars": 180000,
"error_count": 2,
"embedded_count": 35
}

Get Single Document

GET /api/document/{partner}/{kb}/{doc_id}

Create Document (File Upload)

POST /api/documents/{partner}/{kb}
Content-Type: multipart/form-data
curl -X POST https://knowledge.hidoba.com/api/documents/my-partner/my-kb \
-H "X-API-Key: YOUR_API_KEY" \
-F "type=file" \
-F "folder=chapter-1" \
-F "file=@document.pdf" \
-F "auto_rewrite=true" \
-F "model_tier=standard"

Form Parameters

ParameterTypeDefaultDescription
typeStringfile or url. Required.
folderStringTarget folder name. Required.
fileFileFile to upload. Required when type=file.
urlStringURL to fetch. Required when type=url.
nameStringDocument name. Auto-detected from file/URL if omitted.
expert_nameStringContent author or speaker name.
user_emailStringEmail of the uploading user.
auto_rewriteStringfalseAutomatically queue for rewriting after digitization. Pass "true" to enable.
model_tierStringstandardLLM model tier: standard or economy.
use_original_as_rewrittenStringfalseSkip LLM rewriting and use the original/digitized content as final rewritten content. Pass "true" to enable.

When final rewritten content is created, embedding is queued automatically. This happens after a successful rewrite, after use_original_as_rewritten=true, or after uploading/updating rewritten content.

Uploads are validated by file extension and file signature. Supported extensions are PDF, DOC/DOCX, PPT/PPTX, XLS/XLSX, EPUB, MD/MARKDOWN, HTML/HTM, TXT/PY/JS/CSS, CSV/JSON/XML/YAML/YML, MP4/MOV/M4V/AVI, MP3/WAV/M4A, and JPG/JPEG/PNG/TIF/TIFF/GIF/WebP. Archives such as ZIP, TAR, GZ/TGZ, RAR, 7Z, BZ2, and XZ are blocked.

Create Document (URL)

curl -X POST https://knowledge.hidoba.com/api/documents/my-partner/my-kb \
-H "X-API-Key: YOUR_API_KEY" \
-F "type=url" \
-F "folder=articles" \
-F "url=https://example.com/article"

Batch URL Import

POST /api/documents/{partner}/{kb}/batch
Content-Type: application/json
curl -X POST https://knowledge.hidoba.com/api/documents/my-partner/my-kb/batch \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"folder": "articles",
"urls": [
"https://example.com/article-1",
"https://example.com/article-2"
],
"use_original_as_rewritten": false
}'
note

Maximum 1,000 URLs per batch request.

If use_original_as_rewritten is true, each URL is still digitized first, then the digitized content is saved as final rewritten content and embedded automatically.

Response

{
"summary": {
"total": 2,
"succeeded": 2,
"failed": 0
},
"results": [
{
"url": "https://example.com/article-1",
"status": "success",
"document_id": "a1b2c3d4-e5f6-..."
},
{
"url": "https://example.com/article-2",
"status": "success",
"document_id": "f7g8h9i0-j1k2-..."
}
]
}

Create Empty Document

POST /api/documents/{partner}/{kb}/empty
Content-Type: multipart/form-data

Creates a document with no content, for manual content editing.

ParameterTypeDefaultDescription
nameStringDocument name. Required.
folderStringTarget folder name. Required.
typeStringfile or url. Required.
urlStringURL (if type is url).

Rename Document

PUT /api/documents/{partner}/{kb}/{doc_id}/name

Send name as a form parameter.

Update Document Type

PUT /api/documents/{partner}/{kb}/{doc_id}/type

Send type as a form parameter. Valid values are file and url.

Update Document URL

PUT /api/documents/{partner}/{kb}/{doc_id}/url

Send url as a form parameter.

Delete Document

DELETE /api/documents/{partner}/{kb}/{doc_id}

Deletion is allowed by default even if a document is being processed. If active work or vector cleanup still blocks final deletion, the response status is delete_pending and includes pending queue/vector cleanup details. Pass force=false to return 409 instead when active processing would block deletion.

curl -X DELETE "https://knowledge.hidoba.com/api/documents/my-partner/my-kb/DOC_ID?force=false" \
-H "X-API-Key: YOUR_API_KEY"

Document Content

Get Content

GET /api/documents/{partner}/{kb}/{doc_id}/content/{type}

Where {type} is one of: original, digitized, rewritten, draft.

Response

{
"content": "# Document Title\n\nProcessed document content..."
}

Update Content

PUT /api/documents/{partner}/{kb}/{doc_id}/content/{type}

Send content as a form parameter. For updates, {type} is one of: original, digitized, rewritten.

When {type} is rewritten, existing vectors for that document are cleaned up and a fresh embedding job is queued automatically.

Upload Content as File

POST /api/documents/{partner}/{kb}/{doc_id}/content/{type}
Content-Type: multipart/form-data

For uploads, {type} is one of: original, digitized, rewritten.

Upload the content in the file multipart field.

When {type} is rewritten, existing vectors for that document are cleaned up and a fresh embedding job is queued automatically.

Download Document File

GET /api/documents/{partner}/{kb}/{doc_id}/download/{type}

Where {type} is one of: original, digitized, rewritten, draft.

Download Rewritten Bundle

GET /api/documents/{partner}/{kb}/rewritten-bundle

Returns a ZIP archive of all rewritten documents in the knowledge base. The archive contains documents_info.json and one {doc_id}.md file per rewritten document.

Processing

Queue Document for Processing

POST /api/queue/process
ParameterTypeDefaultDescription
documentObjectDocument object (JSON body).
actionStringdigitizeProcessing action: digitize or rewrite.
partnerStringPartner name.
kbStringKnowledge base name.
content_typeStringautoauto, article, youtube, or book.
person_nameStringAuthor/speaker name for the rewrite prompt.

Send document in the JSON body. Send action, partner, kb, content_type, and person_name as query parameters.

Rewriting produces final rewritten content. When that content is saved, embedding is queued automatically.

Content Type Auto-Detection

When content_type is set to auto:

  • YouTube URLs and audio files → youtube template
  • PDF, EPUB, and Word documents → book template
  • Everything else → article template

Bulk Rewrite (Folder)

POST /api/bulk/rewrite/folder/{partner}/{kb}/{folder}
ParameterTypeDefaultDescription
skip_rewrittenBooleantrueSkip documents that already have rewritten content.
content_typeStringautoContent type template to use.
person_nameStringAuthor/speaker name.

These options are query parameters.

Bulk Rewrite (Knowledge Base)

POST /api/bulk/rewrite/kb/{partner}/{kb}
ParameterTypeDefaultDescription
skip_rewrittenBooleantrueSkip documents that already have rewritten content.
content_typeStringautoContent type template to use.
person_nameStringAuthor/speaker name.

These options are query parameters.

Embedding

Embedding is automatic. You do not need to call an endpoint to start embedding for a knowledge base.

The embedding worker indexes final rewritten content only. A document becomes eligible for embedding when file_rewritten is set. Use the document fields and aggregate KB status below to monitor progress.

Get Embedding Status

GET /api/embedding/{partner}/{kb}

Returns aggregate embedding status for the knowledge base. This is a read/status endpoint; it does not start embedding.

Response

{
"last_successful_update_time": "2025-01-15T10:30:00Z",
"last_update_time": "2025-01-15T10:30:00Z",
"last_update_status": "success",
"last_update_details": {
"chunk_count": 35,
"point_count": 35
},
"last_successful_details": {
"chunk_count": 35,
"point_count": 35
},
"knowledge_base_id": "42",
"embedding_profile_id": 1,
"embedding_profile_name": "default",
"eligible_document_count": 35,
"pending_document_count": 0,
"failed_document_count": 0,
"embedded_document_count": 35,
"last_error": null
}

last_update_status is in_progress, success, fail, or null. Per-document embedding state is available on document objects.

Document Model

A document returned from the API includes the following fields:

FieldTypeDescription
idStringUUID identifier.
nameStringDocument name.
folderStringFolder name.
typeStringfile or url.
urlStringSource URL (if type is url).
file_originalStringOriginal uploaded filename.
file_digitizedStringDigitized content filename.
file_rewritten_draftStringDraft rewrite filename.
file_rewrittenStringFinal rewrite filename.
user_emailStringEmail of the uploading user.
in_queuesArrayActive processing queues (e.g., ["digitize"], ["rewrite"], ["embedding"]).
expert_nameStringContent author/speaker.
auto_rewriteBooleanWhether auto-rewrite is enabled.
model_tierStringstandard or economy.
rewrite_modelStringLLM model used for rewriting.
rewrite_input_tokensIntegerInput tokens consumed.
rewrite_output_tokensIntegerOutput tokens generated.
rewrite_completed_atStringISO timestamp of rewrite completion.
processing_errorStringError message if digitization or rewriting failed.
embedding_statusStringPer-document embedding state: pending, in_progress, success, failed, or null.
is_embeddedBooleanBackward-compatible flag; true when embedding_status is success.
embedding_errorStringError message if embedding failed.
embedded_atStringISO timestamp of the latest successful embedding.
embedding_chunk_countIntegerNumber of chunks embedded for this document.
deletion_requested_atStringISO timestamp when deletion has been requested but is still waiting for processing/vector cleanup.
digitized_char_countIntegerCharacter count of digitized content.
draft_rewrite_char_countIntegerCharacter count of draft rewrite.
final_rewrite_char_countIntegerCharacter count of final rewrite.

Error Responses

Most errors use FastAPI's standard JSON shape with a detail field. The exact message varies by endpoint.

Unauthorized (401)

{
"detail": "Invalid API key"
}

Forbidden (403)

{
"detail": "Access denied to partner 'my-partner'"
}

Not Found (404)

{
"detail": "Knowledge base not found"
}

Rate Limited (429)

Rate-limit responses are produced by the shared SlowAPI rate-limit handler.