Upload a document
curl --request POST \
--url https://api.lighton.ai/api/v2/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'file=<string>' \
--form 'collection_type=<string>'import requests
url = "https://api.lighton.ai/api/v2/files"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"collection_type\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "multipart/form-data"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('collection_type', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.lighton.ai/api/v2/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": 1,
"object": "list",
"bytes": 20032,
"created_at": 1631533200,
"filename": "document.pdf",
"purpose": "documents",
"status": "embedded"
}Files
Upload a document
deprecated
Deprecated — this endpoint will be removed in a future release. Use POST /api/v3/files instead.
Endpoint to upload documents.
Documents are saved to the persistent storage, parsed, chunked and embedded.
The file is indexed as a document in the SQL database, with its chunks, and related to its owner, company and collection for permission application.
collection_type is required and must be one of:
private— upload to the caller’s personal workspaceshared— upload to a specific shared workspace;workspace_idis required
Passing collection_type=company returns HTTP 400.
POST
/
api
/
v2
/
files
Upload a document
curl --request POST \
--url https://api.lighton.ai/api/v2/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'file=<string>' \
--form 'collection_type=<string>'import requests
url = "https://api.lighton.ai/api/v2/files"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"collection_type\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "multipart/form-data"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('collection_type', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.lighton.ai/api/v2/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": 1,
"object": "list",
"bytes": 20032,
"created_at": 1631533200,
"filename": "document.pdf",
"purpose": "documents",
"status": "embedded"
}Authorizations
Body
multipart/form-data
Request serializer for file upload.
Response
201 - application/json
Response serializer for file upload results.