Skip to main content
POST
/
api
/
datasets
/
Create dataset
curl --request POST \
  --url https://api.keywordsai.co/api/datasets/ \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<string>",
  "description": "<string>",
  "type": "<string>",
  "sampling": 123,
  "start_time": "<string>",
  "end_time": "<string>",
  "initial_log_filters": {}
}'
Creates a new dataset from your logs. You can specify filters and sampling rate to select which logs to include.

Authentication

All endpoints require API key authentication:
Authorization: Bearer YOUR_API_KEY

Parameters

name
string
required
The name of the dataset.
description
string
A description of the dataset.
type
string
default:"sampling"
The type of dataset creation. currently supports sampling.
sampling
integer
The number of logs to sample.
start_time
string
The start time for filtering logs (ISO format).
end_time
string
The end_time time for filtering logs (ISO format).
initial_log_filters
object
Filters to apply to select logs for the dataset.
{
  "id": {
    "operator": "in",
    "value": ["log_id_1", "log_id_2"]
  }
}

Request Example

Python
import requests
import json

url = "https://api.keywordsai.co/api/datasets/"

payload = json.dumps({
  "name": "My Dataset",
  "description": "Dataset for evaluation",
  "type": "sampling",
  "sampling": 50,
  "start_time": "2024-01-01T00:00:00Z",
  "end_time": "2024-01-31T23:59:59Z",
  "initial_log_filters": {
    "id": {
      "operator": "in",
      "value": [
        "log_id_1",
        "log_id_2"
      ]
    }
  }
})
headers = {
  'Authorization': 'Bearer YOUR_API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)