TypeScript SDK
import { Orchata } from '@orchata-ai/sdk';
const client = new Orchata({ apiKey: 'oai_your_api_key' });
const result = await client.documents.batchUpload({
spaceId: 'space_123',
documents: [
{ filename: 'doc1.md', content: '# Doc 1\n\nContent...' },
{ filename: 'doc2.md', content: '# Doc 2\n\nContent...' },
]
});
console.log(`Uploaded: ${result.totalSuccessful}, Failed: ${result.totalFailed}`);curl --request POST \
--url https://api.orchata.ai/api/documents/batch \
--header 'Content-Type: application/json' \
--header 'Oai-Api-Key: <api-key>' \
--data '
{
"spaceId": "space_123",
"documents": [
{
"filename": "doc1.md",
"content": "# Document Title\n\nContent here...",
"metadata": {}
}
]
}
'import requests
url = "https://api.orchata.ai/api/documents/batch"
payload = {
"spaceId": "space_123",
"documents": [
{
"filename": "doc1.md",
"content": "# Document Title
Content here...",
"metadata": {}
}
]
}
headers = {
"Oai-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Oai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
spaceId: 'space_123',
documents: [
{
filename: 'doc1.md',
content: '# Document Title\n\nContent here...',
metadata: {}
}
]
})
};
fetch('https://api.orchata.ai/api/documents/batch', 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.orchata.ai/api/documents/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'spaceId' => 'space_123',
'documents' => [
[
'filename' => 'doc1.md',
'content' => '# Document Title
Content here...',
'metadata' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Oai-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.orchata.ai/api/documents/batch"
payload := strings.NewReader("{\n \"spaceId\": \"space_123\",\n \"documents\": [\n {\n \"filename\": \"doc1.md\",\n \"content\": \"# Document Title\\n\\nContent here...\",\n \"metadata\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Oai-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.orchata.ai/api/documents/batch")
.header("Oai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"spaceId\": \"space_123\",\n \"documents\": [\n {\n \"filename\": \"doc1.md\",\n \"content\": \"# Document Title\\n\\nContent here...\",\n \"metadata\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orchata.ai/api/documents/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Oai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"spaceId\": \"space_123\",\n \"documents\": [\n {\n \"filename\": \"doc1.md\",\n \"content\": \"# Document Title\\n\\nContent here...\",\n \"metadata\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"successful": [
{
"filename": "<string>",
"documentId": "<string>",
"status": "<string>"
}
],
"failed": [
{
"filename": "<string>",
"error": "<string>"
}
],
"totalSuccessful": 123,
"totalFailed": 123
}Documents
Batch Upload Documents
Upload multiple documents to a space in a single request. Each document is processed independently. Maximum 100 documents per request.
POST
/
api
/
documents
/
batch
TypeScript SDK
import { Orchata } from '@orchata-ai/sdk';
const client = new Orchata({ apiKey: 'oai_your_api_key' });
const result = await client.documents.batchUpload({
spaceId: 'space_123',
documents: [
{ filename: 'doc1.md', content: '# Doc 1\n\nContent...' },
{ filename: 'doc2.md', content: '# Doc 2\n\nContent...' },
]
});
console.log(`Uploaded: ${result.totalSuccessful}, Failed: ${result.totalFailed}`);curl --request POST \
--url https://api.orchata.ai/api/documents/batch \
--header 'Content-Type: application/json' \
--header 'Oai-Api-Key: <api-key>' \
--data '
{
"spaceId": "space_123",
"documents": [
{
"filename": "doc1.md",
"content": "# Document Title\n\nContent here...",
"metadata": {}
}
]
}
'import requests
url = "https://api.orchata.ai/api/documents/batch"
payload = {
"spaceId": "space_123",
"documents": [
{
"filename": "doc1.md",
"content": "# Document Title
Content here...",
"metadata": {}
}
]
}
headers = {
"Oai-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Oai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
spaceId: 'space_123',
documents: [
{
filename: 'doc1.md',
content: '# Document Title\n\nContent here...',
metadata: {}
}
]
})
};
fetch('https://api.orchata.ai/api/documents/batch', 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.orchata.ai/api/documents/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'spaceId' => 'space_123',
'documents' => [
[
'filename' => 'doc1.md',
'content' => '# Document Title
Content here...',
'metadata' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Oai-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.orchata.ai/api/documents/batch"
payload := strings.NewReader("{\n \"spaceId\": \"space_123\",\n \"documents\": [\n {\n \"filename\": \"doc1.md\",\n \"content\": \"# Document Title\\n\\nContent here...\",\n \"metadata\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Oai-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.orchata.ai/api/documents/batch")
.header("Oai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"spaceId\": \"space_123\",\n \"documents\": [\n {\n \"filename\": \"doc1.md\",\n \"content\": \"# Document Title\\n\\nContent here...\",\n \"metadata\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orchata.ai/api/documents/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Oai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"spaceId\": \"space_123\",\n \"documents\": [\n {\n \"filename\": \"doc1.md\",\n \"content\": \"# Document Title\\n\\nContent here...\",\n \"metadata\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"successful": [
{
"filename": "<string>",
"documentId": "<string>",
"status": "<string>"
}
],
"failed": [
{
"filename": "<string>",
"error": "<string>"
}
],
"totalSuccessful": 123,
"totalFailed": 123
}Authorizations
Body
application/json
Batch upload request
Was this page helpful?
⌘I