VocalDocscontracts 1.65.0

Upload a Document

POST /v1/knowledge-bases/{knowledge_base_id}/documents

PropertyValue
Operationupload_knowledge_document
GroupKnowledge bases
Scopeknowledge:write
Route classcontrol
IdempotencyIdempotency-Key accepted: a retry with the same key replays the first answer
AuditAudited knowledge.document.upload (mutation)
Released in1.53.0
Phase 0 hostServed (the hosted api pins 1.65.0)

Uploads a file to an upload Source as multipart/form-data (1.53.0). The api checks the parts (KnowledgeDocumentIssueCode), encrypts the file under the data key of the Organization, stores it under the knowledge/ prefix, creates or revises the Document pending and starts an Ingestion run with cause manual, all before it answers. A new external_ref answers 201 with the new Document; one the Source holds answers 200 with the Document, revised, or unchanged when the content is the same. From 1.54.0: a cell with no object storage refuses every upload with 422 capability_not_available.

Request

Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the knowledge:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.

curl -X POST "$VOCAL_API/v1/knowledge-bases/kb_.../documents" \
  -H "Authorization: Bearer $VOCAL_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F "source_id=ksrc_..." \
  -F "file=@<file>"

Parameters

NameInTypeRequiredDescription
knowledge_base_idpathKnowledgeBaseIdyesThe id of a Knowledge base: kb_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log.
idempotency-keyheaderstringnoA client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response.

Request body

Content type multipart/form-data, required: KnowledgeDocumentUploadRequest.

FieldTypeRequiredDescription
external_refstringnoThe reference to revise; the file name when omitted.
filestring (binary)yesThe file part: its bytes, at most 25 MiB (a target), with a filename and a Content-Type among KnowledgeMediaType.
source_idKnowledgeSourceIdyes
tagsarray of DocumentTagnoSent as repeated tags parts.
titlestringno

Responses

StatusContent typeShapeError codes
200application/jsonKnowledgeDocument
201application/jsonKnowledgeDocument
400application/jsonErrorEnvelopeinvalid_request
401application/jsonErrorEnvelopeunauthenticated
403application/jsonErrorEnvelopeforbidden, org_suspended
404application/jsonErrorEnvelopenot_found
409application/jsonErrorEnvelopeknowledge_base_archived, idempotency_in_progress, idempotency_key_reused
422application/jsonErrorEnvelopevalidation_failed, capability_not_available
429application/jsonErrorEnveloperate_limited
500application/jsonErrorEnvelopeinternal_error

Fields of the 200 answer

The shape is KnowledgeDocument.

FieldTypeRequiredDescription
byte_sizeinteger or nullyes
chunk_countintegeryes
chunker_versionstring or nullyes
classificationKnowledgeClassification or nullyes
created_atTimestampyes
embedding_spaceEmbeddingSpace or nullyes
entity_countsarray of KnowledgeEntityCountyes
error_codeIngestionErrorCode or nullyesSet when failed.
external_refstring or nullyesThe file name, URL or vendor reference the Source knows the Document by. The content class names: null unless the read names include=names, and null in the answer of a write (1.53.0, second part).
idKnowledgeDocumentIdyes
indexed_atTimestamp or nullyes
knowledge_base_idKnowledgeBaseIdyes
last_ingestion_run_idIngestionRunId or nullyes
media_typeKnowledgeMediaType or nullyes
object"knowledge_document"yes
page_countinteger or nullyes
parser_versionstring or nullyes
purged_atTimestamp or nullyes
quarantine_expires_atTimestamp or nullyesWhen the parsed text held for review is deleted, 14 days after the quarantine (a target); null otherwise.
quarantined_atTimestamp or nullyes
review_statusKnowledgeReviewStatusyes
revisionintegeryesCounts writes to the Document; returned as the ETag and required in If-Match. Not the number of content revisions.
source_idKnowledgeSourceIdyes
statusKnowledgeDocumentStatusyes
tagsarray of DocumentTagyes
titlestring or nullyesThe title the upload or the parse stage gave, or null when it has none. The content class names: null unless the read names include=names, and null in the answer of a write (1.53.0, second part).
updated_atTimestampyes