> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# get

> Retrieve a specific document.

Retrieve a specific document by ID.

### Schema

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /api/datasphere/documents/{id}:
    get:
      operationId: subpackageDocuments_get_document
      summary: Get document
      description: >-
        Retrieves one source document from the project's Datasphere knowledge
        store by ID. Use it to check a known document and its readiness for
        retrieval; use [List
        documents](/docs/apis/rest/documents/list-documents) to discover IDs or
        [Search documents](/docs/apis/rest/documents/search-documents) to find
        relevant passages.


        #### Permissions


        The API token used to authenticate must have the following scope(s)
        enabled to make a successful request: _DataSphere_.


        [Learn more about API scopes](/docs/platform/your-signalwire-api-space).
      tags:
        - subpackage_documents
      parameters:
        - name: id
          in: path
          description: Unique ID of a Document.
          required: true
          schema:
            $ref: '#/components/schemas/uuid'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Datasphere.Document'
        '400':
          description: The request is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode400'
        '500':
          description: An internal server error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode500'
tags:
  - name: subpackage_documents
servers:
  - url: https://%7BYour_Space_Name%7D.signalwire.com
    description: SignalWire API
components:
  schemas:
    uuid:
      type: string
      format: uuid
      description: Universal Unique Identifier.
      title: uuid
    Datasphere.DocumentStatus:
      type: string
      enum:
        - submitted
        - in_progress
        - completed
        - failed
      description: >-
        Processing state of the document. A new document is `submitted` and
        moves to `in_progress` while its text is extracted, chunked, and
        indexed. It becomes `completed` once every chunk is searchable, or
        `failed` if a chunk can't be indexed, for example because it is too
        long. A file with no extractable text, such as a scanned PDF with no
        text layer, stays `in_progress`.
      title: Datasphere.DocumentStatus
    Datasphere.ChunkingStrategy:
      type: string
      enum:
        - sentence
        - paragraph
        - page
        - sliding
      description: >-
        How Datasphere splits the document into chunks. `sentence` groups
        sentences, `sliding` takes overlapping windows of words, `paragraph`
        splits on blank lines, and `page` makes one chunk per PDF page. Plain
        text and Markdown files have no pages, so `page` splits them on blank
        lines like `paragraph`. Markdown is chunked as written, so chunks keep
        their markup.
      title: Datasphere.ChunkingStrategy
    Datasphere.Document:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of the Document.
        filename:
          type: string
          description: >-
            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.
        status:
          $ref: '#/components/schemas/Datasphere.DocumentStatus'
          description: Status of the Document.
        tags:
          type: array
          items:
            type: string
          description: Document tags.
        chunking_strategy:
          $ref: '#/components/schemas/Datasphere.ChunkingStrategy'
          description: Strategy used to chunk the document.
        max_sentences_per_chunk:
          type:
            - integer
            - 'null'
          description: >-
            Max Sentences per Chunk. Only present when chunking strategy is
            'sentence', null otherwise.
        split_newlines:
          type:
            - boolean
            - 'null'
          description: >-
            Split on Newlines. Only present when chunking strategy is
            'sentence', null otherwise.
        overlap_size:
          type:
            - integer
            - 'null'
          description: >-
            Overlap Size. Only present when chunking strategy is 'sliding', null
            otherwise.
        chunk_size:
          type:
            - integer
            - 'null'
          description: >-
            Chunk Size. Only present when chunking strategy is 'sliding', null
            otherwise.
        number_of_chunks:
          type: integer
          description: Number of Chunks in the Document.
        chunks_uri:
          type: string
          description: URI path to the chunks for this document.
        created_at:
          type: string
          format: date-time
          description: Document Creation Date.
        updated_at:
          type: string
          format: date-time
          description: Document Update Date.
      required:
        - id
        - filename
        - status
        - tags
        - chunking_strategy
        - max_sentences_per_chunk
        - split_newlines
        - overlap_size
        - chunk_size
        - number_of_chunks
        - chunks_uri
        - created_at
        - updated_at
      title: Datasphere.Document
    TypesStatusCodesStatusCode400Error:
      type: string
      enum:
        - Bad Request
      title: TypesStatusCodesStatusCode400Error
    Types.StatusCodes.StatusCode400:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode400Error'
      required:
        - error
      description: The request is invalid.
      title: Types.StatusCodes.StatusCode400
    TypesStatusCodesStatusCode500Error:
      type: string
      enum:
        - Internal Server Error
      title: TypesStatusCodesStatusCode500Error
    Types.StatusCodes.StatusCode500:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode500Error'
      required:
        - error
      description: An internal server error occurred.
      title: Types.StatusCodes.StatusCode500

```

## **Response Example**

### Response (200)

```json
{
  "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**

```typescript {9-10}
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.get("document-id");
console.log(doc.filename, doc.id);
```