Manage documents within knowledge bases programmatically. Upload, update, retrieve metadata, and delete documents.
Required scope: knowledge-management
Prerequisite: Knowledge bases are created in the platform dashboard. See Knowledge Bases. This API manages documents within existing knowledge bases.
Document Upload Flow
Uploading a document requires three steps:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ 1. Request │ │ 2. Upload │ │ 3. Complete │ │ 4. Poll │
│ Upload Link │────▶│ File │────▶│ Upload │────▶│ Status │
└─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
POST /upload-link PUT to uploadUrl POST /upload-complete GET /documents
Returns: uploadUrl, Include headers Returns: status Check status
documentId, s3Key from response "uploaded" until "ready"
Request upload link — Call /knowledge/documents/upload-link to get a pre-signed upload URL
Upload file — PUT the file bytes to the returned uploadUrl with requiredHeaders
Complete upload — Call /knowledge/documents/upload-complete with the uploadId
Poll status — Query /knowledge/documents until status becomes ready or failed
Document Status Values
Status
Description
uploaded
Document uploaded, processing in progress
ready
Document processed successfully and available for retrieval
failed
Processing failed; check error details
Document Identifiers
Documents can be referenced using two identifiers:
Identifier
Description
s3Key
System-generated document path. Returned by upload endpoints; use for subsequent operations.
customDocumentId
Optional user-defined identifier. Use this to map documents to your external system IDs (e.g., CRM record ID, ticket ID). When provided during upload, you can use it instead of s3Key for update and delete operations.
Document Labels (label1 and label2)
Documents support two optional label fields for filtering and organization:
label1: Primary classification label
label2: Secondary classification label
Both labels use a namespace:value format to prevent high-cardinality values:
Label Requirements
Format: Must match namespace:value pattern (e.g., topic:billing, tier:premium)
Characters: Only lowercase letters, numbers, hyphens, and underscores ([a-z0-9_-])
Max length: 50 characters
Restrictions: Cannot contain UUIDs, timestamps, or ISO dates
Documents also support up to four free-form custom metadata fields for attaching arbitrary string data.
customMeta1 through customMeta4: Any string value, no format restriction
Custom Metadata Requirements
Format: Free-form string, any value is accepted
Max length: 500 characters per field
Not filterable: Custom metadata cannot be used as query filters (unlike label1/label2)
How Custom Metadata is Returned
Custom metadata fields are returned in every retrieved chunk alongside the document's text. Consumers can read them from result.metadata.minded_internal_meta1 through result.metadata.minded_internal_meta4 in raw retrieval responses.
Tip: Use custom metadata to attach source identifiers, version numbers, author names, or any context you want to surface alongside retrieved chunks — without the strict format requirements of filter labels.
Endpoints
Method
Endpoint
Description
POST
/knowledge/documents/upload-link
Get pre-signed URL for new document
POST
/knowledge/documents/upload-complete
Finalize new document upload
POST
/knowledge/documents/update/upload-link
Get pre-signed URL to update document
POST
/knowledge/documents/update/upload-complete
Finalize document update
PATCH
/knowledge/documents/metadata
Update document metadata only
GET
/knowledge/documents
Get document metadata
DELETE
/knowledge/documents
Delete a document
Create Upload Link
Generate a pre-signed URL to upload a new document.
Request Body
Field
Type
Required
Description
agentId
string
Yes
Agent UUID
environment
string
Yes
development, staging, or production
knowledgeBaseId
string
Yes
Knowledge base UUID
fileName
string
Yes
File name with extension (e.g., policy.pdf). If .zip, triggers batch import.
label1
string
No
Primary label in namespace:value format (e.g., dept:support)
label2
string
No
Secondary label in namespace:value format (e.g., lang:en)
customMeta1
string
No
Free-form custom metadata field 1 (max 500 chars)
customMeta2
string
No
Free-form custom metadata field 2 (max 500 chars)
customMeta3
string
No
Free-form custom metadata field 3 (max 500 chars)
customMeta4
string
No
Free-form custom metadata field 4 (max 500 chars)
customDocumentId
string
No
Your external identifier for this document
Request Example
Response
Response Fields
Field
Type
Description
uploadId
string
Unique identifier for this upload session
uploadUrl
string
Pre-signed URL for file upload (expires per expiresIn)
expiresIn
number
Seconds until uploadUrl expires
s3Key
string
Document path; use for subsequent operations
documentId
string
System-generated document UUID (or your customDocumentId if provided)
requiredHeaders
object
Headers to include when uploading to uploadUrl
Uploading the File
After receiving the response, upload your file:
Complete Upload
Finalize the upload and trigger document processing.
Request Body
Field
Type
Required
Description
uploadId
string
Yes
The uploadId from upload-link response
Request Example
Response (Document)
Response (ZIP Import)
When fileName ends with .zip, the response indicates a batch import job:
Response Fields
Field
Type
Description
type
string
document for single files, zip_import for archives