SidetalkGuides
Sidetalk website ↗Open dashboard

Training File Upload API

Purpose

This API uploads files for the chatbot’s knowledge base. TXT and PDF files are supported.

URL



HTTP method

POST

Headers

HeadersValueDescription
Content-Typemultipart/form-dataUse multipart/form-data to send the file.
AuthorizationBearer <api_key>Use the API key provided in Install in the Sidetalk dashboard.

Parameters (body)

Plain Text
multipart/form-data
Body parameters sent in this format.
ParameterTypeRequiredDescription
fileFileYesThe file object to upload. (Supported formats: .txt, .pdf) TXT: up to 3MB — PDF: up to 20MB

Example request

Bash
curl-XPOST"https://api.sidetalk.ai/v1/knowledge/file"\
-H"Authorization: Bearer ${API_KEY}"\
-F"file=@/path/to/document.pdf"

Response format

A JSON response indicates the file was successfully uploaded to storage.
Caution: this response only confirms file storage, not completion of knowledge processing. AI data training runs asynchronously in the background.

Response body (success)

JSON
{
	"success":true,
	"result": {
			"file_name":"manual.pdf",
			"file_size":1048576,
			"file_type":"application/pdf"
	  }
}

Response fields

1. Basic response
FieldTypeDescription
successBooleanWhether the request succeeded. (true)
2. Result data (result)
FieldTypeDescription
file_nameStringThe original name of the uploaded file.
file_sizeNumberThe uploaded file size in bytes.
file_typeStringThe uploaded file MIME type. (Example: application/pdf)

Example code (JavaScript)

Upload a file

JavaScript
async function uploadKnowledgeFile(fileObject) {
    const baseUrl = "https://api.sidetalk.ai/v1/knowledge/file";
    
    // FormData 생성
    const formData = new FormData();
    formData.append("file", fileObject); // <input type="file">에서 가져온 File 객체
  
    try {
        const response = await fetch(baseUrl, {
            method: "POST",
            headers: {
                "Authorization": "Bearer [API_KEY]"
                // Content-Type 헤더는 브라우저가 자동으로 multipart/form-data로 설정하므로 생략
            },
            body: formData
        });
        if (!response.ok) {
            const errorData = await response.json();
            console.error("Upload Failed:", errorData.error || 'Unknown error');
            return;
        }
        const result = await response.json();
        console.log("Upload Success:", result);
    } catch (error) {
        console.error("Error uploading file:", error);
    }
}

Error response

If processing fails, success: false is returned with an error message.

Response body

JSON
{
	"success":false,
	"error":"PDF file size must be 20MB or less."
}

Example error messages

  • No file uploaded or invalid format.: no file attached or an invalid format
  • Only txt and pdf files are allowed.: unsupported extension
  • Text file size must be 3MB or less.: TXT size limit exceeded
  • PDF file size must be 20MB or less.: PDF size limit exceeded
  • Invalid text file. Binary content detected.: binary data found in a text file
  • Invalid PDF file. Signature mismatch.: damaged or forged PDF header

Error response fields

FieldTypeDescription
successBooleanWhether the request failed. (false)
errorStringDetailed information about the error.