curl --request POST \
--url https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"content": "<string>",
"external_id": "<string>",
"title": "<string>",
"url": "<string>"
}
]
}
'import requests
url = "https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert"
payload = { "items": [
{
"content": "<string>",
"external_id": "<string>",
"title": "<string>",
"url": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
content: '<string>',
external_id: '<string>',
title: '<string>',
url: '<string>'
}
]
})
};
fetch('https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert', 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.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert",
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([
'items' => [
[
'content' => '<string>',
'external_id' => '<string>',
'title' => '<string>',
'url' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert"
payload := strings.NewReader("{\n \"items\": [\n {\n \"content\": \"<string>\",\n \"external_id\": \"<string>\",\n \"title\": \"<string>\",\n \"url\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"content\": \"<string>\",\n \"external_id\": \"<string>\",\n \"title\": \"<string>\",\n \"url\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"content\": \"<string>\",\n \"external_id\": \"<string>\",\n \"title\": \"<string>\",\n \"url\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"external_id": "<string>",
"status": "created",
"document_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>",
"details": [
{}
]
}
}
]
}Create or update documents
Up to 100 documents and 8 MB in one call (larger documents fit fewer: send the rest in another call), each as the single call does, with a result for each in request order: created, updated, unchanged, or failed with the error alone that document would have had. One that fails leaves the rest written. Each counts against your rate limit. A document is identified by your external_id, unique in its knowledge base (titles may repeat). Its words are stored and indexed in the background: the previous version keeps answering until the new one is ready. The same words, title and link again are unchanged: nothing is written or indexed again. A 503 that says the document was saved but its indexing could not be started: send it again, and indexing is asked for again. Writes go into a knowledge base this API made or one that takes uploads in the app (writable); a connector’s is a 409. A digital worker’s own key can’t write.
curl --request POST \
--url https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"content": "<string>",
"external_id": "<string>",
"title": "<string>",
"url": "<string>"
}
]
}
'import requests
url = "https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert"
payload = { "items": [
{
"content": "<string>",
"external_id": "<string>",
"title": "<string>",
"url": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
content: '<string>',
external_id: '<string>',
title: '<string>',
url: '<string>'
}
]
})
};
fetch('https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert', 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.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert",
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([
'items' => [
[
'content' => '<string>',
'external_id' => '<string>',
'title' => '<string>',
'url' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert"
payload := strings.NewReader("{\n \"items\": [\n {\n \"content\": \"<string>\",\n \"external_id\": \"<string>\",\n \"title\": \"<string>\",\n \"url\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"content\": \"<string>\",\n \"external_id\": \"<string>\",\n \"title\": \"<string>\",\n \"url\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/knowledge_bases/{knowledge_base_id}/documents/batch/upsert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"content\": \"<string>\",\n \"external_id\": \"<string>\",\n \"title\": \"<string>\",\n \"url\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"external_id": "<string>",
"status": "created",
"document_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>",
"details": [
{}
]
}
}
]
}Authorizations
An API key, sent as Authorization: Bearer stfy_live_…. See Authentication for how to get one and which scopes it needs.
Body
Was this page helpful?