KNOWLEDGE BASE API - Fails on DOCS
https://docs.voiceflow.com/reference/post_v1-knowledge-base-docs-upload-url
I was trying to upload some docs from my webpage dashboard to Voiceflow KB via API. It works fine with PDFs, but fails on DOCS.
Uploading DOCX manually from voiceflow KB dashboard works fine. Wandering, if that will be fixed soon. Thanks!
As per KB API docs -
Features:
Supports multiple document types, including URLs, PDFs, text files, DOCX files, and tabular data.
Features:
Supports multiple document types, including URLs, PDFs, text files, DOCX files, and tabular data.

1 Reply
import { configuration } from '@/constants/config';
import logger from '@/services/logger.service';
const VOICEFLOW_UPLOAD_PATH = '/v1/knowledge-base/docs/upload';
const DEFAULT_VOICEFLOW_CHUNK_SIZE = 1000;
export interface UploadVoiceflowDocumentParams {
fileUrl: string;
fileName: string;
zorId: string;
maxChunkSize?: number;
}
export const uploadDocumentToVoiceflow = async ({
fileUrl,
fileName,
zorId,
maxChunkSize = DEFAULT_VOICEFLOW_CHUNK_SIZE,
}: UploadVoiceflowDocumentParams): Promise<boolean> => {
const apiKey = import.meta.env.VITE_VOICEFLOW_API_KEY;
if (!apiKey) {
logger.warn('Voiceflow API key is not configured. Skipping upload.', {
fileName,
zorId,
});
return false;
}
if (!zorId) {
logger.warn(
'Voiceflow upload skipped due to missing organization ID (zorId).',
{
fileName,
}
);
return false;
}
const uploadUrl = `${configuration.VOICEFLOW_API_URL}${VOICEFLOW_UPLOAD_PATH}?maxChunkSize=${maxChunkSize}`;
try {
const response = await fetch(uploadUrl, {
method: 'POST',
headers: {
Authorization: apiKey,
accept: 'application/json',
'content-type': 'application/json; charset=utf-8',
},
body: JSON.stringify({
data: {
type: 'url',
name: fileName,
url: fileUrl,
metadata: {
zorId,
DocumentName: fileName,
},
},
}),
});
if (!response.ok) {
const errorText = await response.text();
logger.error('Voiceflow upload failed', new Error(errorText), {
status: response.status,
fileName,
zorId,
});
return false;
}
return true;
} catch (error) {
logger.error('Unexpected error uploading document to Voiceflow', error as Error, {
fileName,
zorId,
});
return false;
}
};
import { configuration } from '@/constants/config';
import logger from '@/services/logger.service';
const VOICEFLOW_UPLOAD_PATH = '/v1/knowledge-base/docs/upload';
const DEFAULT_VOICEFLOW_CHUNK_SIZE = 1000;
export interface UploadVoiceflowDocumentParams {
fileUrl: string;
fileName: string;
zorId: string;
maxChunkSize?: number;
}
export const uploadDocumentToVoiceflow = async ({
fileUrl,
fileName,
zorId,
maxChunkSize = DEFAULT_VOICEFLOW_CHUNK_SIZE,
}: UploadVoiceflowDocumentParams): Promise<boolean> => {
const apiKey = import.meta.env.VITE_VOICEFLOW_API_KEY;
if (!apiKey) {
logger.warn('Voiceflow API key is not configured. Skipping upload.', {
fileName,
zorId,
});
return false;
}
if (!zorId) {
logger.warn(
'Voiceflow upload skipped due to missing organization ID (zorId).',
{
fileName,
}
);
return false;
}
const uploadUrl = `${configuration.VOICEFLOW_API_URL}${VOICEFLOW_UPLOAD_PATH}?maxChunkSize=${maxChunkSize}`;
try {
const response = await fetch(uploadUrl, {
method: 'POST',
headers: {
Authorization: apiKey,
accept: 'application/json',
'content-type': 'application/json; charset=utf-8',
},
body: JSON.stringify({
data: {
type: 'url',
name: fileName,
url: fileUrl,
metadata: {
zorId,
DocumentName: fileName,
},
},
}),
});
if (!response.ok) {
const errorText = await response.text();
logger.error('Voiceflow upload failed', new Error(errorText), {
status: response.status,
fileName,
zorId,
});
return false;
}
return true;
} catch (error) {
logger.error('Unexpected error uploading document to Voiceflow', error as Error, {
fileName,
zorId,
});
return false;
}
};