SidetalkGuides
Sidetalk website ↗Open dashboard

Conversational File Attachment API

Related documentation


Purpose

This API uploads document files and attaches them to a conversation session.
Uploaded files are parsed and converted to text. When chat requests use the same session_id, the AI can reference the file contents as needed.
If session_id is absent, the server issues a new session and attaches the file to it.

1. Session File Upload API


URL



HTTP method

Plain Text
POST

Headers

HeadersValueDescription
AuthorizationBearer <api_key>Use the API key provided in the Sidetalk dashboard.
For multipart/form-data requests, let the browser or HTTP client set Content-Type and the boundary automatically.

Body

ParameterTypeRequiredDescription
fileFileYesThe document file to upload.
session_idStringNoThe session ID to attach the file to. The server issues one if absent.
sessionIdStringNoAn alias for session_id.

Supported file formats

ExtensionDescription
pdfPDF document
xlsxExcel document
xlsExcel document
csvCSV file
txtText file
docxWord document
docWord document
pptxPowerPoint document
pptPowerPoint document

File size limits

File formatLimit
txt, csv3MB or less
pdf, xlsx, xls, docx, doc, pptx, ppt20MB or less

session_id policy

SituationBehavior
No session_idThe server creates a new session_id and attaches the file to it.
session_id provided and validAttaches the file to that session.
session_id provided with an invalid formatReturns an error.
session_id provided but does not existReturns an error.
The recommended approach is:
  1. If you have session_id from a chat API response, include it with the file upload.
  2. You can also upload a file first without session_id.
  3. In that case, use session_id from the upload response in subsequent chat requests.

Example request


Upload without session_id

JSON
curl -X POST https://api.sidetalk.ai/v1/chat/files \
  -H "Authorization: Bearer ${API_KEY}" \
  -F "file=@관리자매뉴얼.pdf"

Upload to an existing session

JSON
curl -X POST https://api.sidetalk.ai/v1/chat/files \
  -H "Authorization: Bearer ${API_KEY}" \
  -F "session_id=943f15db-3984-4f21-ad64-f0115839c3a6" \
  -F "file=@관리자매뉴얼.pdf"


Example success response

JSON
{
  "success": true,
  "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
  "result": {
    "file_id": "file_9e17c4df-5b4a-48c8-8e8f-3de7c6e9c5a1",
    "id": 15,
    "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
    "file_name": "관리자매뉴얼.pdf",
    "content_chars": 9527,
    "summary_chars": 247
  }
}

Response fields

FieldTypeDescription
successBooleanWhether the request succeeded.
session_idStringThe session ID the file is attached to, used for subsequent chat requests.
resultObjectUploaded file information.
result.file_idStringThe unique file ID, which can be used for deletion.
result.idNumberThe internal file ID, included for compatibility.
result.session_idStringThe session ID the file is attached to.
result.file_nameStringThe uploaded file name.
result.content_charsNumberThe number of body text characters extracted from the file.
result.summary_charsNumberThe number of characters in the file summary.

2. Chat flow after file upload

Call the chat API with session_id from the upload response.

Step 1. Upload the file

JSON
curl -X POST https://api.sidetalk.ai/v1/chat/files \
  -H "Authorization: Bearer ${API_KEY}" \
  -F "file=@청소기매뉴얼.pdf"
Response:
JSON
{
  "success": true,
  "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
  "result": {
    "file_id": "file_9e17c4df-5b4a-48c8-8e8f-3de7c6e9c5a1",
    "id": 15,
    "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
    "file_name": "청소기매뉴얼.pdf",
    "content_chars": 9527,
    "summary_chars": 247
  }
}

Step 2. Ask a question with the same session_id

JSON
curl -X POST https://api.sidetalk.ai/v2/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  -d '{
    "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
    "message": "먼지통 청소 방법 알려줘.",
    "stream": false
  }'
Response:
JSON
{
  "success": true,
  "object": "chat.completion",
  "model": "sidetalk",
  "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
  "chat_log_uuid": "2b9cc8fb-3cc6-4d40-aef6-d44af3d074f3",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "먼지통 청소 방법은 다음과 같습니다..."
      }
    }
  ]
}

3. File List API

Retrieve the files attached to the current session.

URL

Plain Text
https://api.sidetalk.ai/v1/chat/files

HTTP method

Plain Text
GET

Headers

HeadersValueDescription
AuthorizationBearer <api_key>Use the API key provided in the Sidetalk dashboard.

Query Parameters

ParameterTypeRequiredDescription
session_idStringYesThe session ID to query.
sessionIdStringNoAn alias for session_id.

Example request

JSON
curl -X GET "https://api.sidetalk.ai/v1/chat/files?session_id=943f15db-3984-4f21-ad64-f0115839c3a6" \
  -H "Authorization: Bearer ${API_KEY}"

Example response

