TypeScript SDK
import { Orchata } from '@orchata-ai/sdk';
const client = new Orchata({ apiKey: 'oai_your_api_key' });
// Add a new item to a to-do list without fetching first
const { document } = await client.documents.append('doc_123', {
spaceId: 'space_123',
content: '- [ ] New task added by AI'
});curl --request POST \
--url https://api.orchata.ai/api/documents/{id}/append \
--header 'Content-Type: application/json' \
--header 'Oai-Api-Key: <api-key>' \
--data '
{
"spaceId": "space_123",
"content": "\n- New item added",
"separator": "\n\n"
}
'import requests
url = "https://api.orchata.ai/api/documents/{id}/append"
payload = {
"spaceId": "space_123",
"content": "
- New item added",
"separator": "
"
}
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', content: '\n- New item added', separator: '\n\n'})
};
fetch('https://api.orchata.ai/api/documents/{id}/append', 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/{id}/append",
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',
'content' => '
- New item added',
'separator' => '
'
]),
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/{id}/append"
payload := strings.NewReader("{\n \"spaceId\": \"space_123\",\n \"content\": \"\\n- New item added\",\n \"separator\": \"\\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/{id}/append")
.header("Oai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"spaceId\": \"space_123\",\n \"content\": \"\\n- New item added\",\n \"separator\": \"\\n\\n\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orchata.ai/api/documents/{id}/append")
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 \"content\": \"\\n- New item added\",\n \"separator\": \"\\n\\n\"\n}"
response = http.request(request)
puts response.read_body{
"document": {
"id": "<string>",
"orgId": "<string>",
"spaceId": "<string>",
"filename": "<string>",
"mimeType": "<string>",
"fileSize": "<string>",
"storageUrl": "<string>",
"status": "<string>",
"errorMessage": "<string>",
"embeddingModel": "<string>",
"indexingType": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"metadata": "<unknown>"
}
}Documents
Append to Document
Append content to an existing document. Fetches current content, appends new content, and regenerates embeddings synchronously.
POST
/
api
/
documents
/
{id}
/
append
TypeScript SDK
import { Orchata } from '@orchata-ai/sdk';
const client = new Orchata({ apiKey: 'oai_your_api_key' });
// Add a new item to a to-do list without fetching first
const { document } = await client.documents.append('doc_123', {
spaceId: 'space_123',
content: '- [ ] New task added by AI'
});curl --request POST \
--url https://api.orchata.ai/api/documents/{id}/append \
--header 'Content-Type: application/json' \
--header 'Oai-Api-Key: <api-key>' \
--data '
{
"spaceId": "space_123",
"content": "\n- New item added",
"separator": "\n\n"
}
'import requests
url = "https://api.orchata.ai/api/documents/{id}/append"
payload = {
"spaceId": "space_123",
"content": "
- New item added",
"separator": "
"
}
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', content: '\n- New item added', separator: '\n\n'})
};
fetch('https://api.orchata.ai/api/documents/{id}/append', 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/{id}/append",
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',
'content' => '
- New item added',
'separator' => '
'
]),
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/{id}/append"
payload := strings.NewReader("{\n \"spaceId\": \"space_123\",\n \"content\": \"\\n- New item added\",\n \"separator\": \"\\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/{id}/append")
.header("Oai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"spaceId\": \"space_123\",\n \"content\": \"\\n- New item added\",\n \"separator\": \"\\n\\n\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orchata.ai/api/documents/{id}/append")
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 \"content\": \"\\n- New item added\",\n \"separator\": \"\\n\\n\"\n}"
response = http.request(request)
puts response.read_body{
"document": {
"id": "<string>",
"orgId": "<string>",
"spaceId": "<string>",
"filename": "<string>",
"mimeType": "<string>",
"fileSize": "<string>",
"storageUrl": "<string>",
"status": "<string>",
"errorMessage": "<string>",
"embeddingModel": "<string>",
"indexingType": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"metadata": "<unknown>"
}
}Authorizations
Path Parameters
Example:
"document_123"
Body
application/json
Content to append
The ID of the space containing the document
Example:
"space_123"
Content to append to the document (max 10MB)
Required string length:
1 - 10000000Example:
"\n- New item added"
Separator between existing and new content (default: '\n\n')
Example:
"\n\n"
Response
Content appended successfully
Show child attributes
Show child attributes
Was this page helpful?
⌘I