Skip to main content
POST
/
public
/
v1
/
knowledge-base
/
documents
/
file
Upload document file
curl --request POST \
  --url https://api.callin.io/api/public/v1/knowledge-base/documents/file \
  --header 'Content-Type: multipart/form-data' \
  --header 'x-api-key: <api-key>' \
  --form 'groupName=<string>' \
  --form 'files=<string>' \
  --form files.items='@example-file'
import requests

url = "https://api.callin.io/api/public/v1/knowledge-base/documents/file"

files = { "files.items": ("example-file", open("example-file", "rb")) }
payload = {
    "groupName": "<string>",
    "files": "<string>"
}
headers = {"x-api-key": "<api-key>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.text)
const form = new FormData();
form.append('groupName', '<string>');
form.append('files', '<string>');
form.append('files.items', '{
  "fileName": "example-file"
}');

const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};

options.body = form;

fetch('https://api.callin.io/api/public/v1/knowledge-base/documents/file', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.callin.io/api/public/v1/knowledge-base/documents/file",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"groupName\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--",
  CURLOPT_HTTPHEADER => [
    "Content-Type: multipart/form-data",
    "x-api-key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.callin.io/api/public/v1/knowledge-base/documents/file"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"groupName\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<api-key>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.callin.io/api/public/v1/knowledge-base/documents/file")
  .header("x-api-key", "<api-key>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"groupName\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.callin.io/api/public/v1/knowledge-base/documents/file")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"groupName\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"files.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n  \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "data": {
    "groupId": "<string>",
    "name": "<string>",
    "documents": [
      {
        "documentId": "<string>",
        "type": "file",
        "name": "<string>",
        "details": {
          "fileUrl": "<string>",
          "fileType": "<string>",
          "fileSize": 123
        },
        "metadata": {
          "createdAt": "2023-11-07T05:31:56Z",
          "createdBy": {
            "userId": "<string>",
            "userEmail": "<string>"
          }
        }
      }
    ],
    "metadata": {
      "allowedMb": 123,
      "usedMb": 123,
      "usedMbAfter": 123,
      "remainingMbAfter": 123
    }
  }
}
{
  "success": false,
  "error": {
    "code": "<string>",
    "message": "<string>",
    "status": 123,
    "fields": [
      {}
    ]
  }
}

Authorizations

x-api-key
string
header
required

Send your Callin API key in the x-api-key header.

Body

multipart/form-data

Upload one or more files into a knowledge group (multipart/form-data). The group is created or matched by groupName.

groupName
string
required

Name of the knowledge group to create or add these documents to.

files
file[]
required

Files to upload. Each file must be PDF (.pdf), Word (.docx), or TSX (.tsx). Maximum 5 MB per file.

Minimum array length: 1

One file: PDF, DOCX, or TSX; max 5 MB.

Response

Document created

After uploading files: new or updated group, created documents, and storage usage (MB).

success
boolean
Example:

true

data
object

The details of the document created