---
title: "Create Dataset"
method: POST
path: "/api/datasets/"
tags: ["datasets"]
---

# Create Dataset

`POST /api/datasets/`

Create or duplicate datasets

Endpoint:
    POST /api/datasets/     - Create a dataset (from logs, empty, or by duplicating an existing one)

Args (POST):
    - name (string, required)
    - description (string, optional)
    - start_time (string, required, ISO 8601) — ignored if is_empty=true or source_dataset_id set
    - end_time (string, required, ISO 8601) — ignored if is_empty=true or source_dataset_id set
    - sampling (integer, optional, default 100) — percent of logs to add
    - initial_log_filters (object, optional, default {})
    - is_empty (boolean, optional, default false) — create empty dataset without adding logs
    - source_dataset_id (string, optional) — duplicate an existing dataset. Copies all logs
      asynchronously. When set, start_time/end_time/sampling/initial_log_filters are ignored.
      Name defaults to "{source_name} (copy)" if not provided.

Returns (POST 201):
    {
      "id": "dataset_id",
      "name": "...",
      "type": "sampling",
      "status": "initializing",
      ...
    }

Notes:
    - Server sets organization and updated_by; type defaults to "sampling".
    - If selected logs exceed plan limits, returns 400 with error message.
    - Duplication fires `dataset_processing_complete` WS event when done (same as import).

## Headers

- `Authorization` string, required

## Request body

- DatasetCreateRequest
  - `organization` integer, required
  - `name` string, required
  - `description` string
  - `type` 'llm' | 'human' | 'dataset' | 'sampling' | 'reference' — * `llm` - Llm * `human` - Human * `dataset` - Dataset * `sampling` - Sampling * `reference` - Reference
  - `granularity` 'logs' | 'traces' | 'threads' — * `logs` - Logs * `traces` - Traces * `threads` - Threads
  - `initial_log_filters` FilterParamDictPydantic — Pydantic model for FilterParamDict. A dictionary that maps metric names to their filter parameters. Each key is a metric name (str), and each value can be: - A single MetricFilterParamPydantic (one condition) - A List[MetricFilterParamPydantic] (multiple conditions for same metric) - A FilterBundlePydantic (nested filter bundle with connector) Note: Uses extra="allow" for dynamic metric name fields. The __pydantic_extra__ annotation tells Pydantic what types to expect for extra fields, and generates typed additionalProperties in JSON Schema.
  - `start_time` string, date-time
  - `end_time` string, date-time
  - `sampling` integer — Percent of logs to add (1-100).
  - `is_empty` boolean — Create empty dataset without adding logs.
  - `source_dataset_id` string — ID of dataset to duplicate. Copies all logs asynchronously.

## Response `201`

- DatasetCreate
  - `id` string, required
  - `organization` integer, required
  - `updated_by` Editor, required
    - `id` integer, required
    - `email` string, required
    - `name` string, required
    - `username` string
    - `first_name` string
    - `last_name` string
  - `name` string, required
  - `description` string
  - `type` 'llm' | 'human' | 'dataset' | 'sampling' | 'reference' — * `llm` - Llm * `human` - Human * `dataset` - Dataset * `sampling` - Sampling * `reference` - Reference
  - `granularity` 'logs' | 'traces' | 'threads' — * `logs` - Logs * `traces` - Traces * `threads` - Threads
  - `status` 'initializing' | 'ready' | 'failed' | 'loading', required — * `initializing` - Initializing * `ready` - Ready * `failed` - Failed * `loading` - Loading
  - `initial_log_filters` FilterParamDictPydantic — Pydantic model for FilterParamDict. A dictionary that maps metric names to their filter parameters. Each key is a metric name (str), and each value can be: - A single MetricFilterParamPydantic (one condition) - A List[MetricFilterParamPydantic] (multiple conditions for same metric) - A FilterBundlePydantic (nested filter bundle with connector) Note: Uses extra="allow" for dynamic metric name fields. The __pydantic_extra__ annotation tells Pydantic what types to expect for extra fields, and generates typed additionalProperties in JSON Schema.
  - `log_count` integer, required
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

---

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