JSON
{
  "success": true,
  "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
  "files": [
    {
      "file_id": "file_9e17c4df-5b4a-48c8-8e8f-3de7c6e9c5a1",
      "id": 15,
      "file_name": "청소기매뉴얼.pdf",
      "mime_type": "application/pdf",
      "file_size": 3623117,
      "content_chars": 9527,
      "summary_chars": 247,
      "created_at": "2026-07-14T10:20:30.000Z"
    }
  ]
}


4. File Deletion API

Delete files attached to the current session.

URL

Plain Text
https://api.sidetalk.ai/v1/chat/files

HTTP method

Plain Text
DELETE

Headers

HeadersValueDescription
Content-Typeapplication/jsonIndicates that the request body is JSON.
AuthorizationBearer <api_key>Use the API key provided in the Sidetalk dashboard.

Body

ParameterTypeRequiredDescription
session_idStringYesThe session ID the file is attached to.
sessionIdStringNoAn alias for session_id.
file_idStringNoThe file ID to delete. If absent, deletes all files in the session.

Example request


Delete a specific file

JSON
curl -X DELETE https://api.sidetalk.ai/v1/chat/files \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  -d '{
    "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
    "file_id": "file_9e17c4df-5b4a-48c8-8e8f-3de7c6e9c5a1"
  }'

Delete all files in a session

JSON
curl -X DELETE https://api.sidetalk.ai/v1/chat/files \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  -d '{
    "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6"
  }'

Example response

JSON
{
  "success": true,
  "session_id": "943f15db-3984-4f21-ad64-f0115839c3a6",
  "deleted": 1
}

5. JavaScript examples


5-1. Upload a file

JavaScript
async function uploadFile(file, sessionId = "") {
  const formData = new FormData();
  formData.append("file", file);

  if (sessionId) {
    formData.append("session_id", sessionId);
  }

  const response = await fetch("https://api.sidetalk.ai/v1/chat/files", {
    method: "POST",
    headers: {
      "Authorization": "Bearer [API_KEY]"
    },
    body: formData
  });

  const data = await response.json();

  if (!response.ok || !data.success) {
    console.error("File Upload Error:", data.error || "Unknown error");
    return null;
  }

  return {
    sessionId: data.session_id,
    file: data.result
  };
}

5-2. Ask a question after uploading

JavaScript
async function askWithFile(file, question) {
  const uploadResult = await uploadFile(file);

  if (!uploadResult) {
    return null;
  }

  const response = await fetch("https://api.sidetalk.ai/v2/chat/completions", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer [API_KEY]"
    },
    body: JSON.stringify({
      session_id: uploadResult.sessionId,
      message: question,
      stream: false
    })
  });

  const data = await response.json();

  if (!response.ok) {
    console.error("Chat Error:", data.error?.message || "Unknown error");
    return null;
  }

  return {
    sessionId: data.session_id,
    file: uploadResult.file,
    answer: data.choices?.[0]?.message?.content || "",
    chatLogUuid: data.chat_log_uuid || ""
  };
}

5-3. Retrieve the file list

JavaScript
async function getSessionFiles(sessionId) {
  const response = await fetch(
    `https://api.sidetalk.ai/v1/chat/files?session_id=${encodeURIComponent(sessionId)}`,
    {
      method: "GET",
      headers: {
        "Authorization": "Bearer [API_KEY]"
      }
    }
  );

  const data = await response.json();

  if (!response.ok || !data.success) {
    console.error("File List Error:", data.error || "Unknown error");
    return [];
  }

  return data.files || [];
}

5-4. Delete a file

JavaScript
async function deleteSessionFile(sessionId, fileId = "") {
  const body = {
    session_id: sessionId
  };

  if (fileId) {
    body.file_id = fileId;
  }

  const response = await fetch("https://api.sidetalk.ai/v1/chat/files", {
    method: "DELETE",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer [API_KEY]"
    },
    body: JSON.stringify(body)
  });

  const data = await response.json();

  if (!response.ok || !data.success) {
    console.error("File Delete Error:", data.error || "Unknown error");
    return null;
  }

  return data;
}

6. Error responses

File upload API errors are returned in the following format.
JSON
{
  "success": false,
  "error": "Only txt, pdf, xlsx, xls, and csv files are allowed."
}

Main error cases

HTTP statuserrorDescription
400file is requiredFile is missing
400invalid_session_id_formatsession_id has an invalid format
404session_id_not_foundThe provided session_id does not exist for the current site
400Only txt, pdf, xlsx, xls, and csv files are allowed.Unsupported file format
400File size exceeds limit.File size limit exceeded
403Authentication errorAPI authentication failure
500server_errorAn internal server error occurred

7. Notes

  • The file upload API currently uses /v1/chat/files.
  • It can be used with the v2 chat API.
  • Pass session_id from the upload response to the v2 chat API.
  • If a file is uploaded without session_id, the server issues a new session.
  • Multiple files can be attached to the same session_id.
  • During chat, the AI decides whether to reference files based on the question and conversation flow.
  • The file itself is not stored long term. After parsing, only extracted text and summary information are stored in the session files table.
  • Use file_id for file-level operations such as deletion.