Upload Document
curl --request POST \
--url https://app.truvec.dev/api/v1/documents/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form raw_document=true \
--form chunking_strategy=recursive \
--form chunk_size=1000 \
--form chunk_overlap=200 \
--form 'separator=
' \
--form 'language=<string>' \
--form confirm_mixed_chunking=falseimport requests
url = "https://app.truvec.dev/api/v1/documents/upload"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"raw_document": "true",
"chunking_strategy": "recursive",
"chunk_size": "1000",
"chunk_overlap": "200",
"separator": "
",
"language": "<string>",
"confirm_mixed_chunking": "false"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('raw_document', 'true');
form.append('chunking_strategy', 'recursive');
form.append('chunk_size', '1000');
form.append('chunk_overlap', '200');
form.append('separator', '
');
form.append('language', '<string>');
form.append('confirm_mixed_chunking', 'false');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://app.truvec.dev/api/v1/documents/upload', 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://app.truvec.dev/api/v1/documents/upload",
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<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://app.truvec.dev/api/v1/documents/upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.truvec.dev/api/v1/documents/upload")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.truvec.dev/api/v1/documents/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": 123,
"project_id": 123,
"filename": "<string>",
"file_type": "<string>",
"file_size": 123,
"storage_path": "<string>",
"is_chunked": true,
"chunk_config": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}documents
Upload Document
Upload a document to a project. Supports .txt, .md, .pdf, .json, .csv, .docx files.
raw_document=True: the document is chunked with chunking_strategy
(see GET /chunking-strategies for the options).
If other documents of the same file type were chunked with different settings,
the upload is refused with 409 (code “mixed_chunking”) unless confirm_mixed_chunking is set.
raw_document=False: the file holds chunks the user already produced, as .json (array),
.jsonl (one chunk per line) or .csv (header row with a text column).
See the “Upload pre-chunked data” guide for the full format.
POST
/
api
/
v1
/
documents
/
upload
Upload Document
curl --request POST \
--url https://app.truvec.dev/api/v1/documents/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file' \
--form raw_document=true \
--form chunking_strategy=recursive \
--form chunk_size=1000 \
--form chunk_overlap=200 \
--form 'separator=
' \
--form 'language=<string>' \
--form confirm_mixed_chunking=falseimport requests
url = "https://app.truvec.dev/api/v1/documents/upload"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"raw_document": "true",
"chunking_strategy": "recursive",
"chunk_size": "1000",
"chunk_overlap": "200",
"separator": "
",
"language": "<string>",
"confirm_mixed_chunking": "false"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('raw_document', 'true');
form.append('chunking_strategy', 'recursive');
form.append('chunk_size', '1000');
form.append('chunk_overlap', '200');
form.append('separator', '
');
form.append('language', '<string>');
form.append('confirm_mixed_chunking', 'false');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://app.truvec.dev/api/v1/documents/upload', 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://app.truvec.dev/api/v1/documents/upload",
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<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://app.truvec.dev/api/v1/documents/upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.truvec.dev/api/v1/documents/upload")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.truvec.dev/api/v1/documents/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"raw_document\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunking_strategy\"\r\n\r\nrecursive\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_size\"\r\n\r\n1000\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chunk_overlap\"\r\n\r\n200\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"separator\"\r\n\r\n\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"language\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"confirm_mixed_chunking\"\r\n\r\nfalse\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": 123,
"project_id": 123,
"filename": "<string>",
"file_type": "<string>",
"file_size": 123,
"storage_path": "<string>",
"is_chunked": true,
"chunk_config": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Query Parameters
Body
multipart/form-data
Available options:
recursive, character, token, markdown, code, json Required range:
x >= 1Required range:
x >= 0Response
Successful Response