Skip to navigation

Upload a new document to the Datasphere. Datasphere downloads the file from url and accepts PDF, plain text, and Markdown files up to 10 MB.

Request

Sentence strategyobjectRequired
OR
Sliding strategyobjectRequired
OR
Page strategyobjectRequired
OR
Paragraph strategyobjectRequired

Response

idstringRequiredformat: "uuid"
Unique ID of the Document.
filenamestringRequired
File name of the document. For documents created through this API, Datasphere takes it from the download's `Content-Disposition` header, or from the last segment of the URL path when that header doesn't name a file.
statusenumRequired
Status of the Document.
Allowed values:
tagslist of stringsRequired
Document tags.
chunking_strategyenumRequired
Strategy used to chunk the document.
Allowed values:
max_sentences_per_chunkinteger or nullRequired
Max Sentences per Chunk. Only present when chunking strategy is 'sentence', null otherwise.
split_newlinesboolean or nullRequired
Split on Newlines. Only present when chunking strategy is 'sentence', null otherwise.
overlap_sizeinteger or nullRequired
Overlap Size. Only present when chunking strategy is 'sliding', null otherwise.
chunk_sizeinteger or nullRequired
Chunk Size. Only present when chunking strategy is 'sliding', null otherwise.
number_of_chunksintegerRequired
Number of Chunks in the Document.
chunks_uristringRequired
URI path to the chunks for this document.
created_atdatetimeRequired
Document Creation Date.
updated_atdatetimeRequired
Document Update Date.

Response Example

Response
{
"id": "acaa5c49-be5e-4477-bce0-48f4b23b7720",
"filename": "player_list.pdf",
"status": "in_progress",
"tags": [
"sports",
"football",
"game"
],
"chunking_strategy": "sentence",
"max_sentences_per_chunk": 80,
"split_newlines": true,
"overlap_size": 10,
"chunk_size": 50,
"number_of_chunks": 2345,
"chunks_uri": "/api/rest/datasphere/documents/acaa5c49-be5e-4477-bce0-48f4b23b7720/chunks",
"created_at": "2024-05-06T12:20-12Z",
"updated_at": "2024-05-06T12:20-12Z"
}

Example

import { RestClient } from "@signalwire/sdk";
const client = new RestClient({
project: "your-project-id",
token: "your-api-token",
host: "your-space.signalwire.com"
});
const doc = await client.datasphere.documents.create({
url: "https://filesamples.com/samples/document/txt/sample3.txt",
tags: ["support", "demo"],
});
console.log("Document ID:", doc.id);