Upload a document
curl --request POST \
--url https://api.tensorpro.ai/api/v1/document/ingest \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form 'session_id=<string>' \
--form domain=technical \
--form 'project_id=<string>'import requests
url = "https://api.tensorpro.ai/api/v1/document/ingest"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"session_id": "<string>",
"domain": "technical",
"project_id": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('session_id', '<string>');
form.append('domain', 'technical');
form.append('project_id', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.tensorpro.ai/api/v1/document/ingest', 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.tensorpro.ai/api/v1/document/ingest",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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.tensorpro.ai/api/v1/document/ingest"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.tensorpro.ai/api/v1/document/ingest")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tensorpro.ai/api/v1/document/ingest")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"chunks_stored": 12,
"filename": "launch-plan.pdf",
"file_type": ".pdf",
"session_id": "chat-42",
"domain": "technical",
"source_id": "9a1c3e5f-7b2d-4f6a-8c0e-3b5d7f9a1c2e"
}
Documents
Upload a document
Upload a PDF, Markdown, DOCX or plain-text file, up to 10 MB. EDN splits the text into sections and saves each as a DOCUMENT_VERIFIED memory. With project_id the file becomes a project source; otherwise it goes into your general memory. Counts against your daily ingest quota.
POST
/
api
/
v1
/
document
/
ingest
Upload a document
curl --request POST \
--url https://api.tensorpro.ai/api/v1/document/ingest \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form 'session_id=<string>' \
--form domain=technical \
--form 'project_id=<string>'import requests
url = "https://api.tensorpro.ai/api/v1/document/ingest"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"session_id": "<string>",
"domain": "technical",
"project_id": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('session_id', '<string>');
form.append('domain', 'technical');
form.append('project_id', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.tensorpro.ai/api/v1/document/ingest', 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.tensorpro.ai/api/v1/document/ingest",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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.tensorpro.ai/api/v1/document/ingest"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.tensorpro.ai/api/v1/document/ingest")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tensorpro.ai/api/v1/document/ingest")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"session_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"domain\"\r\n\r\ntechnical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"project_id\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"chunks_stored": 12,
"filename": "launch-plan.pdf",
"file_type": ".pdf",
"session_id": "chat-42",
"domain": "technical",
"source_id": "9a1c3e5f-7b2d-4f6a-8c0e-3b5d7f9a1c2e"
}
Use this endpoint to give EDN a document to answer from, such as a policy, a plan or meeting notes. EDN reads the file, splits it into sections, and saves each section as a
See Error handling.
DOCUMENT_VERIFIED memory that SIPs can use and cite.
What EDN does
- Reads the text from the file: PDF, DOCX, Markdown or plain text, up to 10 MB.
- Splits the text into sections and saves each as a
DOCUMENT_VERIFIEDmemory. - With
project_id, adds the file to the project as a source.
Required headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | Your EDN API key. Create keys in the Console. See Authentication |
Content-Type | multipart/form-data | The request is a file upload. Most HTTP clients set this for you |
Request
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The document: .pdf, .docx, .md or .txt, up to 10 MB |
session_id | string | Yes | Identifier for the conversation. Use the same value for every turn in the same conversation. If EDN hasn’t seen this value before, it creates a new session. Format: 1 to 128 characters, using only letters, digits, period (.), underscore (_), colon (:) and hyphen (-) |
project_id | string | No | Add the file to this project as a source, instead of your general memory. Must be one of your projects |
domain | string | No | The category to save the sections under: technical, factual, professional-context or communication-style. Default: technical |
curl -X POST "https://api.tensorpro.ai/api/v1/document/ingest" \
-H "Authorization: Bearer $EDN_API_KEY" \
-F "file=@launch-plan.pdf" \
-F "session_id=chat-42" \
-F "project_id=b4c8e2f6-1a3d-4e5f-9b7c-2d6e8f0a1b3c"
import os
import requests
with open("launch-plan.pdf", "rb") as f:
resp = requests.post(
"https://api.tensorpro.ai/api/v1/document/ingest",
headers={"Authorization": f"Bearer {os.environ['EDN_API_KEY']}"},
files={"file": f},
data={
"session_id": "chat-42",
"project_id": "b4c8e2f6-1a3d-4e5f-9b7c-2d6e8f0a1b3c"
},
)
resp.raise_for_status()
print(resp.json())
const form = new FormData();
form.append("file", fileInput.files[0]); // launch-plan.pdf
form.append("session_id", "chat-42");
form.append("project_id", "b4c8e2f6-1a3d-4e5f-9b7c-2d6e8f0a1b3c");
const resp = await fetch("https://api.tensorpro.ai/api/v1/document/ingest", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EDN_API_KEY}`,
},
body: form,
});
console.log(await resp.json());
Response
200 OK
{
"chunks_stored": 12,
"filename": "launch-plan.pdf",
"file_type": ".pdf",
"session_id": "chat-42",
"domain": "technical",
"source_id": "9a1c3e5f-7b2d-4f6a-8c0e-3b5d7f9a1c2e"
}
| Field | Type | Description |
|---|---|---|
chunks_stored | integer | How many sections were saved as memories |
filename | string | The uploaded file’s name |
file_type | string | The file’s extension, such as .pdf |
session_id | string | The session you sent |
domain | string | The category the sections were saved under |
source_id | string or null | The project source created for the file when you sent project_id, otherwise null |
Important behavior
- Each file counts once toward your daily limit on saving memory. It isn’t counted if no text could be saved.
- Chat never overwrites a document. If a user later says something different, EDN keeps both.
-
To remove a project document, and everything EDN saved from it, use Remove a project document with the
source_id.
Errors
| Status | Code | When |
|---|---|---|
400 | INVALID_DOCUMENT | The file is empty, has no readable text (such as a scanned PDF), or is corrupt or password-protected |
401 | UNAUTHORIZED | The API key is missing, invalid or revoked |
404 | NOT_FOUND | project_id isn’t one of your projects |
413 | FILE_TOO_LARGE | The file is larger than 10 MB |
415 | UNSUPPORTED_FILE_TYPE | The file isn’t PDF, DOCX, Markdown or plain text |
422 | VALIDATION_ERROR | file or session_id is missing, session_id has invalid characters, or domain isn’t recognised |
429 | RATE_LIMITED | Per-minute or daily limit on saving memory reached. Retry after Retry-After seconds |
500 | INTERNAL_ERROR | Something failed on EDN’s side. Retry later |
{
"chunks_stored": 12,
"filename": "launch-plan.pdf",
"file_type": ".pdf",
"session_id": "chat-42",
"domain": "technical",
"source_id": "9a1c3e5f-7b2d-4f6a-8c0e-3b5d7f9a1c2e"
}
Authorizations
Body
multipart/form-data
Response
Successful Response
