Skip to main content
POST
/
documents
/
add-document
Add Document
curl --request POST \
  --url https://api.zeroentropy.dev/v1/documents/add-document \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "collection_name": "<string>",
  "path": "<string>",
  "content": {
    "type": "text",
    "text": "<string>"
  },
  "metadata": {},
  "overwrite": false
}
'
import requests

url = "https://api.zeroentropy.dev/v1/documents/add-document"

payload = {
"collection_name": "<string>",
"path": "<string>",
"content": {
"type": "text",
"text": "<string>"
},
"metadata": {},
"overwrite": False
}
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({
collection_name: '<string>',
path: '<string>',
content: {type: 'text', text: '<string>'},
metadata: {},
overwrite: false
})
};

fetch('https://api.zeroentropy.dev/v1/documents/add-document', 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.zeroentropy.dev/v1/documents/add-document",
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([
'collection_name' => '<string>',
'path' => '<string>',
'content' => [
'type' => 'text',
'text' => '<string>'
],
'metadata' => [

],
'overwrite' => false
]),
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.zeroentropy.dev/v1/documents/add-document"

payload := strings.NewReader("{\n \"collection_name\": \"<string>\",\n \"path\": \"<string>\",\n \"content\": {\n \"type\": \"text\",\n \"text\": \"<string>\"\n },\n \"metadata\": {},\n \"overwrite\": false\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.zeroentropy.dev/v1/documents/add-document")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"collection_name\": \"<string>\",\n \"path\": \"<string>\",\n \"content\": {\n \"type\": \"text\",\n \"text\": \"<string>\"\n },\n \"metadata\": {},\n \"overwrite\": false\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.zeroentropy.dev/v1/documents/add-document")

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 \"collection_name\": \"<string>\",\n \"path\": \"<string>\",\n \"content\": {\n \"type\": \"text\",\n \"text\": \"<string>\"\n },\n \"metadata\": {},\n \"overwrite\": false\n}"

response = http.request(request)
puts response.read_body
{
  "message": "Success!"
}
{
"detail": "Description of Error"
}
{
"detail": "Description of Error"
}
{
"detail": "Description of Error"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

The Authorization header must be provided in the format Bearer <your-api-key>.

You can get your API Key at the Dashboard!

Body

application/json
collection_name
string
required

The name of the collection to be used for this request. A 404 Not Found status code will be returned if this collection name does not exist.

path
string
required

The filepath of the document that you are adding. A 409 Conflict status code will be returned if this path already exists, unless overwrite is set to true.

content
APITextDocument · object
required

The content of the document. There are three possible JSON types that can be passed into this parameter: APITextDocument, APITextPagesDocument, APIBinaryDocument. The type field is how ZeroEntropy will know which document object you have passed in.

metadata
object

This is a metadata JSON object that can be used to assign various metadata attributes to your document. The provided object must match the type dict[str, str | list[str]]. Please read Metadata Filtering for more details. By default, the metadata will be set to {}.

NOTE: The UTF-8-encoded JSON string must be less than 65536 bytes (Whitespace does not count). This limit can be increased upon request.

overwrite
boolean
default:false

Setting this property to true will put this endpoint in "upsert" mode: If the document already exists, this action will atomically replace it.

Response

Successful Response

message
string
default:Success!

This string will always be "Success!". This may change in the future.