curl --request POST \
--url https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"mime_type": "<string>",
"text": "<string>",
"section": {
"prefix": "<string>",
"content": "<string>",
"sections": "<array>"
},
"source_url": "<string>",
"tags": [
"<string>"
],
"timestamp": 123,
"light_document_output": true,
"async": true,
"upsert_context": {}
}
'import requests
url = "https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}"
payload = {
"title": "<string>",
"mime_type": "<string>",
"text": "<string>",
"section": {
"prefix": "<string>",
"content": "<string>",
"sections": "<array>"
},
"source_url": "<string>",
"tags": ["<string>"],
"timestamp": 123,
"light_document_output": True,
"async": True,
"upsert_context": {}
}
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({
title: '<string>',
mime_type: '<string>',
text: '<string>',
section: {prefix: '<string>', content: '<string>', sections: '<array>'},
source_url: '<string>',
tags: ['<string>'],
timestamp: 123,
light_document_output: true,
async: true,
upsert_context: {}
})
};
fetch('https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}', 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://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}",
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([
'title' => '<string>',
'mime_type' => '<string>',
'text' => '<string>',
'section' => [
'prefix' => '<string>',
'content' => '<string>',
'sections' => '<array>'
],
'source_url' => '<string>',
'tags' => [
'<string>'
],
'timestamp' => 123,
'light_document_output' => true,
'async' => true,
'upsert_context' => [
]
]),
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://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"text\": \"<string>\",\n \"section\": {\n \"prefix\": \"<string>\",\n \"content\": \"<string>\",\n \"sections\": \"<array>\"\n },\n \"source_url\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"timestamp\": 123,\n \"light_document_output\": true,\n \"async\": true,\n \"upsert_context\": {}\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://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"text\": \"<string>\",\n \"section\": {\n \"prefix\": \"<string>\",\n \"content\": \"<string>\",\n \"sections\": \"<array>\"\n },\n \"source_url\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"timestamp\": 123,\n \"light_document_output\": true,\n \"async\": true,\n \"upsert_context\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}")
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 \"title\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"text\": \"<string>\",\n \"section\": {\n \"prefix\": \"<string>\",\n \"content\": \"<string>\",\n \"sections\": \"<array>\"\n },\n \"source_url\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"timestamp\": 123,\n \"light_document_output\": true,\n \"async\": true,\n \"upsert_context\": {}\n}"
response = http.request(request)
puts response.read_body{
"document": {
"data_source_id": "3b7d9f1e5a",
"created": 1625097600,
"document_id": "2c4a6e8d0f",
"title": "Customer Support FAQ",
"mime_type": "text/md",
"timestamp": 1625097600,
"tags": [
"customer_support",
"faq"
],
"parent_id": "1234f4567c",
"parents": [
"7b9d1f3e5a",
"2c4a6e8d0f"
],
"source_url": "https://example.com/support/article1",
"hash": "a1b2c3d4e5",
"text_size": 1024,
"chunk_count": 5,
"chunks": [
{
"chunk_id": "9f1d3b5a7c",
"text": "This is the first chunk of the document.",
"embedding": [
0.1,
0.2,
0.3,
0.4
]
},
{
"chunk_id": "4a2c6e8b0d",
"text": "This is the second chunk of the document.",
"embedding": [
0.5,
0.6,
0.7,
0.8
]
}
],
"text": "This is the full text content of the document. It contains multiple paragraphs and covers various topics related to customer support.",
"token_count": 150
},
"data_source": {
"id": 12345,
"createdAt": 1625097600,
"name": "Customer Knowledge Base",
"description": "Contains all customer-related information and FAQs",
"dustAPIProjectId": "5e9d8c7b6a",
"connectorId": "1f3e5d7c9b",
"connectorProvider": "webcrawler",
"assistantDefaultSelected": true
}
}Upsert a document in a data source
Upsert a document in a data source in the workspace identified by .
curl --request POST \
--url https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"mime_type": "<string>",
"text": "<string>",
"section": {
"prefix": "<string>",
"content": "<string>",
"sections": "<array>"
},
"source_url": "<string>",
"tags": [
"<string>"
],
"timestamp": 123,
"light_document_output": true,
"async": true,
"upsert_context": {}
}
'import requests
url = "https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}"
payload = {
"title": "<string>",
"mime_type": "<string>",
"text": "<string>",
"section": {
"prefix": "<string>",
"content": "<string>",
"sections": "<array>"
},
"source_url": "<string>",
"tags": ["<string>"],
"timestamp": 123,
"light_document_output": True,
"async": True,
"upsert_context": {}
}
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({
title: '<string>',
mime_type: '<string>',
text: '<string>',
section: {prefix: '<string>', content: '<string>', sections: '<array>'},
source_url: '<string>',
tags: ['<string>'],
timestamp: 123,
light_document_output: true,
async: true,
upsert_context: {}
})
};
fetch('https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}', 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://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}",
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([
'title' => '<string>',
'mime_type' => '<string>',
'text' => '<string>',
'section' => [
'prefix' => '<string>',
'content' => '<string>',
'sections' => '<array>'
],
'source_url' => '<string>',
'tags' => [
'<string>'
],
'timestamp' => 123,
'light_document_output' => true,
'async' => true,
'upsert_context' => [
]
]),
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://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"text\": \"<string>\",\n \"section\": {\n \"prefix\": \"<string>\",\n \"content\": \"<string>\",\n \"sections\": \"<array>\"\n },\n \"source_url\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"timestamp\": 123,\n \"light_document_output\": true,\n \"async\": true,\n \"upsert_context\": {}\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://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"text\": \"<string>\",\n \"section\": {\n \"prefix\": \"<string>\",\n \"content\": \"<string>\",\n \"sections\": \"<array>\"\n },\n \"source_url\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"timestamp\": 123,\n \"light_document_output\": true,\n \"async\": true,\n \"upsert_context\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dust.tt/api/v1/w/{wId}/spaces/{spaceId}/data_sources/{dsId}/documents/{documentId}")
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 \"title\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"text\": \"<string>\",\n \"section\": {\n \"prefix\": \"<string>\",\n \"content\": \"<string>\",\n \"sections\": \"<array>\"\n },\n \"source_url\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"timestamp\": 123,\n \"light_document_output\": true,\n \"async\": true,\n \"upsert_context\": {}\n}"
response = http.request(request)
puts response.read_body{
"document": {
"data_source_id": "3b7d9f1e5a",
"created": 1625097600,
"document_id": "2c4a6e8d0f",
"title": "Customer Support FAQ",
"mime_type": "text/md",
"timestamp": 1625097600,
"tags": [
"customer_support",
"faq"
],
"parent_id": "1234f4567c",
"parents": [
"7b9d1f3e5a",
"2c4a6e8d0f"
],
"source_url": "https://example.com/support/article1",
"hash": "a1b2c3d4e5",
"text_size": 1024,
"chunk_count": 5,
"chunks": [
{
"chunk_id": "9f1d3b5a7c",
"text": "This is the first chunk of the document.",
"embedding": [
0.1,
0.2,
0.3,
0.4
]
},
{
"chunk_id": "4a2c6e8b0d",
"text": "This is the second chunk of the document.",
"embedding": [
0.5,
0.6,
0.7,
0.8
]
}
],
"text": "This is the full text content of the document. It contains multiple paragraphs and covers various topics related to customer support.",
"token_count": 150
},
"data_source": {
"id": 12345,
"createdAt": 1625097600,
"name": "Customer Knowledge Base",
"description": "Contains all customer-related information and FAQs",
"dustAPIProjectId": "5e9d8c7b6a",
"connectorId": "1f3e5d7c9b",
"connectorProvider": "webcrawler",
"assistantDefaultSelected": true
}
}Authorizations
Your DUST API key is a Bearer token.
Path Parameters
ID of the workspace
ID of the space
ID of the data source
ID of the document
Body
The title of the document to upsert.
The MIME type of the document to upsert.
The text content of the document to upsert.
A section of a document that can contain nested sections
Show child attributes
Show child attributes
The source URL for the document to upsert.
Tags to associate with the document.
Unix timestamp (in milliseconds) for the document (e.g. 1736365559000).
If true, a lightweight version of the document will be returned in the response (excluding the text, chunks and vectors). Defaults to false.
If true, the upsert operation will be performed asynchronously.
Additional context for the upsert operation.