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

# Create a dataset

`POST /api/datasets/`

Create a new dataset from existing logs, create an empty dataset, or duplicate an existing dataset.

## Headers

- `Authorization` string, required

## Request body

- object
  - `name` string — Dataset name. Required unless `source_dataset_id` is provided.
  - `description` string — Dataset description.
  - `sampling` integer — Percent of matching logs to add (1-100).
  - `start_time` string, date-time — Start of the time range to sample logs from.
  - `end_time` string, date-time — End of the time range to sample logs from.
  - `is_empty` boolean — Create an empty dataset without importing logs.
  - `initial_log_filters` object — Platform-standard filters keyed by field name.
  - `source_dataset_id` string — Existing dataset ID to duplicate. Copies logs asynchronously.
  - `granularity` 'logs' | 'traces' — Evaluation unit. Immutable after dataset creation.

## Response `201`

Dataset created.

- DatasetsCreateDatasetResponse201
  - `id` string
  - `name` string
  - `description` string
  - `type` string
  - `status` 'initializing' | 'ready' | 'failed' | 'loading'
  - `initial_log_filters` object — Platform-standard filters keyed by field name.
  - `created_at` string, date-time
  - `updated_at` string, date-time
  - `granularity` 'logs' | 'traces' — Evaluation unit. Immutable after dataset creation.

## Other responses

- `400` — Invalid dataset request, time range, sampling, or processing limit.
- `401` — Unauthorized - Missing/invalid authentication
- `402` — The organization has reached its dataset plan limit.
- `404` — Source dataset not found.

---

[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/revisions/4e064cf81dae/schema)
