Skip to main content

Link Dataset

Page Outline

Associates an existing dataset with a model, making it the active training data source. Only one dataset can be linked to a model at a time.

Base Path: /api/v1/models

Method: POST

Path: /{model_id}/dataset

Auth: Requires a valid Bearer token (Authorization: Bearer <JWT>)

Path Parameters

ParameterTypeDescription
model_idstringUnique identifier of the model

Request Body

{
"dataset_id": "ds-abc123",
"validate_schema": true
}
FieldTypeRequiredDescription
dataset_idstringID of the dataset to link
validate_schemabooleanIf true (default), validates that the dataset schema is compatible with the model's config.feature_columns and target_column

Behavior

  • If a dataset is already linked, it is replaced by the new one. The previous link is silently removed.
  • Schema validation checks that all configured feature columns exist in the dataset and that the target column is present. Returns HTTP 422 on schema mismatch if validate_schema: true.
  • The dataset must belong to the same organization as the model; cross-org links are rejected with HTTP 403.
  • An audit log entry is written with action model.dataset_linked, referencing both the model_id and dataset_id.
  • Returns HTTP 404 if either the model or dataset is not found.

Response

Returns a DatasetLink confirmation object.

{
"model_id": "mdl-7f3a19bc",
"dataset_id": "ds-abc123",
"dataset_name": "Customer Records Q1 2026",
"schema_validated": true,
"linked_at": "2026-03-13T11:05:00Z"
}