Skip to content

Dataset Management

MemoryLayer Enterprise can ingest tabular datasets, automatically profile column statistics and distributions, and extract structured memories from the data. The format is detected from the file extension: CSV (.csv), TSV (.tsv), Parquet (.parquet, .pq), JSON Lines (.jsonl, .ndjson), and Excel (.xlsx, .xls). The maximum upload size is 2 GB by default (MEMORYLAYER_DATASET_MAX_FILE_SIZE).

Datasets are scoped to the workspace of the authenticated request.


Upload a Dataset

Upload a dataset using multipart/form-data. The server stores the original file, converts it to Parquet (Parquet uploads are used as-is), and starts a background profiling job. The upload returns 201 Created. Uploading a file whose content hash matches an existing dataset in the workspace is rejected with 400.

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/datasets" \
-H "Authorization: Bearer $API_KEY" \
-F "file=@sales_data.csv" \
-F "name=Q1 Sales Data" \
-F "target_context_id=analytics" \
-F "importance=0.6" \
-F "sample_rows=1000" \
-F "detect_time_series=true" \
-F "generate_summaries=true"

Parameters:

ParameterDefaultDescription
file(required)The dataset file
name(from filename)Human-readable dataset name
target_context_id_defaultMemory context for extracted memories
importance0.5Default importance for extracted memories (0.0—1.0)
sample_rows1000Max rows to include in LLM summary sample
detect_time_seriestrueAttempt to detect temporal columns
generate_summariestrueGenerate LLM natural-language summaries

The response includes the dataset record and the profiling job:

{
"dataset": {
"id": "ds_abc123",
"workspace_id": "ws_001",
"name": "Q1 Sales Data",
"filename": "sales_data.csv",
"format": "csv",
"status": "pending",
"size_bytes": 512000,
"row_count": 0,
"column_count": 0,
"created_at": "2026-04-01T12:00:00Z"
},
"job": {
"id": "dsjob_xyz789",
"status": "queued",
"progress_percent": 0,
"created_at": "2026-04-01T12:00:00Z"
}
}

Automatic Profiling

When profiling completes, the dataset record is enriched with:

  • Row and column counts
  • Per-column statistics: null counts/percentages, unique values, min/max/mean/median/std for numeric columns, length stats for strings, top values for categoricals
  • Histograms for numeric columns (20 bins by default)
  • Time series detection: identifies temporal columns with resolution (second, minute, hour, day, week, month, year) and date ranges
  • LLM-generated summary: a natural-language description of the dataset

Retrieve the full profile by fetching the dataset:

Terminal window
curl "$MEMORYLAYER_URL/v1/datasets/$DATASET_ID" \
-H "Authorization: Bearer $API_KEY"

The columns array contains per-column profiling results, and profile_summary contains the natural-language summary.


Dataset Statuses

StatusMeaning
pendingUploaded, waiting for profiling
profilingColumn statistics being computed
summarizingLLM generating natural-language summary
completedProfiling and memory extraction done
failedProcessing encountered an error

Query with DuckDB SQL

Slice into any dataset using DuckDB SQL or structured filters. The dataset is queryable as a table named data. Raw SQL must start with SELECT; statements containing mutation keywords (INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, GRANT, REVOKE) are rejected with 400.

Raw SQL

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/datasets/$DATASET_ID/slice" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT region, SUM(revenue) as total FROM data GROUP BY region ORDER BY total DESC LIMIT 10"
}'

Structured filters

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/datasets/$DATASET_ID/slice" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"columns": ["product", "revenue", "date"],
"filters": [
{"column": "revenue", "op": ">", "value": 10000},
{"column": "region", "op": "=", "value": "EMEA"}
],
"order_by": "revenue",
"descending": true,
"limit": 50,
"offset": 0
}'

Supported filter operators: =, !=, <, >, <=, >=, in, like. limit defaults to 100 (max 10,000).

The response includes columns, dtypes, rows, total_matching, returned_count, and sql_executed.


Retrieve Extracted Memories

After profiling, the summaries are embedded and stored as memories in the dataset’s target_context_id. List them with:

Terminal window
curl "$MEMORYLAYER_URL/v1/datasets/$DATASET_ID/memories" \
-H "Authorization: Bearer $API_KEY"

Job Tracking

Terminal window
# List dataset jobs
curl "$MEMORYLAYER_URL/v1/datasets/jobs?status=running" \
-H "Authorization: Bearer $API_KEY"
# Get job status
curl "$MEMORYLAYER_URL/v1/datasets/jobs/$JOB_ID" \
-H "Authorization: Bearer $API_KEY"
# Cancel a job (204 No Content)
curl -X POST "$MEMORYLAYER_URL/v1/datasets/jobs/$JOB_ID/cancel" \
-H "Authorization: Bearer $API_KEY"

List and Delete Datasets

Terminal window
# List datasets
curl "$MEMORYLAYER_URL/v1/datasets?status=completed&limit=50" \
-H "Authorization: Bearer $API_KEY"
# Delete dataset only (204 No Content)
curl -X DELETE "$MEMORYLAYER_URL/v1/datasets/$DATASET_ID" \
-H "Authorization: Bearer $API_KEY"
# Delete dataset and its extracted memories
curl -X DELETE "$MEMORYLAYER_URL/v1/datasets/$DATASET_ID?delete_memories=true" \
-H "Authorization: Bearer $API_KEY"