---
title: "Create a new datasource"
method: POST
path: "/v2/knowledge/{knowledge_id}/datasources"
tags: ["Knowledge Bases"]
---

# Create a new datasource

`POST /v2/knowledge/{knowledge_id}/datasources`

## Path parameters

- `knowledge_id` string, required — The unique identifier of the knowledge base

## Request body

- object — The request body for creating a new datasource. If `file_id` is provided, the file is immediately queued for chunking.
  - `display_name` string — The display name for the datasource visible in the UI. If omitted, the display name is derived from the uploaded file. When both `display_name` and `file_id` are provided, the provided `display_name` is prioritized.
  - `description` string, nullable — The description of the knowledge base
  - `metadata` object — Client-defined metadata associated with the datasource.
  - `file_id` string — The unique identifier of the file used for datasource creation. If provided, the file is immediately queued for chunking.
  - `chunking_options` object — Configuration options specifying how the datasource file is chunked. Required if `file_id` is specified. Defaults to standard chunking options if omitted.
    - `chunking_configuration` union — The chunking configuration settings for the datasource. Defaults to the system's standard chunking configuration if not specified.
      - object — Optimized chunking strategy focusing on speed and avoiding duplication of content chunks.
        - `type` 'default', required
      - object — Provides advanced settings for customizing chunking behavior, enabling fine-grained control to better meet specific data processing needs.
        - `type` 'advanced', required
        - `chunk_max_characters` number — Defines the absolute maximum character length per chunk. Text elements exceeding this size will be automatically split into multiple chunks.
        - `chunk_overlap` number — Specifies the number of characters to overlap between consecutive chunks. This overlap helps maintain semantic continuity when splitting large text elements.
    - `chunking_cleanup_options` object — The cleanup options applied to the datasource content. All options are enabled by default to ensure enhanced security and optimal chunk quality. Defaults to system-standard cleanup options if not specified.
      - `delete_emails` boolean — Removes email addresses from the provided text.
      - `delete_credit_cards` boolean — Removes credit card numbers from the provided text.
      - `delete_phone_numbers` boolean — Removes phone numbers from the provided text.
      - `clean_bullet_points` boolean — Removes bullet points formatting from the text.
      - `clean_numbered_list` boolean — Removes numbered list formatting from the text.
      - `clean_unicode` boolean — Normalizes or removes unnecessary unicode characters from the text.
      - `clean_dashes` boolean — Normalizes or removes various dash characters to standardize the text.
      - `clean_whitespaces` boolean — Trims and normalizes excessive whitespace throughout the text.

## Response `200`

Datasource successfully created

- object
  - `_id` string, ulid — The unique identifier of the data source
  - `display_name` string, required — The display name of the datasource. Normally the name of the uploaded file
  - `description` string, nullable — The description of the knowledge base
  - `status` 'pending' | 'processing' | 'completed' | 'failed' | 'queued', required
  - `file_id` string, nullable — The unique identifier of the file used to create the datasource.
  - `created` string, required — The date and time the datasource was created
  - `updated` string, required — The date and time the datasource was updated
  - `created_by_id` string, nullable — The user ID of the creator of the knowledge base
  - `update_by_id` string, nullable — The user ID of the last user who updated the knowledge base
  - `knowledge_id` string, required — The unique identifier of the knowledge base
  - `chunks_count` number, required — The number of chunks in the datasource
  - `metadata` object, required
    - `words_count` number — Number of words in the text
    - `sentences_count` number — Number of sentences in the text
    - `paragraphs_count` number — Number of paragraphs in the text
    - `tokens_count` number — Number of tokens in the text
    - `characters_count` number — Number of characters in the text
    - `chunks_count` number — Number of total chunks

## Other responses

- `500` — Failed to create datasource

---

[API](https://skmtc.net/orq-ai/apis/orq-ai-api.md) · [All operations](https://skmtc.net/orq-ai/apis/orq-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/orq-ai/orq-ai-api/versions/6a22c53a2580/schema)
