create

View as MarkdownOpen in Claude

Upload a new document to the Datasphere.

Request

Sentence strategyobjectRequired
OR
Sliding strategyobjectRequired
OR
Page strategyobjectRequired
OR
Paragraph strategyobjectRequired

Response

idstringRequiredformat: "uuid"
Unique ID of the Document.
filenamestringRequired
Name of the Document.
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
1{
2 "id": "acaa5c49-be5e-4477-bce0-48f4b23b7720",
3 "filename": "player_list.pdf",
4 "status": "in_progress",
5 "tags": [
6 "sports",
7 "football",
8 "game"
9 ],
10 "chunking_strategy": "sentence",
11 "max_sentences_per_chunk": 80,
12 "split_newlines": true,
13 "overlap_size": 10,
14 "chunk_size": 50,
15 "number_of_chunks": 2345,
16 "chunks_uri": "/api/rest/datasphere/documents/acaa5c49-be5e-4477-bce0-48f4b23b7720/chunks",
17 "created_at": "2024-05-06T12:20-12Z",
18 "updated_at": "2024-05-06T12:20-12Z"
19}

Example

1import { RestClient } from "@signalwire/sdk";
2
3const client = new RestClient({
4 project: "your-project-id",
5 token: "your-api-token",
6 host: "your-space.signalwire.com"
7});
8
9const doc = await client.datasphere.documents.create({
10 url: "https://filesamples.com/samples/document/txt/sample3.txt",
11 tags: ["support", "demo"],
12});
13console.log("Document ID:", doc.id);