curl --request POST \
--url https://api.getdecisional.ai/api/v1/data-sources \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form 'data={"name":"Annual Report 2023","type":"file","notes":{"category":"financial"},"knowledge_engine_id":"kng_abc123xyz789"}'import requests
url = "https://api.getdecisional.ai/api/v1/data-sources"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "data": "{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}" }
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<binary file content>');
form.append('data', '{"name":"Annual Report 2023","type":"file","notes":{"category":"financial"},"knowledge_engine_id":"kng_abc123xyz789"}');
const options = {method: 'POST', headers: {Authorization: 'Basic <encoded-value>'}};
options.body = form;
fetch('https://api.getdecisional.ai/api/v1/data-sources', 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.getdecisional.ai/api/v1/data-sources",
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=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: multipart/form-data"
],
]);
$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.getdecisional.ai/api/v1/data-sources"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.getdecisional.ai/api/v1/data-sources")
.header("Authorization", "Basic <encoded-value>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getdecisional.ai/api/v1/data-sources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": "ds_abc123xyz789",
"name": "Annual Report 2023",
"type": "file",
"status": "processed",
"notes": {
"category": "financial"
},
"knowledge_engine_id": "kng_abc123xyz789",
"created_at": 1679644800
}{
"error": "Invalid knowledge engine name: exceeds maximum length of 50 characters"
}{
"error": "Duplicate file"
}Create Data Source
Creates a new data source and associates it with a knowledge engine
curl --request POST \
--url https://api.getdecisional.ai/api/v1/data-sources \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form 'data={"name":"Annual Report 2023","type":"file","notes":{"category":"financial"},"knowledge_engine_id":"kng_abc123xyz789"}'import requests
url = "https://api.getdecisional.ai/api/v1/data-sources"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "data": "{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}" }
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<binary file content>');
form.append('data', '{"name":"Annual Report 2023","type":"file","notes":{"category":"financial"},"knowledge_engine_id":"kng_abc123xyz789"}');
const options = {method: 'POST', headers: {Authorization: 'Basic <encoded-value>'}};
options.body = form;
fetch('https://api.getdecisional.ai/api/v1/data-sources', 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.getdecisional.ai/api/v1/data-sources",
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=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: multipart/form-data"
],
]);
$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.getdecisional.ai/api/v1/data-sources"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.getdecisional.ai/api/v1/data-sources")
.header("Authorization", "Basic <encoded-value>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getdecisional.ai/api/v1/data-sources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary file content>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": "ds_abc123xyz789",
"name": "Annual Report 2023",
"type": "file",
"status": "processed",
"notes": {
"category": "financial"
},
"knowledge_engine_id": "kng_abc123xyz789",
"created_at": 1679644800
}{
"error": "Invalid knowledge engine name: exceeds maximum length of 50 characters"
}{
"error": "Duplicate file"
}Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Body
The file to upload
JSON string containing data source metadata.
Example:
{ "name": "Annual Report 2023", "type": "file", "knowledge_engine_id": "kng_abc123xyz789" }
"{\"name\":\"Annual Report 2023\",\"type\":\"file\",\"notes\":{\"category\":\"financial\"},\"knowledge_engine_id\":\"kng_abc123xyz789\"}"
Response
Data source created successfully
Unique identifier for the data source
"ds_abc123xyz789"
Name of the data source
"Annual Report 2023"
Type of the data source
file, ticket "file"
Current status of the data source
processing, processed "processed"
Custom attributes and fields
{ "category": "financial" }
ID of the knowledge engine this data source belongs to
"kng_abc123xyz789"
Unix timestamp when this entity was created
1679644800