curl --request POST \
--url https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"content": "<string>",
"fileName": "<string>",
"knowledgeFolderId": "<string>",
"replaces": [
"<string>"
],
"size": 1,
"url": "<string>"
}
'import requests
url = "https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents"
payload = {
"name": "<string>",
"content": "<string>",
"fileName": "<string>",
"knowledgeFolderId": "<string>",
"replaces": ["<string>"],
"size": 1,
"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({
name: '<string>',
content: '<string>',
fileName: '<string>',
knowledgeFolderId: '<string>',
replaces: ['<string>'],
size: 1,
url: '<string>'
})
};
fetch('https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents', 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.example.com/v1/workspaces/{workspaceId}/knowledge-documents",
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([
'name' => '<string>',
'content' => '<string>',
'fileName' => '<string>',
'knowledgeFolderId' => '<string>',
'replaces' => [
'<string>'
],
'size' => 1,
'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.example.com/v1/workspaces/{workspaceId}/knowledge-documents"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"content\": \"<string>\",\n \"fileName\": \"<string>\",\n \"knowledgeFolderId\": \"<string>\",\n \"replaces\": [\n \"<string>\"\n ],\n \"size\": 1,\n \"url\": \"<string>\"\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.example.com/v1/workspaces/{workspaceId}/knowledge-documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"content\": \"<string>\",\n \"fileName\": \"<string>\",\n \"knowledgeFolderId\": \"<string>\",\n \"replaces\": [\n \"<string>\"\n ],\n \"size\": 1,\n \"url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents")
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 \"name\": \"<string>\",\n \"content\": \"<string>\",\n \"fileName\": \"<string>\",\n \"knowledgeFolderId\": \"<string>\",\n \"replaces\": [\n \"<string>\"\n ],\n \"size\": 1,\n \"url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"contentType": "<string>",
"createdAt": "<string>",
"createdById": "<string>",
"failureReason": "upload_expired",
"fileName": "<string>",
"fileSize": 123,
"id": "<string>",
"knowledgeFolderId": "<string>",
"name": "<string>",
"nbCitations": 123,
"pageId": "<string>",
"reviewStatus": "to_validate",
"status": "pending",
"summary": "<string>",
"type": "text",
"updatedAt": "<string>",
"updatedById": "<string>",
"url": "<string>",
"validatedAt": "<string>",
"validatedById": "<string>",
"workspace": {
"id": "<string>",
"name": "<string>",
"websiteUrl": "<string>"
},
"upload": {
"fields": {},
"url": "<string>"
}
}Create a knowledge document
Creates a knowledge document from exactly one source: text (content), a web page (url) or a file (fileName and size in bytes). The document starts in ‘pending’ status while it is processed. For a file, the response also carries upload, a presigned S3 POST form valid for 15 minutes: send a multipart POST to upload.url with every upload.fields entry first, then the file as the file field, which must come last. Processing starts once the file is in storage, with no further call. Files go up to 50 MB; accepted types: pdf, csv, txt, xlsx, docx. A 403 on a file means the V2 knowledge base or direct upload is not enabled for the workspace, or the user is a guest writer: only workspace owners and members manage knowledge base files. Refusals: 400 knowledge_document_upload_type_not_allowed, 400 knowledge_document_upload_too_large, 422 knowledge_document_replacement_invalid.
curl --request POST \
--url https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"content": "<string>",
"fileName": "<string>",
"knowledgeFolderId": "<string>",
"replaces": [
"<string>"
],
"size": 1,
"url": "<string>"
}
'import requests
url = "https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents"
payload = {
"name": "<string>",
"content": "<string>",
"fileName": "<string>",
"knowledgeFolderId": "<string>",
"replaces": ["<string>"],
"size": 1,
"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({
name: '<string>',
content: '<string>',
fileName: '<string>',
knowledgeFolderId: '<string>',
replaces: ['<string>'],
size: 1,
url: '<string>'
})
};
fetch('https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents', 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.example.com/v1/workspaces/{workspaceId}/knowledge-documents",
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([
'name' => '<string>',
'content' => '<string>',
'fileName' => '<string>',
'knowledgeFolderId' => '<string>',
'replaces' => [
'<string>'
],
'size' => 1,
'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.example.com/v1/workspaces/{workspaceId}/knowledge-documents"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"content\": \"<string>\",\n \"fileName\": \"<string>\",\n \"knowledgeFolderId\": \"<string>\",\n \"replaces\": [\n \"<string>\"\n ],\n \"size\": 1,\n \"url\": \"<string>\"\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.example.com/v1/workspaces/{workspaceId}/knowledge-documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"content\": \"<string>\",\n \"fileName\": \"<string>\",\n \"knowledgeFolderId\": \"<string>\",\n \"replaces\": [\n \"<string>\"\n ],\n \"size\": 1,\n \"url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/workspaces/{workspaceId}/knowledge-documents")
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 \"name\": \"<string>\",\n \"content\": \"<string>\",\n \"fileName\": \"<string>\",\n \"knowledgeFolderId\": \"<string>\",\n \"replaces\": [\n \"<string>\"\n ],\n \"size\": 1,\n \"url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"contentType": "<string>",
"createdAt": "<string>",
"createdById": "<string>",
"failureReason": "upload_expired",
"fileName": "<string>",
"fileSize": 123,
"id": "<string>",
"knowledgeFolderId": "<string>",
"name": "<string>",
"nbCitations": 123,
"pageId": "<string>",
"reviewStatus": "to_validate",
"status": "pending",
"summary": "<string>",
"type": "text",
"updatedAt": "<string>",
"updatedById": "<string>",
"url": "<string>",
"validatedAt": "<string>",
"validatedById": "<string>",
"workspace": {
"id": "<string>",
"name": "<string>",
"websiteUrl": "<string>"
},
"upload": {
"fields": {},
"url": "<string>"
}
}Authorizations
Body
Response
Default Response
Was this page helpful?